Spaces:
Running
Running
BraUndress
commited on
Commit
•
2520a50
1
Parent(s):
43a0f6b
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
-
import numpy as np
|
3 |
-
import requests
|
4 |
import imageio
|
5 |
-
from PIL import Image
|
6 |
-
from io import BytesIO
|
7 |
|
8 |
def dummy(img):
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
# 图片的 URL 地址
|
13 |
-
image_url = "https://api.telegram.org/file/bot6584991592:AAGNv881SaUQd9zmDs2OzQEpKD7nrMkzMpk/photos/file_3648.jpg"
|
14 |
-
|
15 |
-
# 使用 requests 获取图片数据
|
16 |
-
response = requests.get(image_url)
|
17 |
-
image = Image.open(BytesIO(response.content))
|
18 |
-
default_image = np.array(image)
|
19 |
|
20 |
with gr.Blocks() as demo:
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
btn.click(dummy, img, [img1, img2])
|
29 |
|
30 |
-
demo.launch(debug=True)
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
import imageio
|
|
|
|
|
3 |
|
4 |
def dummy(img):
|
5 |
+
imageio.imwrite("output_image.png", img["mask"])
|
6 |
+
return img["image"], img["mask"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
with gr.Blocks() as demo:
|
9 |
+
with gr.Row():
|
10 |
+
img = gr.Image(tool="sketch", label="base image", show_label=True)
|
11 |
+
with gr.Row():
|
12 |
+
img1 = gr.Image()
|
13 |
+
img2 = gr.Image(label="mask image", show_label=True)
|
14 |
+
btn = gr.Button()
|
15 |
+
btn.click(dummy, img, [img1, img2])
|
|
|
16 |
|
17 |
+
demo.launch(debug=True)
|