Update app.py
Browse files
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 |
-
|
| 132 |
-
if
|
| 133 |
-
|
| 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,
|