Spaces:
Running
on
Zero
Running
on
Zero
add example
#1
by
kIDAa
- opened
- .gitattributes +0 -2
- app.py +5 -51
- images/.DS_Store +0 -0
- images/image1.png +0 -3
- images/image1_layer.png +0 -0
- images/image2.png +0 -3
- images/image2_layer.png +0 -0
- images/image3.png +0 -0
- images/image3_layer.png +0 -0
.gitattributes
CHANGED
@@ -34,5 +34,3 @@ saved_model/**/* 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 |
diffsynth/tokenizer_configs/kolors/tokenizer/vocab.txt filter=lfs diff=lfs merge=lfs -text
|
37 |
-
images/image1.png filter=lfs diff=lfs merge=lfs -text
|
38 |
-
images/image2.png 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 |
diffsynth/tokenizer_configs/kolors/tokenizer/vocab.txt filter=lfs diff=lfs merge=lfs -text
|
|
|
|
app.py
CHANGED
@@ -154,23 +154,12 @@ with gr.Blocks() as app:
|
|
154 |
|
155 |
with gr.Accordion(label="Image"):
|
156 |
num_inference_steps = gr.Slider(minimum=1, maximum=100, value=20, step=1, interactive=True, label="Inference steps")
|
157 |
-
height = gr.Slider(minimum=
|
158 |
-
width = gr.Slider(minimum=
|
159 |
with gr.Column():
|
160 |
use_fixed_seed = gr.Checkbox(value=True, interactive=False, label="Use fixed seed")
|
161 |
seed = gr.Number(minimum=0, maximum=10**9, value=0, interactive=True, label="Random seed", show_label=False)
|
162 |
|
163 |
-
with gr.Row(elem_id="pro-tips"):
|
164 |
-
gr.Markdown("""
|
165 |
-
# Usage:
|
166 |
-
|
167 |
-
1. Enter a prompt and click "Generate" to create an image.
|
168 |
-
2. Click "Set as painter's background" to use the generated image as the canvas.
|
169 |
-
3. In the painter, draw the area you want to repaint and set a local prompt. For multiple areas with different prompts, use layer1 and layer2, and click "Enable this layer" to activate the canvas.
|
170 |
-
4. Click "Generate" again to obtain the repainted image.
|
171 |
-
5. If you want to regenerate a new image as the background, uncheck "Enable this layer," update the prompt, and click "Generate."
|
172 |
-
""")
|
173 |
-
|
174 |
@gr.on(
|
175 |
inputs=[model_type, model_path, prompt, negative_prompt, cfg_scale, embedded_guidance, num_inference_steps, height, width],
|
176 |
outputs=[prompt, negative_prompt, cfg_scale, embedded_guidance, num_inference_steps, height, width],
|
@@ -194,17 +183,10 @@ with gr.Blocks() as app:
|
|
194 |
canvas_list = []
|
195 |
for painter_layer_id in range(config["max_num_painter_layers"]):
|
196 |
with gr.Tab(label=f"Layer {painter_layer_id}"):
|
197 |
-
|
198 |
-
enable_local_prompt = gr.Checkbox(
|
199 |
-
label="Enable this layer",
|
200 |
-
value=enable_local_prompt_value,
|
201 |
-
key=f"enable_local_prompt_{painter_layer_id}"
|
202 |
-
)
|
203 |
-
|
204 |
local_prompt = gr.Textbox(label="Local prompt", key=f"local_prompt_{painter_layer_id}")
|
205 |
-
mask_scale = gr.Slider(minimum=0.0, maximum=5.0, value=
|
206 |
-
|
207 |
-
canvas = gr.ImageEditor(canvas_size=canvas_size, sources=None, layers=False, interactive=True, image_mode="RGBA",
|
208 |
brush=gr.Brush(default_size=100, default_color="#000000", colors=["#000000"]),
|
209 |
label="Painter", key=f"canvas_{painter_layer_id}")
|
210 |
@gr.on(inputs=[height, width, canvas], outputs=canvas, triggers=[height.change, width.change, canvas.clear, enable_local_prompt.change], show_progress="hidden")
|
@@ -273,32 +255,4 @@ with gr.Blocks() as app:
|
|
273 |
h, w = canvas["background"].shape[:2]
|
274 |
canvas["background"] = output_image.resize((w, h))
|
275 |
return tuple(canvas_list)
|
276 |
-
|
277 |
-
canvas1 = {
|
278 |
-
"background": Image.open("images/image1.png"),
|
279 |
-
"layers": [np.array(Image.open("images/image1_layer.png"))],
|
280 |
-
"composite": "images/image1_layer.png",
|
281 |
-
}
|
282 |
-
canvas2 = {
|
283 |
-
"background": Image.open("images/image2.png"),
|
284 |
-
"layers": [np.array(Image.open("images/image2_layer.png"))],
|
285 |
-
"composite": "images/image2_layer.png",
|
286 |
-
}
|
287 |
-
canvas3 = {
|
288 |
-
"background": Image.open("images/image3.png"),
|
289 |
-
"layers": [np.array(Image.open("images/image3_layer.png"))],
|
290 |
-
"composite": "images/image3_layer.png",
|
291 |
-
}
|
292 |
-
|
293 |
-
print(*enable_local_prompt_list, *local_prompt_list, *mask_scale_list, *canvas_list)
|
294 |
-
with gr.Row():
|
295 |
-
show_case = gr.Examples(
|
296 |
-
examples=[
|
297 |
-
["a girl", 0, "images/image1.png", True, "red hat", 3.0, canvas1],
|
298 |
-
["an orange cat", 0, "images/image2.png", True, "a big crown on the cat", 3.0, canvas2],
|
299 |
-
["A young man is riding a horse", 0, "images/image3.png", True, "A robot is riding a horse", 3.0, canvas3],
|
300 |
-
],
|
301 |
-
inputs=[prompt, seed, output_image, enable_local_prompt_list[0], local_prompt_list[0], mask_scale_list[0], canvas_list[0]],
|
302 |
-
label=None
|
303 |
-
)
|
304 |
app.launch()
|
|
|
154 |
|
155 |
with gr.Accordion(label="Image"):
|
156 |
num_inference_steps = gr.Slider(minimum=1, maximum=100, value=20, step=1, interactive=True, label="Inference steps")
|
157 |
+
height = gr.Slider(minimum=64, maximum=2048, value=1024, step=64, interactive=True, label="Height")
|
158 |
+
width = gr.Slider(minimum=64, maximum=2048, value=1024, step=64, interactive=True, label="Width")
|
159 |
with gr.Column():
|
160 |
use_fixed_seed = gr.Checkbox(value=True, interactive=False, label="Use fixed seed")
|
161 |
seed = gr.Number(minimum=0, maximum=10**9, value=0, interactive=True, label="Random seed", show_label=False)
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
@gr.on(
|
164 |
inputs=[model_type, model_path, prompt, negative_prompt, cfg_scale, embedded_guidance, num_inference_steps, height, width],
|
165 |
outputs=[prompt, negative_prompt, cfg_scale, embedded_guidance, num_inference_steps, height, width],
|
|
|
183 |
canvas_list = []
|
184 |
for painter_layer_id in range(config["max_num_painter_layers"]):
|
185 |
with gr.Tab(label=f"Layer {painter_layer_id}"):
|
186 |
+
enable_local_prompt = gr.Checkbox(label="Enable", value=False, key=f"enable_local_prompt_{painter_layer_id}")
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
local_prompt = gr.Textbox(label="Local prompt", key=f"local_prompt_{painter_layer_id}")
|
188 |
+
mask_scale = gr.Slider(minimum=0.0, maximum=5.0, value=5.0, step=0.1, interactive=True, label="Mask scale", key=f"mask_scale_{painter_layer_id}")
|
189 |
+
canvas = gr.ImageEditor(canvas_size=(512, 1), sources=None, layers=False, interactive=True, image_mode="RGBA",
|
|
|
190 |
brush=gr.Brush(default_size=100, default_color="#000000", colors=["#000000"]),
|
191 |
label="Painter", key=f"canvas_{painter_layer_id}")
|
192 |
@gr.on(inputs=[height, width, canvas], outputs=canvas, triggers=[height.change, width.change, canvas.clear, enable_local_prompt.change], show_progress="hidden")
|
|
|
255 |
h, w = canvas["background"].shape[:2]
|
256 |
canvas["background"] = output_image.resize((w, h))
|
257 |
return tuple(canvas_list)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
app.launch()
|
images/.DS_Store
DELETED
Binary file (6.15 kB)
|
|
images/image1.png
DELETED
Git LFS Details
|
images/image1_layer.png
DELETED
Binary file (6.55 kB)
|
|
images/image2.png
DELETED
Git LFS Details
|
images/image2_layer.png
DELETED
Binary file (5.93 kB)
|
|
images/image3.png
DELETED
Binary file (58.1 kB)
|
|
images/image3_layer.png
DELETED
Binary file (9.46 kB)
|
|