rexthecoder commited on
Commit
769a6fc
·
1 Parent(s): 28bac9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -5,13 +5,16 @@ tokenizer = AutoTokenizer.from_pretrained("mrm8488/flan-t5-small-finetuned-samsu
5
 
6
  model = AutoModelForSeq2SeqLM.from_pretrained("mrm8488/flan-t5-small-finetuned-samsum")
7
 
 
 
8
 
9
- def predict_sentiment(input: Input):
 
10
  input_ids = tokenizer(input.text, return_tensors="pt").input_ids
11
- outputs = model.generate(input_ids, max_length=30)
12
  return tokenizer.decode(outputs[0], skip_special_tokens=True)
13
 
14
 
15
- iface = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text")
16
 
17
  iface.launch()
 
5
 
6
  model = AutoModelForSeq2SeqLM.from_pretrained("mrm8488/flan-t5-small-finetuned-samsum")
7
 
8
+ class Input(BaseModel):
9
+ text: str
10
 
11
+
12
+ def predict_sentiment(input: Input, words):
13
  input_ids = tokenizer(input.text, return_tensors="pt").input_ids
14
+ outputs = model.generate(input_ids, max_length=words)
15
  return tokenizer.decode(outputs[0], skip_special_tokens=True)
16
 
17
 
18
+ iface = gr.Interface(fn=predict_sentiment, inputs=["text", gr.Slider(0, 100)], outputs="text")
19
 
20
  iface.launch()