update draw codes
Browse files
app.py
CHANGED
@@ -1,5 +1,35 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
|
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import random
|
3 |
+
from PIL import Image
|
4 |
|
5 |
+
# Define the initial options
|
6 |
+
options = ["pink"] * 15 + ["blue"] * 10
|
7 |
|
8 |
+
|
9 |
+
def spin_roulette():
|
10 |
+
# Randomly select an option
|
11 |
+
selected_option = random.choice(options)
|
12 |
+
|
13 |
+
# Remove the selected option from the list
|
14 |
+
options.remove(selected_option)
|
15 |
+
|
16 |
+
return selected_option
|
17 |
+
|
18 |
+
|
19 |
+
def draw():
|
20 |
+
for _ in range(25):
|
21 |
+
if options:
|
22 |
+
option = spin_roulette()
|
23 |
+
if option == "pink":
|
24 |
+
pink = Image.open("images/pink.png")
|
25 |
+
return pink
|
26 |
+
else:
|
27 |
+
blue = Image.open("images/blue.png")
|
28 |
+
return blue
|
29 |
+
|
30 |
+
|
31 |
+
with gr.Blocks() as demo:
|
32 |
+
result = draw()
|
33 |
+
draw_btn = gr.Button("Draw")
|
34 |
+
draw_btn.click(fn=draw, inputs="", outputs=result)
|
35 |
demo.launch()
|