Spaces:
Sleeping
Sleeping
Commit
·
28bac9d
1
Parent(s):
661c5c9
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,17 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 3 |
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained("mrm8488/flan-t5-small-finetuned-samsum")
|
| 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()
|