Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
|
4 |
+
def grayscale_pipeline(prompt): # keep signature the same at first!
|
5 |
+
# ignore prompt; just use a demo image or make a blank
|
6 |
+
img = Image.new('RGB', (256, 256), color='white')
|
7 |
+
gray = img.convert("L")
|
8 |
+
return gray, 42 # image, seed
|
9 |
+
|
10 |
+
with gr.Blocks() as demo:
|
11 |
+
with gr.Column():
|
12 |
+
gr.Markdown(" # Grayscale Test Template")
|
13 |
+
|
14 |
+
with gr.Row():
|
15 |
+
prompt = gr.Text(label="Prompt")
|
16 |
+
run_button = gr.Button("Run")
|
17 |
+
|
18 |
+
result = gr.Image(label="Result")
|
19 |
+
|
20 |
+
gr.Examples(examples=["any"], inputs=[prompt])
|
21 |
+
|
22 |
+
gr.on(
|
23 |
+
triggers=[run_button.click, prompt.submit],
|
24 |
+
fn=grayscale_pipeline,
|
25 |
+
inputs=[prompt],
|
26 |
+
outputs=[result, gr.Number(label="Seed")], # keep outputs shape
|
27 |
+
)
|
28 |
+
|
29 |
+
if __name__ == "__main__":
|
30 |
+
demo.launch()
|
31 |
|
32 |
|