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

some fixes

Browse files
Files changed (1) hide show
  1. app.py +14 -15
app.py CHANGED
@@ -157,19 +157,13 @@ def model_inference(
157
  return generated_text[-1]
158
 
159
 
160
- model_prediction = gr.TextArea(
161
  label="AI's guess",
162
  visible=True,
163
- lines=1,
164
- max_lines=1,
165
- interactive=False,
166
  )
167
- user_prediction = gr.TextArea(
168
  label="Your guess",
169
  visible=True,
170
- lines=1,
171
- max_lines=1,
172
- interactive=False,
173
  )
174
  result = gr.TextArea(
175
  label="Win or lose?",
@@ -191,11 +185,13 @@ h1{display: flex;align-items: center;justify-content: center;gap: .25em}
191
  with gr.Blocks(title="Beat the AI", theme=gr.themes.Base(), css=css) as demo:
192
  gr.Markdown(
193
  """
194
- # Will you beat the AI at these RAVEN puzzles?
195
 
196
  *This demo features an early fine-tuned version of our forth-coming Idefics2 model. The model was specifically fine-tuned on the [RAVEN](https://huggingface.co/datasets/HuggingFaceM4/RAVEN) dataset and reached 91% accuracy on the validation set.*
197
 
198
- To get started, load a new puzzle.
 
 
199
  """
200
  )
201
  load_new_sample = gr.Button(value="Load a new puzzle")
@@ -232,11 +228,14 @@ with gr.Blocks(title="Beat the AI", theme=gr.themes.Base(), css=css) as demo:
232
  result.render()
233
 
234
  def result_string(model_pred, user_pred, solution):
 
 
 
235
  solution_letter = chr(ord('A') + int(solution))
236
  solution_string = f"The correct answer is {solution_letter}."
237
-
238
  win_or_loose = "πŸ₯‡" if user_pred == solution_letter else "πŸ™ˆ"
239
-
240
  if user_pred == solution_letter and model_pred == solution_letter:
241
  comparison_string = "Both you and the AI got it correctly!"
242
  elif user_pred == solution_letter and model_pred != solution_letter:
@@ -245,9 +244,9 @@ with gr.Blocks(title="Beat the AI", theme=gr.themes.Base(), css=css) as demo:
245
  comparison_string = "Both you and the AI got it wrong!"
246
  elif user_pred != solution_letter and model_pred == solution_letter:
247
  comparison_string = "The AI beat you!"
248
-
249
- return f"{win_or_loose} {comparison_string}\n{solution_string}"
250
-
251
  load_new_sample.click(
252
  fn=load_sample,
253
  inputs=[],
 
157
  return generated_text[-1]
158
 
159
 
160
+ model_prediction = gr.Label(
161
  label="AI's guess",
162
  visible=True,
 
 
 
163
  )
164
+ user_prediction = gr.Label(
165
  label="Your guess",
166
  visible=True,
 
 
 
167
  )
168
  result = gr.TextArea(
169
  label="Win or lose?",
 
185
  with gr.Blocks(title="Beat the AI", theme=gr.themes.Base(), css=css) as demo:
186
  gr.Markdown(
187
  """
188
+ # Can you beat the AI at RAVEN puzzles?
189
 
190
  *This demo features an early fine-tuned version of our forth-coming Idefics2 model. The model was specifically fine-tuned on the [RAVEN](https://huggingface.co/datasets/HuggingFaceM4/RAVEN) dataset and reached 91% accuracy on the validation set.*
191
 
192
+ RAVE Progressive Matrices are abstract visual reasoning puzzles. The panels describe logical sequences of shapes and colors (row by row). One is asked to find the option that completes the 3rd sequence following the same logic described by the first two sequences. We recommend looking at the images on a full screen with enough brightness given that some options differ by small differences in sizes and nuances of colors.
193
+
194
+ To get started, load a new puzzle. 🧠
195
  """
196
  )
197
  load_new_sample = gr.Button(value="Load a new puzzle")
 
228
  result.render()
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}."
236
+
237
  win_or_loose = "πŸ₯‡" if user_pred == solution_letter else "πŸ™ˆ"
238
+
239
  if user_pred == solution_letter and model_pred == solution_letter:
240
  comparison_string = "Both you and the AI got it correctly!"
241
  elif user_pred == solution_letter and model_pred != solution_letter:
 
244
  comparison_string = "Both you and the AI got it wrong!"
245
  elif user_pred != solution_letter and model_pred == solution_letter:
246
  comparison_string = "The AI beat you!"
247
+
248
+ return f"{win_or_loose} {comparison_string} {solution_string}"
249
+
250
  load_new_sample.click(
251
  fn=load_sample,
252
  inputs=[],