Ahmed commited on
Commit
90a4ac7
·
verified ·
1 Parent(s): fe1be53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -9
app.py CHANGED
@@ -1,12 +1,34 @@
1
- import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- def greet(name, intensity):
4
- return "Hello, " + name + "!" * int(intensity)
5
 
6
- demo = gr.Interface(
7
- fn=greet,
8
- inputs=["text", "slider"],
9
- outputs=["text"],
10
- )
 
 
 
 
 
 
 
 
 
 
11
 
12
- demo.launch()
 
1
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
2
+
3
+ tokenizerModelName = 'google/flan-t5-base'
4
+ instruct_model_name='truocpham/flan-dialogue-summary-checkpoint'
5
+
6
+ tokenizer = AutoTokenizer.from_pretrained(tokenizerModelName)
7
+ model = AutoModelForSeq2SeqLM.from_pretrained(instruct_model_name)
8
+
9
+ def SummarizeThis(dialogue):
10
+ prompt = f"""
11
+ Summarize the following conversation.
12
+
13
+ {dialogue}
14
 
15
+ Summary:
16
+ """
17
 
18
+ inputs = tokenizer(prompt, return_tensors='pt')
19
+ output = tokenizer.decode(
20
+ model.generate(
21
+ inputs["input_ids"],
22
+ max_new_tokens=200,
23
+ )[0],
24
+ skip_special_tokens=True
25
+ )
26
+
27
+ return output
28
+
29
+
30
+ # Making the gradio application
31
+ import gradio as gr
32
+ iface = gr.Interface(fn=SummarizeThis, inputs="text", outputs=["text"], title="Summarization")
33
 
34
+ iface.launch()