NikhilJoson commited on
Commit
40e429d
Β·
verified Β·
1 Parent(s): 3aae7b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -5,10 +5,10 @@ import random
5
  import os
6
 
7
  # Define the folder containing images
8
- Character_FOLDER = "./Cartoon_Characters"
9
 
10
  # Get the list of celebrity images from the folder
11
- celebs = {os.path.splitext(file)[0]: os.path.join(Character_FOLDER, file) for file in os.listdir(Character_FOLDER)}
12
 
13
  # Define pixel sizes for different levels of clarity
14
  PIXEL_SIZES = [64, 48, 32, 24, 16, 12, 8, 4, 2]
@@ -58,18 +58,18 @@ def clear_more():
58
  # Check the user's guess
59
  def check_guess(user_guess):
60
  if user_guess.strip().lower() == current_name.strip().lower():
61
- return "Correct! πŸŽ‰ You guessed it right!"
62
  else:
63
  return "Incorrect. Keep trying!"
64
 
65
  # Reveal the answer and original image
66
  def reveal_answer():
67
- return current_image, f"The correct answer is: {current_name}!"
68
 
69
  # Create the Gradio interface
70
  with gr.Blocks(theme=gr.themes.Ocean()) as demo:
71
- gr.Markdown("# 🎭 Guess the Chartoon Character Game!")
72
- gr.Markdown("Can you identify the Cartoon Characters as the image becomes clearer?")
73
 
74
  with gr.Row():
75
  pixelated_image = gr.Image(type="pil", label="Pixelated Image")
@@ -80,11 +80,11 @@ with gr.Blocks(theme=gr.themes.Ocean()) as demo:
80
  start_button = gr.Button("Start Game", variant='huggingface')
81
  clear_button = gr.Button("Clear More", variant='secondary')
82
  guess_button = gr.Button("Submit Guess", variant='primary')
83
- reveal_button = gr.Button("Reveal Answer", variant='stop')
84
 
85
  start_button.click(start_game, inputs=[], outputs=[pixelated_image, result])
86
  clear_button.click(clear_more, inputs=[], outputs=[pixelated_image, result])
87
  guess_button.click(check_guess, inputs=answer_input, outputs=result)
88
  reveal_button.click(reveal_answer, inputs=[], outputs=[pixelated_image, result])
89
 
90
- demo.launch(debug=True, show_error=True)
 
5
  import os
6
 
7
  # Define the folder containing images
8
+ CELEB_FOLDER = "./Celebs"
9
 
10
  # Get the list of celebrity images from the folder
11
+ celebs = {os.path.splitext(file)[0]: os.path.join(CELEB_FOLDER, file) for file in os.listdir(CELEB_FOLDER)}
12
 
13
  # Define pixel sizes for different levels of clarity
14
  PIXEL_SIZES = [64, 48, 32, 24, 16, 12, 8, 4, 2]
 
58
  # Check the user's guess
59
  def check_guess(user_guess):
60
  if user_guess.strip().lower() == current_name.strip().lower():
61
+ return f"Correct! πŸŽ‰ You guessed it right! This character's name is {current_name}"
62
  else:
63
  return "Incorrect. Keep trying!"
64
 
65
  # Reveal the answer and original image
66
  def reveal_answer():
67
+ return current_image, f"The correct answer is: {current_name}! πŸŽ‰"
68
 
69
  # Create the Gradio interface
70
  with gr.Blocks(theme=gr.themes.Ocean()) as demo:
71
+ gr.Markdown("# 🎭 Guess the Celebrity Game!")
72
+ gr.Markdown("Can you identify the celebrity as the image becomes clearer?")
73
 
74
  with gr.Row():
75
  pixelated_image = gr.Image(type="pil", label="Pixelated Image")
 
80
  start_button = gr.Button("Start Game", variant='huggingface')
81
  clear_button = gr.Button("Clear More", variant='secondary')
82
  guess_button = gr.Button("Submit Guess", variant='primary')
83
+ reveal_button = gr.Button("Reveal Answer", variant='success')
84
 
85
  start_button.click(start_game, inputs=[], outputs=[pixelated_image, result])
86
  clear_button.click(clear_more, inputs=[], outputs=[pixelated_image, result])
87
  guess_button.click(check_guess, inputs=answer_input, outputs=result)
88
  reveal_button.click(reveal_answer, inputs=[], outputs=[pixelated_image, result])
89
 
90
+ demo.launch(debug=True, show_error=True)