Vanyadoing commited on
Commit
5c556c9
·
verified ·
1 Parent(s): 9fb2e7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -4
app.py CHANGED
@@ -1,7 +1,32 @@
1
  import gradio as gr
2
- def invert(img):
3
- return 255 - img
4
- iface = gr.Interface(fn=invert, inputs=gr.Image(type="numpy"), outputs=gr.Image())
5
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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