ysharma HF Staff commited on
Commit
8c9c7c7
·
1 Parent(s): a6ec80d
Files changed (1) hide show
  1. app.py +41 -6
app.py CHANGED
@@ -1,10 +1,45 @@
1
  import gradio as gr
2
  from PIL import Image
3
 
4
- demo = gr.Blocks.load(name="spaces/freddyaboulton/blocks_inputs")
5
- assert demo("Foo", "bar") == "Foo bar"
6
 
7
- original = Image.open("./c4.jpg")
8
- output_img_path = demo("./c4.jpg", fn_index=1)
9
- output = Image.open(output_img_path)
10
- assert original.size == output.size
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from PIL import Image
3
 
4
+ demo_inf = gr.Blocks.load(name="spaces/freddyaboulton/blocks_inputs")
5
+ #assert demo_inf("Foo", "bar") == "Foo bar"
6
 
7
+ def txt_fun(txt1, txt2):
8
+ return demo_inf(txt1, txt2)
9
+
10
+ #original = Image.open("./c4.jpg")
11
+ #output_img_path = demo_inf("./c4.jpg", fn_index=1)
12
+ #output = Image.open(output_img_path)
13
+ #assert original.size == output.size
14
+
15
+ def img_fun(img_in):
16
+ return demo_inf(img_in, fn_index=1)
17
+
18
+ demo = gr.Blocks()
19
+
20
+ with demo:
21
+ gr.Markdown("<h1><center>Testing</center></h1>")
22
+ gr.Markdown(
23
+ """Testing Blocks Inference"""
24
+ )
25
+ with gr.Row():
26
+ in_image = gr.Image()
27
+ out_image = gr.Image()
28
+
29
+ in_text1 = gr.Textbox()
30
+ in_text2 = gr.Textbox()
31
+ out_text = gr.Textbox()
32
+
33
+ #example_prompt = gr.Radio( ["Instruction: Given an input question, respond with syntactically correct PostgreSQL\nInput: how many users signed up in the past month?\nPostgreSQL query: "], label= "Choose a sample Prompt")
34
+
35
+ #input_word = gr.Textbox(placeholder="Enter a word here to generate text ...")
36
+ #output_image = gr.Image(type="filepath", shape=(256,256))
37
+
38
+ b1 = gr.Button("Image Button")
39
+ b2 = gr.Button("Text Button")
40
+
41
+ b1.click(img_fun,inputs=in_image, outputs=out_image)
42
+ b2.click(txt_fun, inputs=[in_text1, in_text2], out_text)
43
+ #examples=examples
44
+
45
+ demo.launch(enable_queue=True, debug=True)