prograk commited on
Commit
c06167b
·
verified ·
1 Parent(s): 5db38fc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from gradio.themes.builder_app import output_code
4
+
5
+ # Use a pipeline as a high-level helper
6
+ from transformers import pipeline
7
+
8
+ # Use a pipeline as a high-level helper
9
+ from transformers import pipeline
10
+
11
+ text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
12
+
13
+ # model_path = ("../Models/models--sshleifer--distilbart-cnn-12-6/snapshots/a4f8f3ea906ed274767e9906dbaede7531d660ff")
14
+ # text_summary = pipeline("summarization", model=model_path, torch_dtype=torch.bfloat16)
15
+
16
+ # text = '''Elon Reeve Musk (/ˈiːlɒn/ EE-lon; born June 28, 1971) is a businessman known for his leadership of Tesla, SpaceX, and X (formerly Twitter). Since 2025, he has been a senior advisor to United States President Donald Trump and the de facto head of the Department of Government Efficiency (DOGE). Musk is the wealthiest person in the world; as of March 2025, Forbes estimates his net worth to be US$345 billion. He was named Time magazine's Person of the Year in 2021.'''
17
+ # print(text_summary(text))
18
+
19
+ def summary (input):
20
+ output = text_summary(input)
21
+ return output[0]['summary_text']
22
+
23
+ gr.close_all()
24
+
25
+ # demo = gr.Interface(fn=summary, inputs="text", outputs="text")
26
+ demo = gr.Interface(fn=summary,
27
+ inputs=[gr.Textbox(label="Input text to summarize", lines=6)],
28
+ outputs=[gr.Textbox(label="Summarized text", lines=4)],
29
+ title="@GenAILearniverse Project 1: Text Summarizer",
30
+ description="THIS APPLICATION WILL BE USED TO SUMMARIZE THE TEXT")
31
+
32
+ demo.launch()