sadickam commited on
Commit
622409c
·
verified ·
1 Parent(s): fa37060

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -127,9 +127,18 @@ def predict_sdg(text):
127
  # Return result
128
  return {top_prediction[0]: round(top_prediction[1], 3)}, fig
129
 
 
 
 
 
 
 
 
 
 
130
  # Create Gradio interface for single text
131
  iface2 = gr.Interface(fn=predict_sdg,
132
- inputs=gr.Textbox(lines=7, label="Paste or type text here"),
133
  outputs=[gr.Label(label="Top SDG Predicted", show_label=True), gr.Plot(label="Likelihood of all SDG", show_label=True)],
134
  title="Single Text Prediction")
135
 
 
127
  # Return result
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,
141
+ inputs=single_text,
142
  outputs=[gr.Label(label="Top SDG Predicted", show_label=True), gr.Plot(label="Likelihood of all SDG", show_label=True)],
143
  title="Single Text Prediction")
144