Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -38,6 +38,9 @@ best_guess = None
|
|
38 |
def respond(message, chat_history, label_value, image_value):
|
39 |
global has_started, best_guess
|
40 |
|
|
|
|
|
|
|
41 |
logits, is_better = clip_chat.answer(message)
|
42 |
bot_message = logit2sentence(logits, clip_chat.goal)
|
43 |
|
@@ -48,19 +51,15 @@ def respond(message, chat_history, label_value, image_value):
|
|
48 |
best_guess = "YOU WIN! (Press \"Reset\" to play again)"
|
49 |
image_value = clip_chat.image_org
|
50 |
else:
|
51 |
-
if
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
bot_message += "You did better than the last one."
|
58 |
|
59 |
label_value = best_guess
|
60 |
|
61 |
-
if not has_started:
|
62 |
-
has_started = True
|
63 |
-
|
64 |
chat_history.append((message, bot_message))
|
65 |
return "", chat_history, label_value, image_value
|
66 |
|
@@ -79,6 +78,7 @@ with gr.Blocks() as demo:
|
|
79 |
chatbot = gr.Chatbot()
|
80 |
msg = gr.Textbox()
|
81 |
slider = gr.inputs.Slider(minimum=18, maximum=27, default=21, label="Difficulty (18 - Easy, 27 - Expert)")
|
|
|
82 |
with gr.Column():
|
83 |
label = gr.Label("This is a \"Guess the Image\" game. I'm thinking of a picture and you have to guess using the chat above.")
|
84 |
image_output = gr.outputs.Image(type="pil")
|
|
|
38 |
def respond(message, chat_history, label_value, image_value):
|
39 |
global has_started, best_guess
|
40 |
|
41 |
+
if not has_started:
|
42 |
+
has_started = True
|
43 |
+
|
44 |
logits, is_better = clip_chat.answer(message)
|
45 |
bot_message = logit2sentence(logits, clip_chat.goal)
|
46 |
|
|
|
51 |
best_guess = "YOU WIN! (Press \"Reset\" to play again)"
|
52 |
image_value = clip_chat.image_org
|
53 |
else:
|
54 |
+
if is_better == -1:
|
55 |
+
bot_message += ""
|
56 |
+
elif is_better == 0:
|
57 |
+
bot_message += "You did worse than the last one."
|
58 |
+
elif is_better == 1 or is_better == 3:
|
59 |
+
bot_message += "You did better than the last one."
|
|
|
60 |
|
61 |
label_value = best_guess
|
62 |
|
|
|
|
|
|
|
63 |
chat_history.append((message, bot_message))
|
64 |
return "", chat_history, label_value, image_value
|
65 |
|
|
|
78 |
chatbot = gr.Chatbot()
|
79 |
msg = gr.Textbox()
|
80 |
slider = gr.inputs.Slider(minimum=18, maximum=27, default=21, label="Difficulty (18 - Easy, 27 - Expert)")
|
81 |
+
description = gr.Markdown("Start writing in the textbox above. The percentage in the label in the right shows how close you are to the answer.\n\nIMPORTANT!\n- If you feel you are not getting any closer to the answer, try a different approach completly! (maybe a 60% of animal is a 80% a vehicle).\n- Adding \"A photo of ... outdoors/indoors\" might get better results.")
|
82 |
with gr.Column():
|
83 |
label = gr.Label("This is a \"Guess the Image\" game. I'm thinking of a picture and you have to guess using the chat above.")
|
84 |
image_output = gr.outputs.Image(type="pil")
|