Update app.py
Browse files
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 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
return new_string
|
35 |
|
36 |
-
demo = gr.Interface(slowly_reverse, gr.Text(), gr.Text())
|
37 |
|
38 |
-
|
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()
|