NikhilJoson commited on
Commit
178d7f7
·
verified ·
1 Parent(s): 56c75b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -42,27 +42,36 @@ def clear_more():
42
  pixelated_image = pixelate(current_image, current_pixel_size)
43
  return pixelated_image, "Getting clearer! Keep guessing!"
44
 
 
 
 
 
 
 
 
45
  # Reveal the answer
46
  def reveal_answer():
47
  return f"The correct answer is: {current_name}!"
48
 
49
  # Create the Gradio interface
50
- with gr.Blocks(theme=gr.themes.Ocean()) as demo:
51
  gr.Markdown("# 🎭 Guess the Celebrity Game!")
52
  gr.Markdown("Can you identify the celebrity as the image becomes clearer?")
53
 
54
  with gr.Row():
55
  pixelated_image = gr.Image(type="pil", label="Pixelated Image")
56
- answer = gr.Textbox(label="Your Guess", placeholder="Type your guess here...")
57
  result = gr.Label(label="Game Status")
58
 
59
  with gr.Row():
60
- start_button = gr.Button("Start Game", variant='primary')
61
- clear_button = gr.Button("Clear More", variant='secondary')
62
- reveal_button = gr.Button("Reveal Answer", variant='success')
 
63
 
64
  start_button.click(start_game, inputs=[], outputs=[pixelated_image, result])
65
  clear_button.click(clear_more, inputs=[], outputs=[pixelated_image, result])
 
66
  reveal_button.click(reveal_answer, inputs=[], outputs=result)
67
 
68
  demo.launch(debug=True, show_error=True)
 
42
  pixelated_image = pixelate(current_image, current_pixel_size)
43
  return pixelated_image, "Getting clearer! Keep guessing!"
44
 
45
+ # Check the user's guess
46
+ def check_guess(user_guess):
47
+ if user_guess.strip().lower() == current_name.strip().lower():
48
+ return "Correct! 🎉 You guessed it right!"
49
+ else:
50
+ return "Incorrect. Keep trying!"
51
+
52
  # Reveal the answer
53
  def reveal_answer():
54
  return f"The correct answer is: {current_name}!"
55
 
56
  # Create the Gradio interface
57
+ with gr.Blocks() as demo:
58
  gr.Markdown("# 🎭 Guess the Celebrity Game!")
59
  gr.Markdown("Can you identify the celebrity as the image becomes clearer?")
60
 
61
  with gr.Row():
62
  pixelated_image = gr.Image(type="pil", label="Pixelated Image")
63
+ answer_input = gr.Textbox(label="Your Guess", placeholder="Type your guess here...")
64
  result = gr.Label(label="Game Status")
65
 
66
  with gr.Row():
67
+ start_button = gr.Button("Start Game")
68
+ clear_button = gr.Button("Clear More")
69
+ guess_button = gr.Button("Submit Guess")
70
+ reveal_button = gr.Button("Reveal Answer")
71
 
72
  start_button.click(start_game, inputs=[], outputs=[pixelated_image, result])
73
  clear_button.click(clear_more, inputs=[], outputs=[pixelated_image, result])
74
+ guess_button.click(check_guess, inputs=answer_input, outputs=result)
75
  reveal_button.click(reveal_answer, inputs=[], outputs=result)
76
 
77
  demo.launch(debug=True, show_error=True)