sadickam commited on
Commit
dc5f90b
·
verified ·
1 Parent(s): ca74a42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -128,13 +128,10 @@ def predict_sdg(text):
128
  return {top_prediction[0]: round(top_prediction[1], 3)}, fig
129
 
130
  # Define input and warning
131
- single_text = gr.Textbox(lines=7, label="Paste or type text here")
132
- if single_text != '':
133
- single_text=single_text
134
-
135
- elif single_text == "":
136
- single_text=gr.Warning('The model needs some text to return a prediction')
137
-
138
 
139
  # Create Gradio interface for single text
140
  iface2 = gr.Interface(fn=predict_sdg,
 
128
  return {top_prediction[0]: round(top_prediction[1], 3)}, fig
129
 
130
  # Define input and warning
131
+ try:
132
+ single_text = gr.Textbox(lines=7, label="Paste or type text here") if gr.Textbox(lines=7, label="Paste or type text here") != ''
133
+ except:
134
+ single_text = gr.Warning('This model need some text to return a prediction') if gr.Textbox(lines=7, label="Paste or type text here") == ''
 
 
 
135
 
136
  # Create Gradio interface for single text
137
  iface2 = gr.Interface(fn=predict_sdg,