Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
counter = -1
|
| 5 |
+
COLORS = [(255, 0, 0), (0, 255, 0), (0, 0, 255)]
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def fn():
|
| 9 |
+
global counter
|
| 10 |
+
counter = (counter + 1) % 3
|
| 11 |
+
return np.full((300, 300, 3), COLORS[counter], dtype=np.uint8)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
btn = gr.Button()
|
| 16 |
+
out = gr.Image()
|
| 17 |
+
gr.DeepLinkButton()
|
| 18 |
+
btn.click(fn=fn, outputs=out)
|
| 19 |
+
demo.launch()
|