macrdel commited on
Commit
6973620
·
1 Parent(s): 3a69ea2

update pipeline summarize src.py

Browse files
Files changed (1) hide show
  1. app/src/src.py +9 -2
app/src/src.py CHANGED
@@ -62,13 +62,20 @@ def pipeline_stats(data):
62
  """Get statistic of sentiment"""
63
  return data['sentiment'].value_counts(normalize=True).mul(100).round(2)
64
 
65
- def pipeline_summarize(data, model, length=2000, max_length=100):
66
  """Get summarization result"""
67
  text = " ".join(data)
68
  result_text = []
69
 
70
  for i in range(0, len(text), length):
71
  new_text = text[i : i + length]
72
- result_text.append(model(new_text, max_length=max_length))
 
 
 
 
 
 
 
73
 
74
  return ". ".join([i[0]["summary_text"] for i in result_text])
 
62
  """Get statistic of sentiment"""
63
  return data['sentiment'].value_counts(normalize=True).mul(100).round(2)
64
 
65
+ def pipeline_summarize(data, headers, url, length=2000, max_length=25):
66
  """Get summarization result"""
67
  text = " ".join(data)
68
  result_text = []
69
 
70
  for i in range(0, len(text), length):
71
  new_text = text[i : i + length]
72
+ payload = {
73
+ "inputs": new_text,
74
+ "parameters": {
75
+ "max_length": max_length
76
+ }
77
+ }
78
+ res = requests.post(url, headers=headers, json=payload)
79
+ result_text.append(res.json()[0]['generated_text'])
80
 
81
  return ". ".join([i[0]["summary_text"] for i in result_text])