AlGe commited on
Commit
fd5bc1e
·
verified ·
1 Parent(s): fefab3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -83
app.py CHANGED
@@ -162,86 +162,37 @@ examples = [
162
  ["You know, this conversation reminded me of an incredible experience I had at a music festival in college. I'll never forget it. It was a rainy day, but we didn't care, and the band that was playing was my absolute favorite. Even though we were all soaked, the crowd kept on dancing and singing along. The energy was incredible, and I remember feeling so connected to everyone around me. It was as if the rain made the whole experience even more magical. I was surrounded by friends, and we all shared this special moment together. It was one of the best moments of my life, and I still get goosebumps when I think about it. Sometimes, it's the unexpected things that create the most amazing memories, you know?"],
163
  ]
164
 
165
- # Define the sections as Markdown content
166
- intro_text = """
167
- # Introduction
168
- Welcome to this Gradio app. This section provides an introduction to the app.
169
- """
170
- method_text = """
171
- # Method
172
- This section describes the methodology used in this app.
173
- """
174
- demo_text = """
175
- # Demo
176
- Below is the interactive demo of the app.
177
- """
178
- conclusion_text = """
179
- # Conclusion
180
- This section provides conclusions and future directions.
181
- """
182
-
183
- # Define the main content display area
184
- content = gr.Markdown(intro_text)
185
-
186
- # Define the update function for the main content area
187
- def update_content(section):
188
- if section == "Introduction":
189
- return gr.Markdown.update(value=intro_text)
190
- elif section == "Method":
191
- return gr.Markdown.update(value=method_text)
192
- elif section == "Demo":
193
- return gr.Markdown.update(value=demo_text)
194
- elif section == "Conclusion":
195
- return gr.Markdown.update(value=conclusion_text)
196
-
197
- # Define the Gradio interface with a sidebar for navigation
198
- with gr.Blocks(theme=MPGPoster()) as demo:
199
- state = gr.State(value="Introduction")
200
- with gr.Row():
201
- with gr.Column(scale=1):
202
- gr.Markdown("## Navigation")
203
- sections = ["Introduction", "Method", "Demo", "Conclusion"]
204
- section_buttons = [gr.Button(value=section) for section in sections]
205
-
206
- for button, section in zip(section_buttons, sections):
207
- button.click(fn=update_content, inputs=state, outputs=content).then(
208
- fn=lambda x: section, inputs=None, outputs=state
209
- )
210
-
211
- with gr.Column(scale=4):
212
- content
213
-
214
- with gr.Row():
215
- iface = gr.Interface(
216
- fn=all,
217
- inputs=gr.Textbox(lines=5, label="Input Text", placeholder="Write about how your breakfast went or anything else that happend or might happen to you ..."),
218
- outputs=[
219
- gr.HighlightedText(label="Binary Sequence Classification",
220
- color_map={
221
- "External": "#6ad5bcff",
222
- "Internal": "#ee8bacff"}
223
- ),
224
- gr.HighlightedText(label="Extended Sequence Classification",
225
- color_map={
226
- "INTemothou": "#c27ba0",
227
- "INTpercept": "#cc4125",
228
- "INTtime": "#e06f66",
229
- "INTplace": "#e69138",
230
- "INTevent": "#ee8bacff",
231
- "EXTsemantic": "#6ad5bc",
232
- "EXTrepetition": "#11aeb8",
233
- "EXTother": "#24aaad",
234
- }
235
- ),
236
- gr.Label(label="Internal Detail Count"),
237
- gr.Label(label="External Detail Count"),
238
- gr.Label(label="Approximated Internal Detail Ratio")
239
- ],
240
- title="Scoring Demo",
241
- description="Autobiographical Memory Analysis: This demo combines two text - and two sequence classification models to showcase our automated Autobiographical Interview scoring method. Submit a narrative to see the results.",
242
- examples=examples,
243
- )
244
- iface.render()
245
-
246
- # Launch the app
247
- demo.launch()
 
162
  ["You know, this conversation reminded me of an incredible experience I had at a music festival in college. I'll never forget it. It was a rainy day, but we didn't care, and the band that was playing was my absolute favorite. Even though we were all soaked, the crowd kept on dancing and singing along. The energy was incredible, and I remember feeling so connected to everyone around me. It was as if the rain made the whole experience even more magical. I was surrounded by friends, and we all shared this special moment together. It was one of the best moments of my life, and I still get goosebumps when I think about it. Sometimes, it's the unexpected things that create the most amazing memories, you know?"],
163
  ]
164
 
165
+ # Define Gradio interface
166
+ iface = gr.Interface(
167
+ fn=all,
168
+ inputs=gr.Textbox(lines=5, label="Input Text",placeholder="Write about how your breakfast went or anything else that happend or might happen to you ..."),
169
+ outputs=[
170
+ gr.HighlightedText(label="Binary Sequence Classification",
171
+ color_map={
172
+ "External": "#6ad5bcff",
173
+ "Internal": "#ee8bacff"}
174
+ ),
175
+ gr.HighlightedText(label="Extended Sequence Classification",
176
+ color_map={
177
+ "INTemothou": "#c27ba0",
178
+ "INTpercept": "#cc4125",
179
+ "INTtime": "#e06f66",
180
+ "INTplace": "#e69138",
181
+ "INTevent": "#ee8bacff",
182
+ "EXTsemantic": "#6ad5bc",
183
+ "EXTrepetition": "#11aeb8",
184
+ "EXTother": "#24aaad",
185
+ }
186
+ ),
187
+ gr.Label(label="Internal Detail Count"),
188
+ gr.Label(label="External Detail Count"),
189
+ gr.Label(label="Approximated Internal Detail Ratio")
190
+ ],
191
+ title="Scoring Demo",
192
+ description="Autobiographical Memory Analysis: This demo combines two text - and two sequence classification models to showcase our automated Autobiographical Interview scoring method. Submit a narrative to see the results.",
193
+ examples =examples,
194
+ theme= mpg_poster #"soft" #monochrome
195
+ )
196
+
197
+ # Launch the combined interface
198
+ iface.launch()