linkdom commited on
Commit
faa4149
1 Parent(s): 882a8f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -34
app.py CHANGED
@@ -1,41 +1,20 @@
1
- # import gradio as gr
2
- # import numpy as np
3
-
4
-
5
- # def gennerateImage(input_array,eps):
6
- # eps = eps / 100
7
- # mask = np.random.random(input_array.shape)
8
- # mask = mask * 2 - 1 # 将mask的值转换为-1到1之间
9
- # noise_img = (input_array * (1 + mask * eps)).astype(np.uint8) % 255
10
- # return noise_img
11
-
12
- # demo = gr.Interface(
13
- # gennerateImage,
14
- # inputs=[
15
- # gr.Image(),
16
- # gr.Slider(1, 10, 3)
17
- # ],
18
- # outputs="image"
19
- # )
20
-
21
- # demo.launch(share=True)
22
-
23
  import gradio as gr
 
24
  import time
25
 
26
- def slowly_reverse(word, progress=gr.Progress()):
27
- progress(0, desc="Starting")
28
- time.sleep(1)
29
- progress(0.05)
30
- new_string = ""
31
- for letter in progress.tqdm(word, desc="Reversing"):
32
- time.sleep(0.25)
33
- new_string = letter + new_string
34
- return new_string
35
 
36
- demo = gr.Interface(slowly_reverse, gr.Text(), gr.Text())
37
 
38
- if __name__ == "__main__":
39
- demo.queue(concurrency_count=10).launch(share=True)
40
 
 
 
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import numpy as np
3
  import time
4
 
5
+ # define core fn, which returns a generator {steps} times before returning the image
6
+ def fake_diffusion(steps):
7
+ for _ in range(steps):
8
+ time.sleep(1)
9
+ image = np.random.random((600, 600, 3))
10
+ yield image
11
+ image = "https://gradio-builds.s3.amazonaws.com/diffusion_image/cute_dog.jpg"
12
+ yield image
 
13
 
 
14
 
15
+ demo = gr.Interface(fake_diffusion, inputs=gr.Slider(1, 10, 3), outputs="image")
 
16
 
17
+ # define queue - required for generators
18
+ demo.queue()
19
 
20
+ demo.launch()