Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +25 -4
  3. requirements.txt +6 -1
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ venv/
app.py CHANGED
@@ -1,7 +1,28 @@
1
  import gradio as gr
 
2
 
3
- def analyze_file(file):
4
- return f" Uploaded file: {file.name}"
5
 
6
- iface = gr.Interface(analyze_file, inputs="upload", outputs="text", title="File Upload")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ summarizer = pipeline("summarization")
 
5
 
6
+
7
+ def summarize(doc: str) -> str:
8
+ results = summarizer(doc, max_length=150, min_length=30, do_sample=False)
9
+ summary_text = results[0]["summary_text"]
10
+ return summary_text
11
+
12
+
13
+ app = gr.Interface(
14
+ summarize,
15
+ [gr.Textbox(label="Text to summarize")],
16
+ gr.Textbox(label="Summary"),
17
+ examples=[
18
+ [
19
+ "Researchers have discovered a new species of dinosaur in Argentina. The dinosaur, named Bajadasaurus pronuspinax, lived approximately 140 million years ago during the Cretaceous period. It was a herbivore with a long neck and spiky back, similar to the more well-known Stegosaurus. The discovery sheds light on the diversity of dinosaurs in South America during the Cretaceous period."
20
+ ],
21
+ [
22
+ "Recent advances in deep learning have led to significant improvements in natural language processing tasks. In this paper, we propose a novel architecture for text summarization using transformer-based models. Our approach leverages self-attention mechanisms to capture long-range dependencies and generate coherent summaries. Experimental results on benchmark datasets demonstrate the effectiveness of our method compared to existing approaches."
23
+ ],
24
+ ],
25
+ )
26
+
27
+ if __name__ == "__main__":
28
+ app.launch()
requirements.txt CHANGED
@@ -1 +1,6 @@
1
- gradio_pdf
 
 
 
 
 
 
1
+ gradio_pdf
2
+ transformers
3
+ torch
4
+ torchvision
5
+ torchaudio
6
+ datasets