SatyamSinghal commited on
Commit
2007180
·
verified ·
1 Parent(s): 1af75b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -24
app.py CHANGED
@@ -19,7 +19,7 @@ def query_summarization(input_text):
19
  response = requests.post(API_URL, headers=headers, json=payload)
20
  response.raise_for_status() # Raise error for bad responses (4xx, 5xx)
21
  result = response.json()
22
-
23
  # Extract and return the summary
24
  if result and "summary_text" in result[0]:
25
  return result[0]["summary_text"]
@@ -28,28 +28,8 @@ def query_summarization(input_text):
28
  except requests.exceptions.RequestException as e:
29
  return f"Error: {e}"
30
 
31
- # Create Gradio interface for text summarization
32
- iface = gr.Interface(
33
- fn=query_summarization, # Function to call
34
- inputs=gr.Textbox(
35
- lines=10,
36
- placeholder="Enter your text here...",
37
- label="Input Text",
38
- elem_id="input-text"
39
- ), # Input text area
40
- outputs=gr.Textbox(
41
- placeholder="Summary will appear here...",
42
- label="Summary",
43
- elem_id="summary-output"
44
- ), # Output summary text
45
- title="AI Text Summarization",
46
- description="Enter text to get a summarized version using Hugging Face's BART model.",
47
- theme="huggingface", # Apply Hugging Face theme
48
- live=True, # Set to True for live updates (optional)
49
- )
50
-
51
  # Custom CSS styling
52
- css = """
53
  #input-text {
54
  font-size: 18px;
55
  border: 2px solid #8a2be2;
@@ -96,5 +76,24 @@ h1 {
96
  }
97
  """
98
 
99
- # Launch the interface with custom styling
100
- iface.launch(share=True, css=css)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  response = requests.post(API_URL, headers=headers, json=payload)
20
  response.raise_for_status() # Raise error for bad responses (4xx, 5xx)
21
  result = response.json()
22
+
23
  # Extract and return the summary
24
  if result and "summary_text" in result[0]:
25
  return result[0]["summary_text"]
 
28
  except requests.exceptions.RequestException as e:
29
  return f"Error: {e}"
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  # Custom CSS styling
32
+ custom_css = """
33
  #input-text {
34
  font-size: 18px;
35
  border: 2px solid #8a2be2;
 
76
  }
77
  """
78
 
79
+ # Create Gradio interface with custom CSS
80
+ iface = gr.Interface(
81
+ fn=query_summarization, # Function to call
82
+ inputs=gr.Textbox(
83
+ lines=10,
84
+ placeholder="Enter your text here...",
85
+ label="Input Text",
86
+ elem_id="input-text"
87
+ ), # Input text area
88
+ outputs=gr.Textbox(
89
+ placeholder="Summary will appear here...",
90
+ label="Summary",
91
+ elem_id="summary-output"
92
+ ), # Output summary text
93
+ title="AI Text Summarization",
94
+ description="Enter text to get a summarized version using Hugging Face's BART model.",
95
+ css=custom_css # Apply custom CSS here
96
+ )
97
+
98
+ # Launch the interface
99
+ iface.launch(share=True)