Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,2 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
2 |
+
|
3 |
+
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-large")
|
4 |
+
|
5 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-large", device_map="auto", cache_dir="cache", offload_folder="offload" )
|
6 |
+
|
7 |
+
def generate(input_text):
|
8 |
+
input_ids = tokenizer(input_text, return_tensors="pt")
|
9 |
+
output = model.generate(input_ids, max_length=70)
|
10 |
+
return tokenizer.decode(output[0], skip_special_tokens=True)
|
11 |
+
|
12 |
+
#@title GUI
|
13 |
import gradio as gr
|
14 |
+
|
15 |
+
title = "Flan T5 :)"
|
16 |
+
|
17 |
+
def inference(text):
|
18 |
+
return generate(text)
|
19 |
+
|
20 |
+
io = gr.Interface(
|
21 |
+
inference,
|
22 |
+
gr.Textbox(lines=3),
|
23 |
+
outputs=[
|
24 |
+
gr.Textbox(lines=3, label="Flan T5")
|
25 |
+
],
|
26 |
+
title=title,
|
27 |
+
)
|
28 |
+
io.launch(share=True,debug=True)
|