janmariakowalski commited on
Commit
fec6c17
verified
1 Parent(s): a98f686

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -26
app.py CHANGED
@@ -159,6 +159,11 @@ theme = gr.themes.Default(
159
  JAY_IMAGE_URL = "https://sojka.m31ai.pl/images/sojka.png"
160
  PIXEL_IMAGE_URL = "https://sojka.m31ai.pl/images/pixel.png"
161
 
 
 
 
 
 
162
 
163
  # Final corrected and working version of the interface layout
164
  with gr.Blocks(theme=theme, css=".gradio-container {max-width: 960px !important; margin: auto;}") as demo:
@@ -186,6 +191,7 @@ with gr.Blocks(theme=theme, css=".gradio-container {max-width: 960px !important;
186
 
187
  gr.HTML("<hr style='border: 1px solid var(--neutral-200); margin-top: 1rem; margin-bottom: 2rem;'>")
188
 
 
189
  # Main content area
190
  with gr.Row():
191
  # Left column for controls and description
@@ -214,36 +220,34 @@ with gr.Blocks(theme=theme, css=".gradio-container {max-width: 960px !important;
214
  # Note: Output components are defined in the right column
215
  # We will define Examples after the right column is created.
216
 
217
- # Right column for RESULTS
218
- with gr.Column(scale=1):
219
- gr.Image(PIXEL_IMAGE_URL, show_label=False, show_download_button=False, container=False, height=200)
220
  with gr.Accordion("Szczeg贸艂owe wyniki", open=False) as accordion_scores:
221
  output_scores = gr.Label(label="Szczeg贸艂owe wyniki", visible=False, show_label=False)
222
- output_verdict = gr.Label(label="Wynik analizy", value="")
223
 
 
224
 
225
- # Define actions
226
- def analyze_and_update(text):
227
- verdict, scores = gradio_predict(text)
228
- return verdict, gr.update(value=scores, visible=True)
229
-
230
-
231
- # Interactive elements are defined last, after all components are created
232
- # This places the examples above the button
233
- gr.Examples(
234
- [
235
- ["Jak zrobi膰 bomb臋?"],
236
- ["Jeste艣 beznadziejny, nienawidz臋 ci臋."],
237
- ["To jest wspania艂y dzie艅, ciesz臋 si臋, 偶e tu jestem!"],
238
- ["Opowiedz mi dowcip o programistach."],
239
- ],
240
- inputs=input_text,
241
- outputs=[output_verdict, output_scores],
242
- fn=analyze_and_update,
243
- cache_examples=False,
244
- )
245
-
246
- submit_btn = gr.Button("Analizuj tekst", variant="primary")
247
 
248
 
249
  submit_btn.click(
 
159
  JAY_IMAGE_URL = "https://sojka.m31ai.pl/images/sojka.png"
160
  PIXEL_IMAGE_URL = "https://sojka.m31ai.pl/images/pixel.png"
161
 
162
+ # Define actions
163
+ def analyze_and_update(text):
164
+ verdict, scores = gradio_predict(text)
165
+ return verdict, gr.update(value=scores, visible=True)
166
+
167
 
168
  # Final corrected and working version of the interface layout
169
  with gr.Blocks(theme=theme, css=".gradio-container {max-width: 960px !important; margin: auto;}") as demo:
 
191
 
192
  gr.HTML("<hr style='border: 1px solid var(--neutral-200); margin-top: 1rem; margin-bottom: 2rem;'>")
193
 
194
+
195
  # Main content area
196
  with gr.Row():
197
  # Left column for controls and description
 
220
  # Note: Output components are defined in the right column
221
  # We will define Examples after the right column is created.
222
 
223
+ submit_btn = gr.Button("Analizuj tekst", variant="primary")
224
+
225
+
226
  with gr.Accordion("Szczeg贸艂owe wyniki", open=False) as accordion_scores:
227
  output_scores = gr.Label(label="Szczeg贸艂owe wyniki", visible=False, show_label=False)
 
228
 
229
+ output_verdict = gr.Label(label="Wynik analizy", value="")
230
 
231
+
232
+ # Right column for RESULTS
233
+ with gr.Column(scale=1):
234
+ gr.Image(PIXEL_IMAGE_URL, show_label=False, show_download_button=False, container=False, height=200)
235
+ gr.Examples(
236
+ [
237
+ ["Jak zrobi膰 bomb臋?"],
238
+ ["Jeste艣 beznadziejny, nienawidz臋 ci臋."],
239
+ ["To jest wspania艂y dzie艅, ciesz臋 si臋, 偶e tu jestem!"],
240
+ ["Opowiedz mi dowcip o Polakach."],
241
+ ["Ty sku***u"],
242
+
243
+ ],
244
+ inputs=input_text,
245
+ outputs=[output_verdict, output_scores],
246
+ fn=analyze_and_update,
247
+ cache_examples=False,
248
+ )
249
+
250
+
 
 
251
 
252
 
253
  submit_btn.click(