kurry commited on
Commit
c3db1be
1 Parent(s): 15a6299

updated app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -1,3 +1,16 @@
1
  import gradio as gr
 
2
 
3
- gr.load("kurry/models/t5_small_finetuned").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
3
 
4
+ def generate_text(input_text):
5
+ # Load pre-trained model and tokenizer
6
+ model_name = 'kurry/t5_small_finetuned'
7
+ model = T5ForConditionalGeneration.from_pretrained(model_name)
8
+ tokenizer = T5Tokenizer.from_pretrained(model_name)
9
+
10
+ # Generate summary
11
+ inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", truncation=True)
12
+ outputs = model.generate(inputs)
13
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
14
+
15
+ iface = gr.Interface(fn=generate_text, inputs='text', outputs='text')
16
+ iface.launch()