VictorSanh commited on
Commit
1154e3f
β€’
1 Parent(s): 0ea8e96

error handling

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -127,7 +127,7 @@ def model_inference(
127
  image,
128
  ):
129
  if image is None:
130
- raise ValueError("`image` is None. It should be a PIL image.")
131
 
132
  # return "A"
133
  inputs = PROCESSOR.tokenizer(
@@ -229,7 +229,7 @@ with gr.Blocks(title="Beat the AI", theme=gr.themes.Base(), css=css) as demo:
229
 
230
  def result_string(model_pred, user_pred, solution):
231
  if solution == "":
232
- return "Load a new sample first! πŸ‘†"
233
 
234
  solution_letter = chr(ord('A') + int(solution))
235
  solution_string = f"The correct answer is {solution_letter}."
 
127
  image,
128
  ):
129
  if image is None:
130
+ raise gr.Error("Load a new sample first!")
131
 
132
  # return "A"
133
  inputs = PROCESSOR.tokenizer(
 
229
 
230
  def result_string(model_pred, user_pred, solution):
231
  if solution == "":
232
+ return ""
233
 
234
  solution_letter = chr(ord('A') + int(solution))
235
  solution_string = f"The correct answer is {solution_letter}."