Spaces:
Running
on
Zero
Running
on
Zero
update
Browse files- app.py +30 -17
- demo_footer.html +3 -0
- demo_header.html +12 -8
- examples/draw-gimp_input.jpg +0 -0
- examples/draw-gimp_output.jpg +0 -0
- examples/draw_input.jpg +0 -0
- examples/draw_output.jpg +0 -0
- examples/gimp_input.jpg +0 -0
- examples/gimp_output.jpg +0 -0
- examples/inpaint_input.jpg +0 -0
- examples/inpaint_output.jpg +0 -0
- requirements.txt +1 -0
- tools.html +10 -0
app.py
CHANGED
|
@@ -35,7 +35,7 @@ def process_images(image, image2=None,prompt="a girl",strength=0.75,seed=0,infer
|
|
| 35 |
if not isinstance(image, dict):
|
| 36 |
if image2 == None:
|
| 37 |
print("empty mask")
|
| 38 |
-
return image
|
| 39 |
else:
|
| 40 |
image = dict({'background': image, 'layers': [image2]})
|
| 41 |
|
|
@@ -70,7 +70,7 @@ def process_images(image, image2=None,prompt="a girl",strength=0.75,seed=0,infer
|
|
| 70 |
output = process_img2img(image["background"],mask,prompt,strength,seed,inference_step)
|
| 71 |
|
| 72 |
print("end process_images")
|
| 73 |
-
return output
|
| 74 |
|
| 75 |
|
| 76 |
def read_file(path: str) -> str:
|
|
@@ -89,49 +89,62 @@ css="""
|
|
| 89 |
margin: 0 auto;
|
| 90 |
max-width: 640px;
|
| 91 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
"""
|
| 93 |
|
| 94 |
with gr.Blocks(css=css, elem_id="demo-container") as demo:
|
| 95 |
with gr.Column():
|
| 96 |
gr.HTML(read_file("demo_header.html"))
|
|
|
|
| 97 |
with gr.Row():
|
| 98 |
with gr.Column():
|
| 99 |
-
image = gr.
|
| 100 |
with gr.Row(elem_id="prompt-container", equal_height=False):
|
| 101 |
with gr.Row():
|
| 102 |
prompt = gr.Textbox(label="Prompt",value="a eyes closed girl,shut eyes",placeholder="Your prompt (what you want in place of what is erased)", elem_id="prompt")
|
| 103 |
|
| 104 |
btn = gr.Button("Img2Img", elem_id="run_button",variant="primary")
|
| 105 |
|
| 106 |
-
image_mask = gr.Image(sources=['upload','clipboard'], elem_id="mask_upload", type="pil", label="Mask_Upload",height=400, value=None)
|
| 107 |
with gr.Accordion(label="Advanced Settings", open=False):
|
| 108 |
with gr.Row( equal_height=True):
|
| 109 |
strength = gr.Number(value=0.75, minimum=0, maximum=0.75, step=0.01, label="strength")
|
| 110 |
seed = gr.Number(value=100, minimum=0, step=1, label="seed")
|
| 111 |
inference_step = gr.Number(value=4, minimum=1, step=4, label="inference_step")
|
| 112 |
-
#models = ["black-forest-labs/FLUX.1-schnell"]
|
| 113 |
-
#inpaint_model = gr.Dropdown(label="modes", choices=models, value="black-forest-labs/FLUX.1-schnell")
|
| 114 |
id_input=gr.Text(label="Name", visible=False)
|
| 115 |
|
| 116 |
with gr.Column():
|
| 117 |
image_out = gr.Image(height=800,sources=[],label="Output", elem_id="output-img",format="jpg")
|
| 118 |
-
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
-
#btn.click(fn=process_images, inputs=[image, image_mask,prompt,strength,seed,inference_step], outputs =[image_out,mask_out], api_name='infer')
|
| 124 |
gr.Examples(
|
| 125 |
examples=[
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
| 129 |
]
|
| 130 |
,
|
| 131 |
-
|
| 132 |
-
inputs=[image,image_mask,prompt,strength,image_out],
|
| 133 |
-
#outputs=[test_out],
|
| 134 |
-
#cache_examples=False,
|
| 135 |
)
|
| 136 |
gr.HTML(
|
| 137 |
"""
|
|
@@ -141,8 +154,8 @@ with gr.Blocks(css=css, elem_id="demo-container") as demo:
|
|
| 141 |
gr.on(
|
| 142 |
triggers=[btn.click, prompt.submit],
|
| 143 |
fn = process_images,
|
| 144 |
-
inputs = [image,
|
| 145 |
-
outputs = [image_out
|
| 146 |
)
|
| 147 |
|
| 148 |
if __name__ == "__main__":
|
|
|
|
| 35 |
if not isinstance(image, dict):
|
| 36 |
if image2 == None:
|
| 37 |
print("empty mask")
|
| 38 |
+
return image
|
| 39 |
else:
|
| 40 |
image = dict({'background': image, 'layers': [image2]})
|
| 41 |
|
|
|
|
| 70 |
output = process_img2img(image["background"],mask,prompt,strength,seed,inference_step)
|
| 71 |
|
| 72 |
print("end process_images")
|
| 73 |
+
return output
|
| 74 |
|
| 75 |
|
| 76 |
def read_file(path: str) -> str:
|
|
|
|
| 89 |
margin: 0 auto;
|
| 90 |
max-width: 640px;
|
| 91 |
}
|
| 92 |
+
.grid-container {
|
| 93 |
+
display: flex;
|
| 94 |
+
align-items: center;
|
| 95 |
+
justify-content: center;
|
| 96 |
+
gap:10px
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.image {
|
| 100 |
+
width: 128px;
|
| 101 |
+
height: 128px;
|
| 102 |
+
object-fit: cover;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.text {
|
| 106 |
+
font-size: 16px;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
"""
|
| 110 |
|
| 111 |
with gr.Blocks(css=css, elem_id="demo-container") as demo:
|
| 112 |
with gr.Column():
|
| 113 |
gr.HTML(read_file("demo_header.html"))
|
| 114 |
+
gr.HTML(read_file("demo_tools.html"))
|
| 115 |
with gr.Row():
|
| 116 |
with gr.Column():
|
| 117 |
+
image = gr.Image(height=800,sources=['upload','clipboard'],image_mode='RGB', elem_id="image_upload", type="pil", label="Upload")
|
| 118 |
with gr.Row(elem_id="prompt-container", equal_height=False):
|
| 119 |
with gr.Row():
|
| 120 |
prompt = gr.Textbox(label="Prompt",value="a eyes closed girl,shut eyes",placeholder="Your prompt (what you want in place of what is erased)", elem_id="prompt")
|
| 121 |
|
| 122 |
btn = gr.Button("Img2Img", elem_id="run_button",variant="primary")
|
| 123 |
|
|
|
|
| 124 |
with gr.Accordion(label="Advanced Settings", open=False):
|
| 125 |
with gr.Row( equal_height=True):
|
| 126 |
strength = gr.Number(value=0.75, minimum=0, maximum=0.75, step=0.01, label="strength")
|
| 127 |
seed = gr.Number(value=100, minimum=0, step=1, label="seed")
|
| 128 |
inference_step = gr.Number(value=4, minimum=1, step=4, label="inference_step")
|
|
|
|
|
|
|
| 129 |
id_input=gr.Text(label="Name", visible=False)
|
| 130 |
|
| 131 |
with gr.Column():
|
| 132 |
image_out = gr.Image(height=800,sources=[],label="Output", elem_id="output-img",format="jpg")
|
| 133 |
+
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
|
|
|
| 138 |
gr.Examples(
|
| 139 |
examples=[
|
| 140 |
+
["examples/draw_input.jpg", "examples/draw_output.jpg","a women ,eyes closed,mouth opened"],
|
| 141 |
+
["examples/draw-gimp_input.jpg", "examples/draw-gimp_output.jpg","a women ,eyes closed,mouth opened"],
|
| 142 |
+
["examples/draw_input.jpg", "examples/draw_output.jpg","a women ,eyes closed,mouth opened"],
|
| 143 |
+
["examples/gimp_input.jpg", "examples/gimp_output.jpg","a women ,hand on neck"],
|
| 144 |
+
["examples/inpaint_input.jpg", "examples/inpaint_output.jpg","a women ,hand on neck"]
|
| 145 |
]
|
| 146 |
,
|
| 147 |
+
inputs=[image,image_out,prompt],
|
|
|
|
|
|
|
|
|
|
| 148 |
)
|
| 149 |
gr.HTML(
|
| 150 |
"""
|
|
|
|
| 154 |
gr.on(
|
| 155 |
triggers=[btn.click, prompt.submit],
|
| 156 |
fn = process_images,
|
| 157 |
+
inputs = [image,prompt,strength,seed,inference_step],
|
| 158 |
+
outputs = [image_out]
|
| 159 |
)
|
| 160 |
|
| 161 |
if __name__ == "__main__":
|
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
|
@@ -1,12 +1,16 @@
|
|
| 1 |
<div style="text-align: center;">
|
| 2 |
<h1>
|
| 3 |
-
Flux.1-schnell
|
| 4 |
</h1>
|
| 5 |
-
<
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
</div>
|
|
|
|
|
|
| 1 |
<div style="text-align: center;">
|
| 2 |
<h1>
|
| 3 |
+
Flux.1-schnell img2img
|
| 4 |
</h1>
|
| 5 |
+
<div class="grid-container">
|
| 6 |
+
<img src="https://akjava.github.io/AIDiagramChatWithVoice-FaceCharacter/webp/128/00349245_09_00002200.webp" alt="Flux.1-schnell-WebP3Frame-TalkingAnimation" class="image">
|
| 7 |
+
<p class="text">
|
| 8 |
+
Simple Classic Inapint result are good.but plain drawing is not so good,You can get best result with Gimp's Smudge Tool<br>
|
| 9 |
+
Img2img is good for scale-up too ,the result is more better with Gimp's sharpen<br>
|
| 10 |
+
Basically output face is totally difference,scale up to image to reduce that<br>
|
| 11 |
+
Usually result color strange,use Whitebalance tools or gimp<br>
|
| 12 |
+
you can clear face coverd hand with img2img + inpaint
|
| 13 |
+
</p>
|
| 14 |
+
</div>
|
| 15 |
</div>
|
| 16 |
+
|
examples/draw-gimp_input.jpg
ADDED
|
examples/draw-gimp_output.jpg
ADDED
|
examples/draw_input.jpg
ADDED
|
examples/draw_output.jpg
ADDED
|
examples/gimp_input.jpg
ADDED
|
examples/gimp_output.jpg
ADDED
|
examples/inpaint_input.jpg
ADDED
|
examples/inpaint_output.jpg
ADDED
|
requirements.txt
CHANGED
|
@@ -4,4 +4,5 @@ torch
|
|
| 4 |
diffusers
|
| 5 |
accelerate
|
| 6 |
transformers
|
|
|
|
| 7 |
sentencepiece
|
|
|
|
| 4 |
diffusers
|
| 5 |
accelerate
|
| 6 |
transformers
|
| 7 |
+
xformers
|
| 8 |
sentencepiece
|
tools.html
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div style="text-align: center;">
|
| 2 |
+
<p><a href="https://huggingface.co/spaces/Akjava/AIDiagramChatWithVoice-FaceCharacter">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-img2img">[Flux1-Img2Img(GPU)]</a>
|
| 5 |
+
<a href="https://huggingface.co/spaces/Akjava/flux1-schnell-mask-inpaint">[Flux1-Inpaint(GPU)]</a>
|
| 6 |
+
<a href="https://huggingface.co/spaces/Akjava/OpenCVInpaintCPU">[OpenCV-Inapint]</a>
|
| 7 |
+
<a href="https://huggingface.co/spaces/Akjava/Simple-Whitebalance-Image">[Whitebalance]</a>
|
| 8 |
+
<a href="https://huggingface.co/spaces/Akjava/Simple-Mask-Paste-Image">[Paste Image]</a>
|
| 9 |
+
<a href=" https://huggingface.co/spaces/Akjava/WebP-Resize-Convert">[WebP Resize Convert]</a></p>
|
| 10 |
+
</div>
|