Spaces:
Running
on
Zero
Running
on
Zero
refactoring
Browse files- app.py +26 -11
- demo_footer.html +3 -0
- demo_header.html +9 -8
- examples/00207245.jpg +0 -0
- examples/00207245_18.jpg +0 -0
- examples/00207245_18_mask.jpg +0 -0
- examples/00538245.jpg +0 -0
- examples/00538245_mask.jpg +0 -0
- examples/00538245_paint.jpg +0 -0
- examples/00547245.jpg +0 -0
- examples/00547245_99.jpg +0 -0
- examples/00547245_99_mask.jpg +0 -0
- tools.html +12 -0
app.py
CHANGED
|
@@ -47,10 +47,10 @@ def sanitize_prompt(prompt):
|
|
| 47 |
return sanitized_prompt
|
| 48 |
|
| 49 |
@spaces.GPU(duration=120)
|
| 50 |
-
def
|
| 51 |
# I'm not sure when this happen
|
| 52 |
-
progress(0, desc="start-process-
|
| 53 |
-
print("start-process-
|
| 54 |
if not isinstance(image, dict):
|
| 55 |
if image2 == None:
|
| 56 |
print("empty mask")
|
|
@@ -88,7 +88,7 @@ def process_images(image, image2=None,prompt="a girl",inpaint_model="black-fores
|
|
| 88 |
output = pipe(prompt=prompt, image=image, mask_image=mask_image,generator=generator,strength=strength,width=width,height=height,
|
| 89 |
guidance_scale=0,num_inference_steps=num_inference_steps,max_sequence_length=256)
|
| 90 |
|
| 91 |
-
return output.
|
| 92 |
|
| 93 |
|
| 94 |
output = process_inpaint(image["background"],mask,prompt,inpaint_model,strength,seed)
|
|
@@ -111,11 +111,28 @@ css="""
|
|
| 111 |
margin: 0 auto;
|
| 112 |
max-width: 640px;
|
| 113 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
"""
|
| 115 |
|
| 116 |
with gr.Blocks(css=css, elem_id="demo-container") as demo:
|
| 117 |
with gr.Column():
|
| 118 |
gr.HTML(read_file("demo_header.html"))
|
|
|
|
| 119 |
with gr.Row():
|
| 120 |
with gr.Column():
|
| 121 |
image = gr.ImageEditor(height=800,sources=['upload','clipboard'],transforms=[],image_mode='RGB', layers=False, elem_id="image_upload", type="pil", label="Upload",brush=gr.Brush(colors=["#fff"], color_mode="fixed"))
|
|
@@ -141,12 +158,12 @@ with gr.Blocks(css=css, elem_id="demo-container") as demo:
|
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
-
btn.click(fn=
|
| 145 |
gr.Examples(
|
| 146 |
examples=[
|
| 147 |
-
["
|
| 148 |
-
["
|
| 149 |
-
["
|
| 150 |
]
|
| 151 |
,
|
| 152 |
#fn=example_out,
|
|
@@ -155,9 +172,7 @@ with gr.Blocks(css=css, elem_id="demo-container") as demo:
|
|
| 155 |
#cache_examples=False,
|
| 156 |
)
|
| 157 |
gr.HTML(
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
"""
|
| 161 |
)
|
| 162 |
|
| 163 |
demo.launch()
|
|
|
|
| 47 |
return sanitized_prompt
|
| 48 |
|
| 49 |
@spaces.GPU(duration=120)
|
| 50 |
+
def process_examples(image, image2=None,prompt="a girl",inpaint_model="black-forest-labs/FLUX.1-schnell",strength=0.75,seed=0,progress=gr.Progress(track_tqdm=True)):
|
| 51 |
# I'm not sure when this happen
|
| 52 |
+
progress(0, desc="start-process-examples")
|
| 53 |
+
print("start-process-examples")
|
| 54 |
if not isinstance(image, dict):
|
| 55 |
if image2 == None:
|
| 56 |
print("empty mask")
|
|
|
|
| 88 |
output = pipe(prompt=prompt, image=image, mask_image=mask_image,generator=generator,strength=strength,width=width,height=height,
|
| 89 |
guidance_scale=0,num_inference_steps=num_inference_steps,max_sequence_length=256)
|
| 90 |
|
| 91 |
+
return output.examples[0]
|
| 92 |
|
| 93 |
|
| 94 |
output = process_inpaint(image["background"],mask,prompt,inpaint_model,strength,seed)
|
|
|
|
| 111 |
margin: 0 auto;
|
| 112 |
max-width: 640px;
|
| 113 |
}
|
| 114 |
+
.grid-container {
|
| 115 |
+
display: flex;
|
| 116 |
+
align-items: center;
|
| 117 |
+
justify-content: center;
|
| 118 |
+
gap:10px
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
.image {
|
| 122 |
+
width: 128px;
|
| 123 |
+
height: 128px;
|
| 124 |
+
object-fit: cover;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.text {
|
| 128 |
+
font-size: 16px;
|
| 129 |
+
}
|
| 130 |
"""
|
| 131 |
|
| 132 |
with gr.Blocks(css=css, elem_id="demo-container") as demo:
|
| 133 |
with gr.Column():
|
| 134 |
gr.HTML(read_file("demo_header.html"))
|
| 135 |
+
gr.HTML(read_file("tools.html"))
|
| 136 |
with gr.Row():
|
| 137 |
with gr.Column():
|
| 138 |
image = gr.ImageEditor(height=800,sources=['upload','clipboard'],transforms=[],image_mode='RGB', layers=False, elem_id="image_upload", type="pil", label="Upload",brush=gr.Brush(colors=["#fff"], color_mode="fixed"))
|
|
|
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
+
btn.click(fn=process_examples, inputs=[image, image_mask,prompt,inpaint_model,strength,seed], outputs =[image_out,mask_out], api_name='infer')
|
| 162 |
gr.Examples(
|
| 163 |
examples=[
|
| 164 |
+
["examples/00547245_99.jpg", "examples/00547245_99_mask.jpg","a beautiful girl,eyes closed",0.8,"examples/00547245.jpg"],
|
| 165 |
+
["examples/00538245_paint.jpg", "examples/00538245_mask.jpg","a beautiful girl,wearing t-shirt",0.7,"examples/00538245.jpg"],
|
| 166 |
+
["examples/00207245_18.jpg", "examples/00207245_18_mask.jpg","a beautiful girl,mouth opened",0.2,"examples/00207245.jpg"]
|
| 167 |
]
|
| 168 |
,
|
| 169 |
#fn=example_out,
|
|
|
|
| 172 |
#cache_examples=False,
|
| 173 |
)
|
| 174 |
gr.HTML(
|
| 175 |
+
gr.HTML(read_file("demo_footer.html"))
|
|
|
|
|
|
|
| 176 |
)
|
| 177 |
|
| 178 |
demo.launch()
|
demo_footer.html
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div>
|
| 2 |
+
<P> Images are generated with <a href="https://huggingface.co/black-forest-labs/FLUX.1-schnell">FLUX.1-schnell</a> and licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">the Apache 2.0 License</a>
|
| 3 |
+
</div>
|
demo_header.html
CHANGED
|
@@ -2,12 +2,13 @@
|
|
| 2 |
<h1>
|
| 3 |
Flux.1-schnell mask-inpaint
|
| 4 |
</h1>
|
| 5 |
-
<
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
See examples
|
| 9 |
-
The image requires guide painting.(To generate an image with closed eyes, fill the eye area with skin color.)
|
| 10 |
-
You can draw mask or upload mask.BE CAREFUL UPLOAEDED MASK(If the uploaded mask exist,ignore your painted mask)
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
</div>
|
|
|
|
| 2 |
<h1>
|
| 3 |
Flux.1-schnell mask-inpaint
|
| 4 |
</h1>
|
| 5 |
+
<div class="grid-container">
|
| 6 |
+
<img src="https://akjava.github.io/AIDiagramChatWithVoice-FaceCharacter/webp/128/00206245_09_00003200.webp" alt="Flux.1-schnell-WebP3Frame-TalkingAnimation" class="image">
|
| 7 |
+
<p class="text">
|
| 8 |
+
See examples.<br>
|
| 9 |
+
The image requires guide painting.(To generate an image with closed eyes, fill the eye area with skin color.)<br>
|
| 10 |
+
You can draw mask or upload mask.BE CAREFUL UPLOAEDED MASK(If the uploaded mask exist,ignore your painted mask)<br>
|
| 11 |
+
Hint:step by step,reduce strength.blur guide-paint and mask
|
| 12 |
+
</p>
|
| 13 |
+
</div>
|
| 14 |
</div>
|
examples/00207245.jpg
ADDED
|
examples/00207245_18.jpg
ADDED
|
examples/00207245_18_mask.jpg
ADDED
|
examples/00538245.jpg
ADDED
|
examples/00538245_mask.jpg
ADDED
|
examples/00538245_paint.jpg
ADDED
|
examples/00547245.jpg
ADDED
|
examples/00547245_99.jpg
ADDED
|
examples/00547245_99_mask.jpg
ADDED
|
tools.html
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div style="text-align: center;">
|
| 2 |
+
<p><a href="https://huggingface.co/spaces/Akjava/godot-huggingface-chain">AI Diagram Chat with Voice/Face Character Making Tools</a></p>
|
| 3 |
+
<p><a href="https://huggingface.co/spaces/Akjava/WebPTalkHead">[WebP-3F-TH]</a>
|
| 4 |
+
<a href="https://huggingface.co/spaces/Akjava/flux1-schnell-mask-inpaint">[Flux1-Inpaint(GPU)]</a>
|
| 5 |
+
<a href="https://huggingface.co/spaces/Akjava/OpenCVInpaintCPU">[OpenCV-Inapint]</a>
|
| 6 |
+
<a href="https://huggingface.co/spaces/Akjava/Simple-Whitebalance-Image">[Whitebalance]</a>
|
| 7 |
+
<a href="https://huggingface.co/spaces/Akjava/Simple-Mask-Paste-Image">[Paste Image]</a>
|
| 8 |
+
<a href=" https://huggingface.co/spaces/Akjava/WebP-Resize-Convert">[WebP Resize Convert]</a></p>
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
</div>
|