Pavankalyan
commited on
Commit
Β·
61e2838
1
Parent(s):
be6a2c9
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,26 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
|
4 |
def greet(name):
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
|
8 |
# We instantiate the Textbox class
|
9 |
-
textbox = gr.Textbox(label="Type your name here:", placeholder="
|
10 |
|
11 |
gr.Interface(fn=greet, inputs=textbox, outputs="text").launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
3 |
+
|
4 |
+
tokenizer = T5Tokenizer.from_pretrained("./model_files")
|
5 |
+
model = T5ForConditionalGeneration.from_pretrained("./model_files")
|
6 |
+
|
7 |
+
|
8 |
|
9 |
|
10 |
def greet(name):
|
11 |
+
inp = "Summarize:" + name
|
12 |
+
input_ids = tokenizer(inp, return_tensors="pt").input_ids
|
13 |
+
outputs = model.generate(input_ids,
|
14 |
+
max_length=150,
|
15 |
+
num_beams=2,
|
16 |
+
repetition_penalty=2.5,
|
17 |
+
length_penalty=1.0,
|
18 |
+
early_stopping=True)
|
19 |
+
return tokenizer.decode(outputs[0],skip_special_tokens=True, clean_up_tokenization_spaces=True))
|
20 |
+
|
21 |
|
22 |
|
23 |
# We instantiate the Textbox class
|
24 |
+
textbox = gr.Textbox(label="Type your name here:", placeholder="Article", lines=5)
|
25 |
|
26 |
gr.Interface(fn=greet, inputs=textbox, outputs="text").launch()
|