Spaces:
Running
Running
update example
Browse filesThis view is limited to 50 files because it contains too many changes. Β
See raw diff
- app.py +48 -37
- demo_footer.html +3 -0
- demo_header.html +18 -2
- demo_tools.html +10 -0
- {webpes β examples}/00002062.webp +0 -0
- {imgs β examples}/00002062_00.jpg +0 -0
- {imgs β examples}/00002062_09.jpg +0 -0
- {imgs β examples}/00002062_99.jpg +0 -0
- {webpes β examples}/00003245.webp +0 -0
- {imgs β examples}/00003245_eyes.jpg +0 -0
- {imgs β examples}/00003245_mouth.jpg +0 -0
- {imgs β examples}/00003245_normal.jpg +0 -0
- {webpes β examples}/00100265.webp +0 -0
- {imgs β examples}/00100265_00.jpg +0 -0
- {imgs β examples}/00100265_09.jpg +0 -0
- {imgs β examples}/00100265_99.jpg +0 -0
- {webpes β examples}/00207245.webp +0 -0
- {imgs β examples}/00207245_eyes.png +0 -0
- {imgs β examples}/00207245_mouth.png +0 -0
- {imgs β examples}/00207245_normal.png +0 -0
- {webpes β examples}/00350245.webp +0 -0
- {imgs β examples}/00350245_eyes.jpg +0 -0
- {imgs β examples}/00350245_mouth.jpg +0 -0
- {imgs β examples}/00350245_normal.jpg +0 -0
- {webpes β examples}/00538245.webp +0 -0
- {imgs β examples}/00538245_eyes.jpg +0 -0
- {imgs β examples}/00538245_mouth.jpg +0 -0
- {imgs β examples}/00538245_normal.jpg +0 -0
- {webpes β examples}/00824006.webp +0 -0
- {imgs β examples}/00824006_00.jpg +0 -0
- {imgs β examples}/00824006_09.jpg +0 -0
- {imgs β examples}/00824006_99.jpg +0 -0
- {webpes β examples}/00824008.webp +0 -0
- {imgs β examples}/00824008_00.jpg +0 -0
- {imgs β examples}/00824008_09.jpg +0 -0
- {imgs β examples}/00824008_99.jpg +0 -0
- {webpes β examples}/00825000.webp +0 -0
- {imgs β examples}/00825000_00.jpg +0 -0
- {imgs β examples}/00825000_09.jpg +0 -0
- {imgs β examples}/00825000_99.jpg +0 -0
- {webpes β examples}/00826004.webp +0 -0
- {imgs β examples}/00826004_00.jpg +0 -0
- {imgs β examples}/00826004_09.jpg +0 -0
- {imgs β examples}/00826004_99.jpg +0 -0
- {webpes β examples}/00826007.webp +0 -0
- {imgs β examples}/00826007_00.jpg +0 -0
- {imgs β examples}/00826007_09.jpg +0 -0
- {imgs β examples}/00826007_99.jpg +0 -0
- {webpes β examples}/00827009.webp +0 -0
- {imgs β examples}/00827009_00.jpg +0 -0
app.py
CHANGED
@@ -8,6 +8,7 @@ import io
|
|
8 |
import hashlib
|
9 |
import os
|
10 |
import time
|
|
|
11 |
css="""
|
12 |
#col-left {
|
13 |
margin: 0 auto;
|
@@ -17,10 +18,27 @@ css="""
|
|
17 |
margin: 0 auto;
|
18 |
max-width: 640px;
|
19 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
"""
|
21 |
|
|
|
22 |
output_dir = "outputs"
|
23 |
-
passed_time = 60
|
24 |
def load_text(text_path: str) -> str:
|
25 |
with open(text_path, 'r', encoding='utf-8') as f:
|
26 |
text = f.read()
|
@@ -28,17 +46,19 @@ def load_text(text_path: str) -> str:
|
|
28 |
return text
|
29 |
|
30 |
def clear_old_files(dir,passed_time):
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
42 |
|
43 |
|
44 |
def process_images(normal_image,mouth_open_image,eye_close_image,duration=100,pattern = "nnnmmmnenmmmnnnmmmnnnmmmnnnmmm",looping = True):
|
@@ -74,11 +94,6 @@ def process_images(normal_image,mouth_open_image,eye_close_image,duration=100,pa
|
|
74 |
else:
|
75 |
frames.append(normal_image)
|
76 |
|
77 |
-
#img = webp.load_image('00044063.webp', 'RGB')
|
78 |
-
#imgs = webp.load_images('00044063.webp', 'RGB',fps=10)#some how only fps10 load correctly?
|
79 |
-
#print(len(imgs))
|
80 |
-
|
81 |
-
#print(len(frames))
|
82 |
loop = 0 if looping else 1 #MUST BE ZERO,NOT TRUE
|
83 |
output_path = "tmp.webp"
|
84 |
output_buffer = io.BytesIO()
|
@@ -106,10 +121,11 @@ def show_example(value1,value2,valu3,id):
|
|
106 |
return f"webpes/{id}.webp"
|
107 |
|
108 |
#css=css,
|
109 |
-
|
110 |
-
with
|
111 |
with gr.Column():
|
112 |
gr.HTML(load_text("demo_header.html"))
|
|
|
113 |
with gr.Row():
|
114 |
with gr.Column():
|
115 |
image_normal = gr.Image(sources=['upload','clipboard'], elem_id="image_normal", type="pil", label="Normal Image",height=400, value=None)
|
@@ -131,26 +147,21 @@ with demo_blocks as demo:
|
|
131 |
btn.click(fn=process_images, inputs=[image_normal, image_mouth,image_eyes,animation_time,timing_seat,looping], outputs =image_out, api_name='infer')
|
132 |
gr.Examples(
|
133 |
examples=[
|
134 |
-
["
|
135 |
-
["
|
136 |
-
["
|
137 |
-
["
|
138 |
-
["
|
139 |
-
["
|
140 |
-
["
|
141 |
-
["
|
142 |
],
|
143 |
-
|
144 |
-
|
145 |
-
cache_examples=True,
|
146 |
)
|
147 |
gr.HTML(
|
148 |
-
|
149 |
-
<div style="text-align: center;">
|
150 |
-
<p>Test <a href="http://google.com" style="text-decoration: underline;" target="_blank">Google</a> - Gradio Demo by π€ Hugging Face
|
151 |
-
</p>
|
152 |
-
</div>
|
153 |
-
"""
|
154 |
)
|
155 |
|
156 |
-
|
|
|
|
8 |
import hashlib
|
9 |
import os
|
10 |
import time
|
11 |
+
import shutil
|
12 |
css="""
|
13 |
#col-left {
|
14 |
margin: 0 auto;
|
|
|
18 |
margin: 0 auto;
|
19 |
max-width: 640px;
|
20 |
}
|
21 |
+
.grid-container {
|
22 |
+
display: flex;
|
23 |
+
align-items: center;
|
24 |
+
justify-content: center;
|
25 |
+
gap:10px
|
26 |
+
}
|
27 |
+
|
28 |
+
.image {
|
29 |
+
width: 128px;
|
30 |
+
height: 128px;
|
31 |
+
object-fit: cover;
|
32 |
+
}
|
33 |
+
|
34 |
+
.text {
|
35 |
+
font-size: 16px;
|
36 |
+
}
|
37 |
"""
|
38 |
|
39 |
+
|
40 |
output_dir = "outputs"
|
41 |
+
passed_time = 60 * 10
|
42 |
def load_text(text_path: str) -> str:
|
43 |
with open(text_path, 'r', encoding='utf-8') as f:
|
44 |
text = f.read()
|
|
|
46 |
return text
|
47 |
|
48 |
def clear_old_files(dir,passed_time):
|
49 |
+
try:
|
50 |
+
files = os.listdir(dir)
|
51 |
+
current_time = time.time()
|
52 |
+
for file in files:
|
53 |
+
file_path = os.path.join(dir,file)
|
54 |
+
|
55 |
+
ctime = os.stat(file_path).st_ctime
|
56 |
+
diff = current_time - ctime
|
57 |
+
#print(f"ctime={ctime},current_time={current_time},passed_time={passed_time},diff={diff}")
|
58 |
+
if diff > passed_time:
|
59 |
+
os.remove(file_path)
|
60 |
+
except:
|
61 |
+
print("maybe still gallery using error")
|
62 |
|
63 |
|
64 |
def process_images(normal_image,mouth_open_image,eye_close_image,duration=100,pattern = "nnnmmmnenmmmnnnmmmnnnmmmnnnmmm",looping = True):
|
|
|
94 |
else:
|
95 |
frames.append(normal_image)
|
96 |
|
|
|
|
|
|
|
|
|
|
|
97 |
loop = 0 if looping else 1 #MUST BE ZERO,NOT TRUE
|
98 |
output_path = "tmp.webp"
|
99 |
output_buffer = io.BytesIO()
|
|
|
121 |
return f"webpes/{id}.webp"
|
122 |
|
123 |
#css=css,
|
124 |
+
|
125 |
+
with gr.Blocks(css=css, elem_id="demo-container") as demo:
|
126 |
with gr.Column():
|
127 |
gr.HTML(load_text("demo_header.html"))
|
128 |
+
gr.HTML(load_text("demo_tools.html"))
|
129 |
with gr.Row():
|
130 |
with gr.Column():
|
131 |
image_normal = gr.Image(sources=['upload','clipboard'], elem_id="image_normal", type="pil", label="Normal Image",height=400, value=None)
|
|
|
147 |
btn.click(fn=process_images, inputs=[image_normal, image_mouth,image_eyes,animation_time,timing_seat,looping], outputs =image_out, api_name='infer')
|
148 |
gr.Examples(
|
149 |
examples=[
|
150 |
+
["examples/00003245_normal.jpg","examples/00003245_mouth.jpg","examples/00003245_eyes.jpg","examples/00003245.webp"],
|
151 |
+
["examples/00207245_normal.png","examples/00207245_mouth.png","examples/00207245_eyes.png","examples/00207245.webp"],
|
152 |
+
["examples/00350245_normal.jpg","examples/00350245_mouth.jpg","examples/00350245_eyes.jpg","examples/00350245.webp"],
|
153 |
+
["examples/00538245_normal.jpg","examples/00538245_mouth.jpg","examples/00538245_eyes.jpg","examples/00538245.webp"],
|
154 |
+
["examples/00828003_00.jpg","examples/00828003_09.jpg","examples/00828003_99.jpg","examples/00828003.webp"],
|
155 |
+
["examples/00825000_00.jpg","examples/00825000_09.jpg","examples/00825000_99.jpg","examples/00825000.webp"],
|
156 |
+
["examples/00824008_00.jpg","examples/00824008_09.jpg","examples/00824008_99.jpg","examples/00824008.webp"],
|
157 |
+
["examples/prompt01_normal.jpg","examples/prompt01_mouth.jpg","examples/prompt01_eyes.jpg","examples/prompt01.webp"],
|
158 |
],
|
159 |
+
inputs=[image_normal,image_mouth,image_eyes,image_out],
|
160 |
+
|
|
|
161 |
)
|
162 |
gr.HTML(
|
163 |
+
gr.HTML(load_text("demo_footer.html"))
|
|
|
|
|
|
|
|
|
|
|
164 |
)
|
165 |
|
166 |
+
if __name__ == "__main__":
|
167 |
+
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
@@ -1,2 +1,18 @@
|
|
1 |
-
<
|
2 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div style="text-align: center;">
|
2 |
+
<h1>
|
3 |
+
WebP 3-Frame TalkingAnimation
|
4 |
+
</h1>
|
5 |
+
<div class="grid-container">
|
6 |
+
<img src="https://akjava.github.io/AIDiagramChatWithVoice-FaceCharacter/webp/128/00346245_09_00001200.webp" alt="Flux.1-schnell-WebP3Frame-TalkingAnimation" class="image">
|
7 |
+
<p class="text">
|
8 |
+
Create animation from 3 frame images<br>
|
9 |
+
Main create tool is not relaeased yet(mediapipe68-based and img2img-based)<br>
|
10 |
+
however you can create from prompt like eyes closed and open mouth.one of example is made by this way<br>
|
11 |
+
created webp can be resize and convert with tool.
|
12 |
+
</p>
|
13 |
+
</div>
|
14 |
+
</div>
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
<h1></h1>
|
demo_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>
|
{webpes β examples}/00002062.webp
RENAMED
File without changes
|
{imgs β examples}/00002062_00.jpg
RENAMED
File without changes
|
{imgs β examples}/00002062_09.jpg
RENAMED
File without changes
|
{imgs β examples}/00002062_99.jpg
RENAMED
File without changes
|
{webpes β examples}/00003245.webp
RENAMED
File without changes
|
{imgs β examples}/00003245_eyes.jpg
RENAMED
File without changes
|
{imgs β examples}/00003245_mouth.jpg
RENAMED
File without changes
|
{imgs β examples}/00003245_normal.jpg
RENAMED
File without changes
|
{webpes β examples}/00100265.webp
RENAMED
File without changes
|
{imgs β examples}/00100265_00.jpg
RENAMED
File without changes
|
{imgs β examples}/00100265_09.jpg
RENAMED
File without changes
|
{imgs β examples}/00100265_99.jpg
RENAMED
File without changes
|
{webpes β examples}/00207245.webp
RENAMED
File without changes
|
{imgs β examples}/00207245_eyes.png
RENAMED
File without changes
|
{imgs β examples}/00207245_mouth.png
RENAMED
File without changes
|
{imgs β examples}/00207245_normal.png
RENAMED
File without changes
|
{webpes β examples}/00350245.webp
RENAMED
File without changes
|
{imgs β examples}/00350245_eyes.jpg
RENAMED
File without changes
|
{imgs β examples}/00350245_mouth.jpg
RENAMED
File without changes
|
{imgs β examples}/00350245_normal.jpg
RENAMED
File without changes
|
{webpes β examples}/00538245.webp
RENAMED
File without changes
|
{imgs β examples}/00538245_eyes.jpg
RENAMED
File without changes
|
{imgs β examples}/00538245_mouth.jpg
RENAMED
File without changes
|
{imgs β examples}/00538245_normal.jpg
RENAMED
File without changes
|
{webpes β examples}/00824006.webp
RENAMED
File without changes
|
{imgs β examples}/00824006_00.jpg
RENAMED
File without changes
|
{imgs β examples}/00824006_09.jpg
RENAMED
File without changes
|
{imgs β examples}/00824006_99.jpg
RENAMED
File without changes
|
{webpes β examples}/00824008.webp
RENAMED
File without changes
|
{imgs β examples}/00824008_00.jpg
RENAMED
File without changes
|
{imgs β examples}/00824008_09.jpg
RENAMED
File without changes
|
{imgs β examples}/00824008_99.jpg
RENAMED
File without changes
|
{webpes β examples}/00825000.webp
RENAMED
File without changes
|
{imgs β examples}/00825000_00.jpg
RENAMED
File without changes
|
{imgs β examples}/00825000_09.jpg
RENAMED
File without changes
|
{imgs β examples}/00825000_99.jpg
RENAMED
File without changes
|
{webpes β examples}/00826004.webp
RENAMED
File without changes
|
{imgs β examples}/00826004_00.jpg
RENAMED
File without changes
|
{imgs β examples}/00826004_09.jpg
RENAMED
File without changes
|
{imgs β examples}/00826004_99.jpg
RENAMED
File without changes
|
{webpes β examples}/00826007.webp
RENAMED
File without changes
|
{imgs β examples}/00826007_00.jpg
RENAMED
File without changes
|
{imgs β examples}/00826007_09.jpg
RENAMED
File without changes
|
{imgs β examples}/00826007_99.jpg
RENAMED
File without changes
|
{webpes β examples}/00827009.webp
RENAMED
File without changes
|
{imgs β examples}/00827009_00.jpg
RENAMED
File without changes
|