diff --git a/app.py b/app.py index dab031fe75d7b127473cdd7b6ed56f154ced39a0..b69a80521da9f336d07fc479696b47f5f11d5003 100644 --- a/app.py +++ b/app.py @@ -8,6 +8,7 @@ import io import hashlib import os import time +import shutil css=""" #col-left { margin: 0 auto; @@ -17,10 +18,27 @@ css=""" margin: 0 auto; max-width: 640px; } +.grid-container { + display: flex; + align-items: center; + justify-content: center; + gap:10px +} + +.image { + width: 128px; + height: 128px; + object-fit: cover; +} + +.text { + font-size: 16px; +} """ + output_dir = "outputs" -passed_time = 60 #* 60 +passed_time = 60 * 10 def load_text(text_path: str) -> str: with open(text_path, 'r', encoding='utf-8') as f: text = f.read() @@ -28,17 +46,19 @@ def load_text(text_path: str) -> str: return text def clear_old_files(dir,passed_time): - files = os.listdir(dir) - current_time = time.time() - for file in files: - file_path = os.path.join(dir,file) - #print(os.stat(file_path)) - ctime = os.stat(file_path).st_ctime - diff = current_time - ctime - print(f"ctime={ctime},current_time={current_time},passed_time={passed_time},diff={diff}") - if diff > passed_time: - os.remove(file_path) - print(f"file removed {file_path}") + try: + files = os.listdir(dir) + current_time = time.time() + for file in files: + file_path = os.path.join(dir,file) + + ctime = os.stat(file_path).st_ctime + diff = current_time - ctime + #print(f"ctime={ctime},current_time={current_time},passed_time={passed_time},diff={diff}") + if diff > passed_time: + os.remove(file_path) + except: + print("maybe still gallery using error") 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 else: frames.append(normal_image) - #img = webp.load_image('00044063.webp', 'RGB') - #imgs = webp.load_images('00044063.webp', 'RGB',fps=10)#some how only fps10 load correctly? - #print(len(imgs)) - - #print(len(frames)) loop = 0 if looping else 1 #MUST BE ZERO,NOT TRUE output_path = "tmp.webp" output_buffer = io.BytesIO() @@ -106,10 +121,11 @@ def show_example(value1,value2,valu3,id): return f"webpes/{id}.webp" #css=css, -demo_blocks = gr.Blocks(css=css, elem_id="demo-container") -with demo_blocks as demo: + +with gr.Blocks(css=css, elem_id="demo-container") as demo: with gr.Column(): gr.HTML(load_text("demo_header.html")) + gr.HTML(load_text("demo_tools.html")) with gr.Row(): with gr.Column(): 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: btn.click(fn=process_images, inputs=[image_normal, image_mouth,image_eyes,animation_time,timing_seat,looping], outputs =image_out, api_name='infer') gr.Examples( examples=[ - ["imgs/00003245_normal.jpg","imgs/00003245_mouth.jpg","imgs/00003245_eyes.jpg","00003245"], - ["imgs/00207245_normal.png","imgs/00207245_mouth.png","imgs/00207245_eyes.png","00207245"], - ["imgs/00350245_normal.jpg","imgs/00350245_mouth.jpg","imgs/00350245_eyes.jpg","00350245"], - ["imgs/00538245_normal.jpg","imgs/00538245_mouth.jpg","imgs/00538245_eyes.jpg","00538245"], - ["imgs/00828003_00.jpg","imgs/00828003_09.jpg","imgs/00828003_99.jpg","00828003"], - ["imgs/00825000_00.jpg","imgs/00825000_09.jpg","imgs/00825000_99.jpg","00825000"], - ["imgs/00824008_00.jpg","imgs/00824008_09.jpg","imgs/00824008_99.jpg","00824008"], - ["imgs/prompt01_normal.jpg","imgs/prompt01_mouth.jpg","imgs/prompt01_eyes.jpg","prompt01"], + ["examples/00003245_normal.jpg","examples/00003245_mouth.jpg","examples/00003245_eyes.jpg","examples/00003245.webp"], + ["examples/00207245_normal.png","examples/00207245_mouth.png","examples/00207245_eyes.png","examples/00207245.webp"], + ["examples/00350245_normal.jpg","examples/00350245_mouth.jpg","examples/00350245_eyes.jpg","examples/00350245.webp"], + ["examples/00538245_normal.jpg","examples/00538245_mouth.jpg","examples/00538245_eyes.jpg","examples/00538245.webp"], + ["examples/00828003_00.jpg","examples/00828003_09.jpg","examples/00828003_99.jpg","examples/00828003.webp"], + ["examples/00825000_00.jpg","examples/00825000_09.jpg","examples/00825000_99.jpg","examples/00825000.webp"], + ["examples/00824008_00.jpg","examples/00824008_09.jpg","examples/00824008_99.jpg","examples/00824008.webp"], + ["examples/prompt01_normal.jpg","examples/prompt01_mouth.jpg","examples/prompt01_eyes.jpg","examples/prompt01.webp"], ], - fn=show_example, - inputs=[image_normal,image_mouth,image_eyes,id_input],outputs=[image_out], - cache_examples=True, + inputs=[image_normal,image_mouth,image_eyes,image_out], + ) gr.HTML( - """ -
-

Test Google - Gradio Demo by 🤗 Hugging Face -

-
- """ + gr.HTML(load_text("demo_footer.html")) ) -demo_blocks.queue(max_size=25).launch()#share=True \ No newline at end of file + if __name__ == "__main__": + demo.launch() \ No newline at end of file diff --git a/demo_footer.html b/demo_footer.html new file mode 100644 index 0000000000000000000000000000000000000000..18fa5a3fd35b808f80817788fcf3bed61d4cb1e4 --- /dev/null +++ b/demo_footer.html @@ -0,0 +1,3 @@ +
+

Images are generated with FLUX.1-schnell and licensed under the Apache 2.0 License +

\ No newline at end of file diff --git a/demo_header.html b/demo_header.html index 84c3ea01349a4908a652a01f40b940678cb6d66a..11b5eb52a8c6ca2b1ae81c8676b173edd06ae80f 100644 --- a/demo_header.html +++ b/demo_header.html @@ -1,2 +1,18 @@ -

WebP 3-Frame TalkingAnimation

-

This is Character Face part of AI Diagram Chat with Voice/Face Character

\ No newline at end of file +
+

+ WebP 3-Frame TalkingAnimation +

+
+ Flux.1-schnell-WebP3Frame-TalkingAnimation +

+ Create animation from 3 frame images
+ Main create tool is not relaeased yet(mediapipe68-based and img2img-based)
+ however you can create from prompt like eyes closed and open mouth.one of example is made by this way
+ created webp can be resize and convert with tool. +

+
+
+ + + +

diff --git a/demo_tools.html b/demo_tools.html new file mode 100644 index 0000000000000000000000000000000000000000..7a907d4ed89cf6557c0d313232209850d4ace538 --- /dev/null +++ b/demo_tools.html @@ -0,0 +1,10 @@ +
+

AI Diagram Chat with Voice/Face Character Making Tools

+

[WebP-3F-TH] + [Flux1-Img2Img(GPU)] + [Flux1-Inpaint(GPU)] + [OpenCV-Inapint] + [Whitebalance] + [Paste Image] + [WebP Resize Convert]

+
diff --git a/webpes/00002062.webp b/examples/00002062.webp similarity index 100% rename from webpes/00002062.webp rename to examples/00002062.webp diff --git a/imgs/00002062_00.jpg b/examples/00002062_00.jpg similarity index 100% rename from imgs/00002062_00.jpg rename to examples/00002062_00.jpg diff --git a/imgs/00002062_09.jpg b/examples/00002062_09.jpg similarity index 100% rename from imgs/00002062_09.jpg rename to examples/00002062_09.jpg diff --git a/imgs/00002062_99.jpg b/examples/00002062_99.jpg similarity index 100% rename from imgs/00002062_99.jpg rename to examples/00002062_99.jpg diff --git a/webpes/00003245.webp b/examples/00003245.webp similarity index 100% rename from webpes/00003245.webp rename to examples/00003245.webp diff --git a/imgs/00003245_eyes.jpg b/examples/00003245_eyes.jpg similarity index 100% rename from imgs/00003245_eyes.jpg rename to examples/00003245_eyes.jpg diff --git a/imgs/00003245_mouth.jpg b/examples/00003245_mouth.jpg similarity index 100% rename from imgs/00003245_mouth.jpg rename to examples/00003245_mouth.jpg diff --git a/imgs/00003245_normal.jpg b/examples/00003245_normal.jpg similarity index 100% rename from imgs/00003245_normal.jpg rename to examples/00003245_normal.jpg diff --git a/webpes/00100265.webp b/examples/00100265.webp similarity index 100% rename from webpes/00100265.webp rename to examples/00100265.webp diff --git a/imgs/00100265_00.jpg b/examples/00100265_00.jpg similarity index 100% rename from imgs/00100265_00.jpg rename to examples/00100265_00.jpg diff --git a/imgs/00100265_09.jpg b/examples/00100265_09.jpg similarity index 100% rename from imgs/00100265_09.jpg rename to examples/00100265_09.jpg diff --git a/imgs/00100265_99.jpg b/examples/00100265_99.jpg similarity index 100% rename from imgs/00100265_99.jpg rename to examples/00100265_99.jpg diff --git a/webpes/00207245.webp b/examples/00207245.webp similarity index 100% rename from webpes/00207245.webp rename to examples/00207245.webp diff --git a/imgs/00207245_eyes.png b/examples/00207245_eyes.png similarity index 100% rename from imgs/00207245_eyes.png rename to examples/00207245_eyes.png diff --git a/imgs/00207245_mouth.png b/examples/00207245_mouth.png similarity index 100% rename from imgs/00207245_mouth.png rename to examples/00207245_mouth.png diff --git a/imgs/00207245_normal.png b/examples/00207245_normal.png similarity index 100% rename from imgs/00207245_normal.png rename to examples/00207245_normal.png diff --git a/webpes/00350245.webp b/examples/00350245.webp similarity index 100% rename from webpes/00350245.webp rename to examples/00350245.webp diff --git a/imgs/00350245_eyes.jpg b/examples/00350245_eyes.jpg similarity index 100% rename from imgs/00350245_eyes.jpg rename to examples/00350245_eyes.jpg diff --git a/imgs/00350245_mouth.jpg b/examples/00350245_mouth.jpg similarity index 100% rename from imgs/00350245_mouth.jpg rename to examples/00350245_mouth.jpg diff --git a/imgs/00350245_normal.jpg b/examples/00350245_normal.jpg similarity index 100% rename from imgs/00350245_normal.jpg rename to examples/00350245_normal.jpg diff --git a/webpes/00538245.webp b/examples/00538245.webp similarity index 100% rename from webpes/00538245.webp rename to examples/00538245.webp diff --git a/imgs/00538245_eyes.jpg b/examples/00538245_eyes.jpg similarity index 100% rename from imgs/00538245_eyes.jpg rename to examples/00538245_eyes.jpg diff --git a/imgs/00538245_mouth.jpg b/examples/00538245_mouth.jpg similarity index 100% rename from imgs/00538245_mouth.jpg rename to examples/00538245_mouth.jpg diff --git a/imgs/00538245_normal.jpg b/examples/00538245_normal.jpg similarity index 100% rename from imgs/00538245_normal.jpg rename to examples/00538245_normal.jpg diff --git a/webpes/00824006.webp b/examples/00824006.webp similarity index 100% rename from webpes/00824006.webp rename to examples/00824006.webp diff --git a/imgs/00824006_00.jpg b/examples/00824006_00.jpg similarity index 100% rename from imgs/00824006_00.jpg rename to examples/00824006_00.jpg diff --git a/imgs/00824006_09.jpg b/examples/00824006_09.jpg similarity index 100% rename from imgs/00824006_09.jpg rename to examples/00824006_09.jpg diff --git a/imgs/00824006_99.jpg b/examples/00824006_99.jpg similarity index 100% rename from imgs/00824006_99.jpg rename to examples/00824006_99.jpg diff --git a/webpes/00824008.webp b/examples/00824008.webp similarity index 100% rename from webpes/00824008.webp rename to examples/00824008.webp diff --git a/imgs/00824008_00.jpg b/examples/00824008_00.jpg similarity index 100% rename from imgs/00824008_00.jpg rename to examples/00824008_00.jpg diff --git a/imgs/00824008_09.jpg b/examples/00824008_09.jpg similarity index 100% rename from imgs/00824008_09.jpg rename to examples/00824008_09.jpg diff --git a/imgs/00824008_99.jpg b/examples/00824008_99.jpg similarity index 100% rename from imgs/00824008_99.jpg rename to examples/00824008_99.jpg diff --git a/webpes/00825000.webp b/examples/00825000.webp similarity index 100% rename from webpes/00825000.webp rename to examples/00825000.webp diff --git a/imgs/00825000_00.jpg b/examples/00825000_00.jpg similarity index 100% rename from imgs/00825000_00.jpg rename to examples/00825000_00.jpg diff --git a/imgs/00825000_09.jpg b/examples/00825000_09.jpg similarity index 100% rename from imgs/00825000_09.jpg rename to examples/00825000_09.jpg diff --git a/imgs/00825000_99.jpg b/examples/00825000_99.jpg similarity index 100% rename from imgs/00825000_99.jpg rename to examples/00825000_99.jpg diff --git a/webpes/00826004.webp b/examples/00826004.webp similarity index 100% rename from webpes/00826004.webp rename to examples/00826004.webp diff --git a/imgs/00826004_00.jpg b/examples/00826004_00.jpg similarity index 100% rename from imgs/00826004_00.jpg rename to examples/00826004_00.jpg diff --git a/imgs/00826004_09.jpg b/examples/00826004_09.jpg similarity index 100% rename from imgs/00826004_09.jpg rename to examples/00826004_09.jpg diff --git a/imgs/00826004_99.jpg b/examples/00826004_99.jpg similarity index 100% rename from imgs/00826004_99.jpg rename to examples/00826004_99.jpg diff --git a/webpes/00826007.webp b/examples/00826007.webp similarity index 100% rename from webpes/00826007.webp rename to examples/00826007.webp diff --git a/imgs/00826007_00.jpg b/examples/00826007_00.jpg similarity index 100% rename from imgs/00826007_00.jpg rename to examples/00826007_00.jpg diff --git a/imgs/00826007_09.jpg b/examples/00826007_09.jpg similarity index 100% rename from imgs/00826007_09.jpg rename to examples/00826007_09.jpg diff --git a/imgs/00826007_99.jpg b/examples/00826007_99.jpg similarity index 100% rename from imgs/00826007_99.jpg rename to examples/00826007_99.jpg diff --git a/webpes/00827009.webp b/examples/00827009.webp similarity index 100% rename from webpes/00827009.webp rename to examples/00827009.webp diff --git a/imgs/00827009_00.jpg b/examples/00827009_00.jpg similarity index 100% rename from imgs/00827009_00.jpg rename to examples/00827009_00.jpg diff --git a/imgs/00827009_09.jpg b/examples/00827009_09.jpg similarity index 100% rename from imgs/00827009_09.jpg rename to examples/00827009_09.jpg diff --git a/imgs/00827009_99.jpg b/examples/00827009_99.jpg similarity index 100% rename from imgs/00827009_99.jpg rename to examples/00827009_99.jpg diff --git a/webpes/00828003.webp b/examples/00828003.webp similarity index 100% rename from webpes/00828003.webp rename to examples/00828003.webp diff --git a/imgs/00828003_00.jpg b/examples/00828003_00.jpg similarity index 100% rename from imgs/00828003_00.jpg rename to examples/00828003_00.jpg diff --git a/imgs/00828003_09.jpg b/examples/00828003_09.jpg similarity index 100% rename from imgs/00828003_09.jpg rename to examples/00828003_09.jpg diff --git a/imgs/00828003_99.jpg b/examples/00828003_99.jpg similarity index 100% rename from imgs/00828003_99.jpg rename to examples/00828003_99.jpg diff --git a/webpes/prompt01.webp b/examples/prompt01.webp similarity index 100% rename from webpes/prompt01.webp rename to examples/prompt01.webp diff --git a/imgs/prompt01_eyes.jpg b/examples/prompt01_eyes.jpg similarity index 100% rename from imgs/prompt01_eyes.jpg rename to examples/prompt01_eyes.jpg diff --git a/imgs/prompt01_mouth.jpg b/examples/prompt01_mouth.jpg similarity index 100% rename from imgs/prompt01_mouth.jpg rename to examples/prompt01_mouth.jpg diff --git a/imgs/prompt01_normal.jpg b/examples/prompt01_normal.jpg similarity index 100% rename from imgs/prompt01_normal.jpg rename to examples/prompt01_normal.jpg diff --git a/make_demo.py b/make_demo.py deleted file mode 100644 index 6b73743338c53513cfde150daf4dc399e9f74147..0000000000000000000000000000000000000000 --- a/make_demo.py +++ /dev/null @@ -1,14 +0,0 @@ - -import os - -def to_text(id): - template = f"""["imgs/{id}_00.jpg","imgs/{id}_09.jpg","imgs/{id}_99.jpg","{id}"],""" - return template - -files = os.listdir("webpes") -for file in files: - if file.endswith(".webp"): - base,ext = os.path.splitext(file) - print(to_text(base.strip())) - -