Spaces:
Running
Running
"O Fascinante Mundo dos Óculos: Estilo, Proteção e Tendências"
#2
by
EstrelaBrilhante
- opened
- app.py +11 -11
- assets/banner/banner.png +2 -2
- requirements.txt +1 -5
- src/util.py +1 -4
app.py
CHANGED
@@ -37,16 +37,16 @@ for idx, name in enumerate(files):
|
|
37 |
ep = "assets/examples"
|
38 |
# Layout, Style, Color, Subject, Prompt,Strict Layout Edge,Layout Content Scale, Automatic Image Matting
|
39 |
image_examples = [
|
40 |
-
[0, f"{ep}/00_layout.png", f"{ep}/empty.png", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.,
|
41 |
-
[1, f"{ep}/01_layout.png", f"{ep}/empty.png", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.8,
|
42 |
-
[2, f"{ep}/empty.png", f"{ep}/02_style.png", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.8,
|
43 |
-
[3, f"{ep}/empty.png", f"{ep}/03_style.png", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.8,
|
44 |
-
[4, f"{ep}/empty.png", f"{ep}/empty.png", f"{ep}/04_color.png", f"{ep}/empty.png", "A moose, Merry Christmas", True, 0.8,
|
45 |
[5, f"{ep}/empty.png", f"{ep}/empty.png", f"{ep}/05_color.png", f"{ep}/empty.png", "A photo about cherry blossom",
|
46 |
-
True, 0.8,
|
47 |
-
[6, f"{ep}/06_layout.png", f"{ep}/06_style.jpeg", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.8,
|
48 |
-
[7, f"{ep}/07_layout.jpeg", f"{ep}/07_style.jpeg", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.8,
|
49 |
-
[8, f"{ep}/empty.png", f"{ep}/08_style.png", f"{ep}/08_color.jpeg", f"{ep}/empty.png", "", True, 0.8,
|
50 |
[9, f"{ep}/empty.png", f"{ep}/09_style.png", f"{ep}/empty.png", f"{ep}/base_image1.jpeg", "", True, 0.8, True],
|
51 |
[10, f"{ep}/10_layout.png", f"{ep}/10_style.png", f"{ep}/empty.png", f"{ep}/base_image2.png", "", True, 0.8, False],
|
52 |
[11, f"{ep}/11_layout.png", f"{ep}/empty.png", f"{ep}/empty.png", f"{ep}/base_image4.png", "", False, 0.8, False],
|
@@ -243,7 +243,7 @@ if __name__ == "__main__":
|
|
243 |
gr.Markdown("""
|
244 |
- ⭐️ <b>step1:</b> (Optional) Upload or select a set of images from the examples for the "Layout", "Style", and "Color" reference. Mix and match freely, no need to select all.
|
245 |
- ⭐️ <b>step2:</b> (Optional) Use brush to erase areas in the layout, style, and color reference images (if present) that you do not want transferred.
|
246 |
-
- ⭐️ <b>step3:</b> (Optional) Upload an
|
247 |
- ⭐️ <b>step4:</b> Click "Run" to start the generation process.
|
248 |
- ⭐️ <b>step5:</b> (Optional) Additionally, prompt input is supported, as well as control over advanced parameters such as layout edge consistency and conditional weights. Feel free to try these features.
|
249 |
""")
|
@@ -305,7 +305,7 @@ if __name__ == "__main__":
|
|
305 |
type="pil", image_mode="RGBA", tool="editor")
|
306 |
pil_base_image_rgba_mirror = gr.Image(label="Subject", image_mode="RGBA", visible=False)
|
307 |
with gr.Box():
|
308 |
-
preprocess_base_image = gr.Checkbox(label="Automatic Image Matting"
|
309 |
pil_fg_mask = gr.Image(interactive=False, type="pil", image_mode="L", visible=False)
|
310 |
run_button = gr.Button("Run", elem_id="btn")
|
311 |
with gr.Accordion("", open=True, elem_id="accordion1"):
|
|
|
37 |
ep = "assets/examples"
|
38 |
# Layout, Style, Color, Subject, Prompt,Strict Layout Edge,Layout Content Scale, Automatic Image Matting
|
39 |
image_examples = [
|
40 |
+
[0, f"{ep}/00_layout.png", f"{ep}/empty.png", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0., False],
|
41 |
+
[1, f"{ep}/01_layout.png", f"{ep}/empty.png", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.8, False],
|
42 |
+
[2, f"{ep}/empty.png", f"{ep}/02_style.png", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.8, False],
|
43 |
+
[3, f"{ep}/empty.png", f"{ep}/03_style.png", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.8, False],
|
44 |
+
[4, f"{ep}/empty.png", f"{ep}/empty.png", f"{ep}/04_color.png", f"{ep}/empty.png", "A moose, Merry Christmas", True, 0.8, False],
|
45 |
[5, f"{ep}/empty.png", f"{ep}/empty.png", f"{ep}/05_color.png", f"{ep}/empty.png", "A photo about cherry blossom",
|
46 |
+
True, 0.8, False],
|
47 |
+
[6, f"{ep}/06_layout.png", f"{ep}/06_style.jpeg", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.8, False],
|
48 |
+
[7, f"{ep}/07_layout.jpeg", f"{ep}/07_style.jpeg", f"{ep}/empty.png", f"{ep}/empty.png", "", True, 0.8, False],
|
49 |
+
[8, f"{ep}/empty.png", f"{ep}/08_style.png", f"{ep}/08_color.jpeg", f"{ep}/empty.png", "", True, 0.8, False],
|
50 |
[9, f"{ep}/empty.png", f"{ep}/09_style.png", f"{ep}/empty.png", f"{ep}/base_image1.jpeg", "", True, 0.8, True],
|
51 |
[10, f"{ep}/10_layout.png", f"{ep}/10_style.png", f"{ep}/empty.png", f"{ep}/base_image2.png", "", True, 0.8, False],
|
52 |
[11, f"{ep}/11_layout.png", f"{ep}/empty.png", f"{ep}/empty.png", f"{ep}/base_image4.png", "", False, 0.8, False],
|
|
|
243 |
gr.Markdown("""
|
244 |
- ⭐️ <b>step1:</b> (Optional) Upload or select a set of images from the examples for the "Layout", "Style", and "Color" reference. Mix and match freely, no need to select all.
|
245 |
- ⭐️ <b>step2:</b> (Optional) Use brush to erase areas in the layout, style, and color reference images (if present) that you do not want transferred.
|
246 |
+
- ⭐️ <b>step3:</b> (Optional) Upload an image with the subject you wish to preserve at the pixel level to the "Subject" component, with a transparent channel required (or upload a regular RGB image and select automatic image matting, which will automatically segment the subject area for you).
|
247 |
- ⭐️ <b>step4:</b> Click "Run" to start the generation process.
|
248 |
- ⭐️ <b>step5:</b> (Optional) Additionally, prompt input is supported, as well as control over advanced parameters such as layout edge consistency and conditional weights. Feel free to try these features.
|
249 |
""")
|
|
|
305 |
type="pil", image_mode="RGBA", tool="editor")
|
306 |
pil_base_image_rgba_mirror = gr.Image(label="Subject", image_mode="RGBA", visible=False)
|
307 |
with gr.Box():
|
308 |
+
preprocess_base_image = gr.Checkbox(label="Automatic Image Matting")
|
309 |
pil_fg_mask = gr.Image(interactive=False, type="pil", image_mode="L", visible=False)
|
310 |
run_button = gr.Button("Run", elem_id="btn")
|
311 |
with gr.Accordion("", open=True, elem_id="accordion1"):
|
assets/banner/banner.png
CHANGED
Git LFS Details
|
Git LFS Details
|
requirements.txt
CHANGED
@@ -1,8 +1,5 @@
|
|
1 |
-
|
2 |
-
addict
|
3 |
-
simplejson
|
4 |
dashscope
|
5 |
-
datasets==2.18.0
|
6 |
tensorflow-gpu==2.11.0
|
7 |
Pillow
|
8 |
gradio==3.50.2
|
@@ -10,4 +7,3 @@ opencv-python
|
|
10 |
oss2==2.17.0
|
11 |
torch
|
12 |
torchvision
|
13 |
-
modelscope
|
|
|
1 |
+
modelscope
|
|
|
|
|
2 |
dashscope
|
|
|
3 |
tensorflow-gpu==2.11.0
|
4 |
Pillow
|
5 |
gradio==3.50.2
|
|
|
7 |
oss2==2.17.0
|
8 |
torch
|
9 |
torchvision
|
|
src/util.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import concurrent.futures
|
2 |
import io
|
3 |
import os
|
4 |
-
import time
|
5 |
|
6 |
import numpy as np
|
7 |
import oss2
|
@@ -20,7 +19,7 @@ bucket = oss2.Bucket(oss2.Auth(access_key_id, access_key_secret), endpoint, buck
|
|
20 |
oss_path = "hejunjie.hjj/TransferAnythingHF"
|
21 |
oss_path_img_gallery = "hejunjie.hjj/TransferAnythingHF_img_gallery"
|
22 |
|
23 |
-
|
24 |
def download_img_pil(index, img_url):
|
25 |
# print(img_url)
|
26 |
r = requests.get(img_url, stream=True)
|
@@ -63,10 +62,8 @@ def upload_np_2_oss(input_image, name="cache.png", gallery=False):
|
|
63 |
else:
|
64 |
path = oss_path
|
65 |
|
66 |
-
start_time = time.perf_counter()
|
67 |
bucket.put_object(path + "/" + name, imgByteArr) # data为数据,可以是图片
|
68 |
ret = bucket.sign_url('GET', path + "/" + name, 60 * 60 * 24) # 返回值为链接,参数依次为,方法/oss上文件路径/过期时间(s)
|
69 |
-
logger.info(f"upload cost: {time.perf_counter() - start_time} s.")
|
70 |
del imgByteArr
|
71 |
return ret
|
72 |
|
|
|
1 |
import concurrent.futures
|
2 |
import io
|
3 |
import os
|
|
|
4 |
|
5 |
import numpy as np
|
6 |
import oss2
|
|
|
19 |
oss_path = "hejunjie.hjj/TransferAnythingHF"
|
20 |
oss_path_img_gallery = "hejunjie.hjj/TransferAnythingHF_img_gallery"
|
21 |
|
22 |
+
|
23 |
def download_img_pil(index, img_url):
|
24 |
# print(img_url)
|
25 |
r = requests.get(img_url, stream=True)
|
|
|
62 |
else:
|
63 |
path = oss_path
|
64 |
|
|
|
65 |
bucket.put_object(path + "/" + name, imgByteArr) # data为数据,可以是图片
|
66 |
ret = bucket.sign_url('GET', path + "/" + name, 60 * 60 * 24) # 返回值为链接,参数依次为,方法/oss上文件路径/过期时间(s)
|
|
|
67 |
del imgByteArr
|
68 |
return ret
|
69 |
|