Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
3 |
|
4 |
-
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-
|
5 |
-
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-
|
6 |
|
|
|
7 |
|
8 |
def get_examples ():
|
9 |
return [
|
@@ -22,15 +23,15 @@ on Friday is higher by 40 * 40/100 = <<40*40/100=16>>16 books. How many books do
|
|
22 |
def text2text(input_text):
|
23 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
24 |
|
25 |
-
outputs = model.generate(input_ids, max_length=
|
26 |
return tokenizer.decode(outputs[0])
|
27 |
|
28 |
|
29 |
with gr.Blocks() as demo:
|
30 |
|
31 |
-
txt_in = gr.Textbox(label="Input", lines=
|
32 |
correct_label = gr.Label(label="Correct")
|
33 |
-
txt_out = gr.Textbox(value="", label="Output")
|
34 |
|
35 |
|
36 |
btn = gr.Button(value="Submit")
|
@@ -41,7 +42,8 @@ with gr.Blocks() as demo:
|
|
41 |
examples=get_examples(),
|
42 |
inputs=[txt_in,correct_label]
|
43 |
)
|
44 |
-
|
|
|
45 |
|
46 |
if __name__ == "__main__":
|
47 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
3 |
|
4 |
+
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
|
5 |
+
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
|
6 |
|
7 |
+
title = "Flan T5 Large Demo"
|
8 |
|
9 |
def get_examples ():
|
10 |
return [
|
|
|
23 |
def text2text(input_text):
|
24 |
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
25 |
|
26 |
+
outputs = model.generate(input_ids, max_length=100)
|
27 |
return tokenizer.decode(outputs[0])
|
28 |
|
29 |
|
30 |
with gr.Blocks() as demo:
|
31 |
|
32 |
+
txt_in = gr.Textbox(label="Input", lines=3)
|
33 |
correct_label = gr.Label(label="Correct")
|
34 |
+
txt_out = gr.Textbox(value="", label="Output", lines=3)
|
35 |
|
36 |
|
37 |
btn = gr.Button(value="Submit")
|
|
|
42 |
examples=get_examples(),
|
43 |
inputs=[txt_in,correct_label]
|
44 |
)
|
45 |
+
|
46 |
+
demo.
|
47 |
|
48 |
if __name__ == "__main__":
|
49 |
demo.launch()
|