Spaces:
Runtime error
Runtime error
lixiang46
commited on
Commit
•
06436de
1
Parent(s):
1ae1c49
add exampes
Browse files- .gitattributes +8 -0
- app.py +21 -10
- image/1.png +3 -0
- image/1_masked.png +3 -0
- image/2.png +3 -0
- image/2_masked.png +3 -0
- image/3.png +3 -0
- image/3_mask.png +3 -0
- image/4.png +3 -0
- image/4_mask.png +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,11 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
image/2.png filter=lfs diff=lfs merge=lfs -text
|
37 |
+
image/2_masked.png filter=lfs diff=lfs merge=lfs -text
|
38 |
+
image/3.png filter=lfs diff=lfs merge=lfs -text
|
39 |
+
image/3_mask.png filter=lfs diff=lfs merge=lfs -text
|
40 |
+
image/4.png filter=lfs diff=lfs merge=lfs -text
|
41 |
+
image/4_mask.png filter=lfs diff=lfs merge=lfs -text
|
42 |
+
image/1.png filter=lfs diff=lfs merge=lfs -text
|
43 |
+
image/1_masked.png filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -35,12 +35,15 @@ MAX_IMAGE_SIZE = 1024
|
|
35 |
@spaces.GPU
|
36 |
def infer(prompt,
|
37 |
image,
|
|
|
38 |
negative_prompt = "",
|
39 |
seed = 0,
|
40 |
randomize_seed = False,
|
41 |
guidance_scale = 5.0,
|
42 |
num_inference_steps = 25
|
43 |
):
|
|
|
|
|
44 |
if randomize_seed:
|
45 |
seed = random.randint(0, MAX_SEED)
|
46 |
generator = torch.Generator().manual_seed(seed)
|
@@ -62,6 +65,14 @@ def infer(prompt,
|
|
62 |
return result
|
63 |
|
64 |
examples = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
]
|
66 |
|
67 |
css="""
|
@@ -91,12 +102,12 @@ with gr.Blocks(css=css) as Kolors:
|
|
91 |
lines=2
|
92 |
)
|
93 |
with gr.Row():
|
94 |
-
image = gr.ImageEditor(type='pil', image_mode='RGB', layers=False, brush=gr.Brush(colors=["#AAAAAA"], color_mode="fixed"))
|
|
|
95 |
with gr.Accordion("Advanced Settings", open=False):
|
96 |
negative_prompt = gr.Textbox(
|
97 |
label="Negative prompt",
|
98 |
placeholder="Enter a negative prompt",
|
99 |
-
visible=True,
|
100 |
value='残缺的手指,畸形的手指,畸形的手,残肢,模糊,低质量'
|
101 |
)
|
102 |
seed = gr.Slider(
|
@@ -128,17 +139,17 @@ with gr.Blocks(css=css) as Kolors:
|
|
128 |
with gr.Column(elem_id="col-right"):
|
129 |
result = gr.Image(label="Result", show_label=False)
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
|
139 |
run_button.click(
|
140 |
fn = infer,
|
141 |
-
inputs = [prompt, image, negative_prompt, seed, randomize_seed, guidance_scale, num_inference_steps],
|
142 |
outputs = [result]
|
143 |
)
|
144 |
|
|
|
35 |
@spaces.GPU
|
36 |
def infer(prompt,
|
37 |
image,
|
38 |
+
mask_image = None,
|
39 |
negative_prompt = "",
|
40 |
seed = 0,
|
41 |
randomize_seed = False,
|
42 |
guidance_scale = 5.0,
|
43 |
num_inference_steps = 25
|
44 |
):
|
45 |
+
if mask_image != None:
|
46 |
+
image = dict({'background': image, 'layers': [negative_prompt]})
|
47 |
if randomize_seed:
|
48 |
seed = random.randint(0, MAX_SEED)
|
49 |
generator = torch.Generator().manual_seed(seed)
|
|
|
65 |
return result
|
66 |
|
67 |
examples = [
|
68 |
+
["一只带着红色帽子的小猫咪,圆脸,大眼,极度可爱,高饱和度,立体,柔和的光线",
|
69 |
+
"image/1.png", "image/1_masked.png"],
|
70 |
+
["This is a mouth-watering hot pot scene, with all kinds of delicious ingredients cooking in the boiling pot, emitting intoxicating heat and aroma. The fiery red peppers and bright chili oil are shining, with attractive and fascinating colors. The delicate thin-cut beef, refreshing tofu skin, enoki mushrooms with rich abalone sauce, and crisp vegetables in the pot are combined together to create a colorful visual presentation",
|
71 |
+
"image/2.png", "image/2_masked.png"],
|
72 |
+
["穿着美少女战士的衣服,一件类似于水手服风格的衣服,包括一个白色紧身上衣,前胸搭配一个大大的红色蝴蝶结。衣服的领子部分呈蓝色,并且有白色条纹。她还穿着一条蓝色百褶裙,超高清,辛烷渲染,高级质感,32k,高分辨率,最好的质量,超级细节,景深",
|
73 |
+
"image/3.png", "image/3_masked.png"],
|
74 |
+
["Wearing Iron Man's clothes, high-tech armor, the main colors are red and gold, and there are some silverdecorations. There is a light-up round reactor device on the chest, full of futuristic technology. Ultra-clear , high-quality, ultra-realistic, high-resolution, best quality, super details, depth of field",
|
75 |
+
"image/4.png", "image/4_masked.png"],
|
76 |
]
|
77 |
|
78 |
css="""
|
|
|
102 |
lines=2
|
103 |
)
|
104 |
with gr.Row():
|
105 |
+
image = gr.ImageEditor(label='Image', type='pil', image_mode='RGB', layers=False, brush=gr.Brush(colors=["#AAAAAA"], color_mode="fixed"))
|
106 |
+
mask_image = gr.Image(labe='Mask_Image',type='pil', visible=False, value=None)
|
107 |
with gr.Accordion("Advanced Settings", open=False):
|
108 |
negative_prompt = gr.Textbox(
|
109 |
label="Negative prompt",
|
110 |
placeholder="Enter a negative prompt",
|
|
|
111 |
value='残缺的手指,畸形的手指,畸形的手,残肢,模糊,低质量'
|
112 |
)
|
113 |
seed = gr.Slider(
|
|
|
139 |
with gr.Column(elem_id="col-right"):
|
140 |
result = gr.Image(label="Result", show_label=False)
|
141 |
|
142 |
+
with gr.Row():
|
143 |
+
gr.Examples(
|
144 |
+
fn = infer,
|
145 |
+
examples = examples,
|
146 |
+
inputs = [prompt, image, mask_image],
|
147 |
+
outputs = [result]
|
148 |
+
)
|
149 |
|
150 |
run_button.click(
|
151 |
fn = infer,
|
152 |
+
inputs = [prompt, image, None, negative_prompt, seed, randomize_seed, guidance_scale, num_inference_steps],
|
153 |
outputs = [result]
|
154 |
)
|
155 |
|
image/1.png
ADDED
Git LFS Details
|
image/1_masked.png
ADDED
Git LFS Details
|
image/2.png
ADDED
Git LFS Details
|
image/2_masked.png
ADDED
Git LFS Details
|
image/3.png
ADDED
Git LFS Details
|
image/3_mask.png
ADDED
Git LFS Details
|
image/4.png
ADDED
Git LFS Details
|
image/4_mask.png
ADDED
Git LFS Details
|