NikhilJoson commited on
Commit
952541f
·
verified ·
1 Parent(s): e9f8b4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -41,22 +41,22 @@ def clear_and_start(prev_size=256):
41
  # Open and pixelate the image
42
  img = Image.open(image_path)
43
  result_img = pixelate(img, current_pixel_size)
44
- return result_img, celebrity
45
 
46
- def next_image(prev_size):
47
  """
48
  Moves to the next celebrity and pixelates the image.
49
  """
50
  global current_index, current_pixel_size
51
  current_index = (current_index + 1) % len(celeb_list) # Loop through the list
52
- current_pixel_size = prev_size
53
  celebrity = celeb_list[current_index]
54
  image_path = celeb_folder[celebrity]
55
 
56
  # Open and pixelate the image
57
  img = Image.open(image_path)
58
  result_img = pixelate(img, current_pixel_size)
59
- return result_img, celebrity
60
 
61
  def progressive_clear(pixel_size):
62
  """
@@ -70,11 +70,11 @@ def progressive_clear(pixel_size):
70
  # Open and pixelate the image
71
  img = Image.open(image_path)
72
  result_img = pixelate(img, current_pixel_size)
73
- return result_img, celebrity
74
 
75
  # Gradio App Layout
76
  MARKDOWN = "## Guess the Celebrity before the Image Clears Up!"
77
- with gr.Blocks() as demo:
78
  gr.Markdown(MARKDOWN)
79
 
80
  with gr.Row():
@@ -89,8 +89,8 @@ with gr.Blocks() as demo:
89
  Next_button = gr.Button(value='Next Image', variant='success')
90
 
91
  # Define button actions
92
- Start_button.click(fn=clear_and_start, inputs=[], outputs=[pixelated_image, answer])
93
- Clear_button.click(fn=progressive_clear, inputs=[gr.Number(value=current_pixel_size)], outputs=[pixelated_image, answer])
94
- Next_button.click(fn=next_image, inputs=[gr.Number(value=current_pixel_size)], outputs=[pixelated_image, answer])
95
 
96
- demo.launch(debug=True, show_error=True)
 
41
  # Open and pixelate the image
42
  img = Image.open(image_path)
43
  result_img = pixelate(img, current_pixel_size)
44
+ return result_img, celebrity, current_pixel_size
45
 
46
+ def next_image(pixel_size):
47
  """
48
  Moves to the next celebrity and pixelates the image.
49
  """
50
  global current_index, current_pixel_size
51
  current_index = (current_index + 1) % len(celeb_list) # Loop through the list
52
+ current_pixel_size = pixel_size
53
  celebrity = celeb_list[current_index]
54
  image_path = celeb_folder[celebrity]
55
 
56
  # Open and pixelate the image
57
  img = Image.open(image_path)
58
  result_img = pixelate(img, current_pixel_size)
59
+ return result_img, celebrity, current_pixel_size
60
 
61
  def progressive_clear(pixel_size):
62
  """
 
70
  # Open and pixelate the image
71
  img = Image.open(image_path)
72
  result_img = pixelate(img, current_pixel_size)
73
+ return result_img, celebrity, current_pixel_size
74
 
75
  # Gradio App Layout
76
  MARKDOWN = "## Guess the Celebrity before the Image Clears Up!"
77
+ with gr.Blocks(theme=gr.themes.Ocean()) as demo:
78
  gr.Markdown(MARKDOWN)
79
 
80
  with gr.Row():
 
89
  Next_button = gr.Button(value='Next Image', variant='success')
90
 
91
  # Define button actions
92
+ Start_button.click(fn=clear_and_start, inputs=[], outputs=[pixelated_image, answer, gr.State(current_pixel_size)])
93
+ Clear_button.click(fn=progressive_clear, inputs=[gr.State(current_pixel_size)], outputs=[pixelated_image, answer, gr.State(current_pixel_size)])
94
+ Next_button.click(fn=next_image, inputs=[gr.State(current_pixel_size)], outputs=[pixelated_image, answer, gr.State(current_pixel_size)])
95
 
96
+ demo.launch(debug=True, show_error=True)