MrSimple07 commited on
Commit
9abda6a
·
verified ·
1 Parent(s): 5b81475

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -53
app.py CHANGED
@@ -16,57 +16,59 @@ example_texts = [
16
  ["Climate change is one of the most pressing issues of our time. Rising global temperatures, melting ice caps, and extreme weather events are just some of the impacts being observed. Scientists and policymakers are working together to find sustainable solutions to mitigate its effects and protect the planet for future generations."]
17
  ]
18
 
19
- # Create a Gradio interface
20
- iface = gr.Interface(
21
- fn=summarize_text,
22
- inputs=[
23
- gr.inputs.Textbox(lines=10, label="Enter Text to Summarize", placeholder="Type or paste your article here..."),
24
- gr.inputs.Slider(50, 200, step=10, default=100, label="Max Length of Summary"),
25
- gr.inputs.Slider(20, 100, step=10, default=50, label="Min Length of Summary")
26
- ],
27
- outputs=gr.outputs.Textbox(label="Summarized Text"),
28
- title="📄 Text Summarization App",
29
- description="This app generates a concise summary for long-form text (articles, reports, books, etc.). Adjust the sliders to control the length of the summary. Powered by Hugging Face's BART model.",
30
- examples=example_texts,
31
- theme="huggingface",
32
- live=True,
33
- allow_flagging="never"
34
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
- # Custom styling for enhanced aesthetics
37
- iface.launch(share=True, server_port=7860, inline=True,
38
- server_name="0.0.0.0",
39
- style={
40
- "title": {
41
- "color": "#5A67D8",
42
- "font-weight": "bold"
43
- },
44
- "description": {
45
- "color": "#4A5568",
46
- "font-size": "1.1em"
47
- },
48
- "input_textbox": {
49
- "background-color": "#EDF2F7",
50
- "border-radius": "8px",
51
- "font-family": "sans-serif"
52
- },
53
- "input_slider": {
54
- "background-color": "#CBD5E0",
55
- "border-radius": "4px"
56
- },
57
- "output_textbox": {
58
- "background-color": "#E2E8F0",
59
- "font-family": "serif"
60
- },
61
- "examples": {
62
- "background-color": "#E2E8F0",
63
- "border-radius": "6px"
64
- },
65
- "button": {
66
- "background-color": "#4299E1",
67
- "color": "#FFF",
68
- "font-weight": "bold",
69
- "border-radius": "6px"
70
- }
71
- }
72
- )
 
16
  ["Climate change is one of the most pressing issues of our time. Rising global temperatures, melting ice caps, and extreme weather events are just some of the impacts being observed. Scientists and policymakers are working together to find sustainable solutions to mitigate its effects and protect the planet for future generations."]
17
  ]
18
 
19
+ # Create a Gradio interface with modern syntax
20
+ with gr.Blocks(theme=gr.themes.HuggingFace()) as iface:
21
+ gr.Markdown("# 📄 Text Summarization App")
22
+ gr.Markdown("This app generates a concise summary for long-form text (articles, reports, books, etc.). Adjust the sliders to control the length of the summary. Powered by Hugging Face's BART model.")
23
+
24
+ with gr.Row():
25
+ with gr.Column():
26
+ input_text = gr.Textbox(
27
+ lines=10,
28
+ label="Enter Text to Summarize",
29
+ placeholder="Type or paste your article here...",
30
+ elem_classes="input_textbox"
31
+ )
32
+ max_length = gr.Slider(
33
+ minimum=50,
34
+ maximum=200,
35
+ value=100,
36
+ step=10,
37
+ label="Max Length of Summary",
38
+ elem_classes="input_slider"
39
+ )
40
+ min_length = gr.Slider(
41
+ minimum=20,
42
+ maximum=100,
43
+ value=50,
44
+ step=10,
45
+ label="Min Length of Summary",
46
+ elem_classes="input_slider"
47
+ )
48
+
49
+ with gr.Column():
50
+ output_text = gr.Textbox(
51
+ label="Summarized Text",
52
+ elem_classes="output_textbox"
53
+ )
54
+
55
+ # Add examples
56
+ gr.Examples(
57
+ examples=example_texts,
58
+ inputs=[input_text],
59
+ examples_per_page=3
60
+ )
61
+
62
+ # Create the submit button
63
+ input_text.submit(
64
+ fn=summarize_text,
65
+ inputs=[input_text, max_length, min_length],
66
+ outputs=output_text
67
+ )
68
 
69
+ # Launch the app
70
+ iface.launch(
71
+ share=True,
72
+ server_port=7860,
73
+ server_name="0.0.0.0"
74
+ )