Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,18 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
iface.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 |
+
input_text = "translate English to German: How old are you?"
|
8 |
+
|
9 |
+
|
10 |
+
def greet(input_text):
|
11 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
12 |
+
|
13 |
+
outputs = model.generate(input_ids, max_length=40)
|
14 |
+
return tokenizer.decode(outputs[0])
|
15 |
|
|
|
|
|
16 |
|
17 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
18 |
iface.launch()
|