saadob12 commited on
Commit
3e77d90
·
1 Parent(s): f590933

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -57,14 +57,34 @@ class Model:
57
  self.tokenizer = AutoTokenizer.from_pretrained('saadob12/t5_C2T_big')
58
  self.model = AutoModelForSeq2SeqLM.from_pretrained('saadob12/t5_C2T_big').to(self.device)
59
  elif mode.lower() == 'analytical':
60
- self.tokenizer = AutoTokenizer.from_pretrained('saadob12/t5_C2T_autochart')
61
- self.model = AutoModelForSeq2SeqLM.from_pretrained('saadob12/t5_C2T_autochart').to(self.device)
62
 
63
  def generate(self):
64
  tokens = self.tokenizer.encode(self.prefix + self.text, truncation=self.truncation, padding=self.padding, return_tensors='pt').to(self.device)
65
  generated = self.model.generate(tokens, num_beams=4, max_length=256)
66
  tgt_text = self.tokenizer.decode(generated[0], skip_special_tokens=True, clean_up_tokenization_spaces=True)
67
  summary = str(tgt_text).strip('[]""')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  return summary
69
 
70
  st.title('Chart and Data Summarization')
 
57
  self.tokenizer = AutoTokenizer.from_pretrained('saadob12/t5_C2T_big')
58
  self.model = AutoModelForSeq2SeqLM.from_pretrained('saadob12/t5_C2T_big').to(self.device)
59
  elif mode.lower() == 'analytical':
60
+ self.tokenizer = AutoTokenizer.from_pretrained('saadob12/t5_autochart_2.0')
61
+ self.model = AutoModelForSeq2SeqLM.from_pretrained('saadob12/t5_autochart_2.0').to(self.device)
62
 
63
  def generate(self):
64
  tokens = self.tokenizer.encode(self.prefix + self.text, truncation=self.truncation, padding=self.padding, return_tensors='pt').to(self.device)
65
  generated = self.model.generate(tokens, num_beams=4, max_length=256)
66
  tgt_text = self.tokenizer.decode(generated[0], skip_special_tokens=True, clean_up_tokenization_spaces=True)
67
  summary = str(tgt_text).strip('[]""')
68
+ if 'barchart' in summary:
69
+ summary.replace('barchart','statistic')
70
+ if 'bar graph' in summary:
71
+ summary.replace('bar graph','statistic')
72
+ if 'bar plot' in summary:
73
+ summary.replace('bar plot','statistic')
74
+ if 'scatter plot' in summary:
75
+ summary.replace('scatter plot','statistic')
76
+ if 'scatter graph' in summary:
77
+ summary.replace('scatter graph','statistic')
78
+ if 'scatterchart' in summary:
79
+ summary.replace('scatter chart','statistic')
80
+ if 'line plot' in summary:
81
+ summary.replace('line plot','statistic')
82
+ if 'line graph' in summary:
83
+ summary.replace('line graph','statistic')
84
+ if 'linechart' in summary:
85
+ summary.replace('linechart','statistic')
86
+ if 'graph' in summary:
87
+ summary.replace('graph','statistic'
88
  return summary
89
 
90
  st.title('Chart and Data Summarization')