Fix dependency issues and add some updates
#10
by hysts HF Staff - opened
Files changed (3)
- README.md+1-1
- app.py+32-43
- requirements.txt+76-25
3 unmodified lines4567789103 unmodified linescolorFrom: indigocolorTo: indigosdk: gradiosdk_version: 3.0.19sdk_version: 3.48.0app_file: app.pypinned: false---1132345667791011128910111213141516171824 unmodified lines434445434446474849464750515253545556495051525354555657585960606162637 unmodified lines7172737474757677787977787980813 unmodified lines85868789888990919394959293949596999798991001 unmodified line1021031041071051061071081 unmodified line110111112115116117118119120121122113114123124125115116128117import gradio as grimport osimport shutilimport pathlib
import gradio as grimport torchfrom PIL import Imageimport argparseimport pathlib
os.system("git clone https://github.com/yoyo-nb/Thin-Plate-Spline-Motion-Model")os.chdir("Thin-Plate-Spline-Motion-Model")os.system("mkdir checkpoints")os.system("gdown 1-CKOjv_y_TzNe-dwQsjjeVxJUuyBAb5X -O checkpoints/vox.pth.tar")repo_dir = pathlib.Path("Thin-Plate-Spline-Motion-Model").absolute()if not repo_dir.exists(): os.system("git clone https://github.com/yoyo-nb/Thin-Plate-Spline-Motion-Model")os.chdir(repo_dir.name)if not (repo_dir / "checkpoints").exists(): os.system("mkdir checkpoints")if not (repo_dir / "checkpoints/vox.pth.tar").exists(): os.system("gdown 1-CKOjv_y_TzNe-dwQsjjeVxJUuyBAb5X -O checkpoints/vox.pth.tar")
24 unmodified lines return gr.Markdown.update(value=text)
def set_example_image(example: list) -> dict: return gr.Image.update(value=example[0])def inference(img, vid): if not os.path.exists('temp'): os.system('mkdir temp')
def set_example_video(example: list) -> dict: return gr.Video.update(value=example[0]) img.save("temp/image.jpg", "JPEG") if torch.cuda.is_available(): os.system(f"python demo.py --config config/vox-256.yaml --checkpoint ./checkpoints/vox.pth.tar --source_image 'temp/image.jpg' --driving_video {vid} --result_video './temp/result.mp4'") else: os.system(f"python demo.py --config config/vox-256.yaml --checkpoint ./checkpoints/vox.pth.tar --source_image 'temp/image.jpg' --driving_video {vid} --result_video './temp/result.mp4' --cpu") return './temp/result.mp4'
def inference(img,vid): if not os.path.exists('temp'): os.system('mkdir temp') img.save("temp/image.jpg", "JPEG") os.system(f"python demo.py --config config/vox-256.yaml --checkpoint ./checkpoints/vox.pth.tar --source_image 'temp/image.jpg' --driving_video {vid} --result_video './temp/result.mp4' --cpu") return './temp/result.mp4'
def main(): with gr.Blocks(theme="huggingface", css='style.css') as demo: with gr.Blocks(css='style.css') as demo: gr.Markdown(title) gr.Markdown(DESCRIPTION)
7 unmodified lines with gr.Row(): input_image = gr.Image(label='Input Image', type="pil")
with gr.Row(): paths = sorted(pathlib.Path('assets').glob('*.png')) example_images = gr.Dataset(components=[input_image], samples=[[path.as_posix()] for path in paths]) gr.Examples(inputs=[input_image], examples=[[path.as_posix()] for path in paths])
with gr.Box(): gr.Markdown('''## Step 2 (Select Driving Video)3 unmodified lines with gr.Column(): with gr.Row(): driving_video = gr.Video(label='Driving Video', format="mp4") format="mp4")
with gr.Row(): paths = sorted(pathlib.Path('assets').glob('*.mp4')) example_video = gr.Dataset(components=[driving_video], samples=[[path.as_posix()] for path in paths]) gr.Examples(inputs=[driving_video], examples=[[path.as_posix()] for path in paths])
with gr.Box(): gr.Markdown('''## Step 3 (Generate Animated Image based on the Video)- Hit the **Generate** button. (Note: As it runs on the CPU, it takes ~ 3 minutes to generate final results.)- Hit the **Generate** button. (Note: On cpu-basic, it takes ~ 10 minutes to generate final results.)''') with gr.Row(): with gr.Column():1 unmodified line generate_button = gr.Button('Generate')
with gr.Column(): result = gr.Video(type="file", label="Output") result = gr.Video(label="Output") gr.Markdown(FOOTER) generate_button.click(fn=inference, inputs=[1 unmodified line driving_video ], outputs=result) example_images.click(fn=set_example_image, inputs=example_images, outputs=example_images.components) example_video.click(fn=set_example_video, inputs=example_video, outputs=example_video.components)
demo.launch(
demo.queue(max_size=10).launch() enable_queue=True, debug=True )
if __name__ == '__main__': main() main()12345678910111213141234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950511617181920215253545556575859606162232425262763646566676869707172737475767778cffi==1.14.6cycler==0.10.0decorator==5.1.0face-alignment==1.3.5imageio==2.9.0imageio-ffmpeg==0.4.5kiwisolver==1.3.2matplotlib==3.4.3networkx==2.6.3numpy==1.20.3pandas==1.3.3Pillowpycparser==2.20pyparsing==2.4.7aiofiles==23.2.1altair==5.1.2annotated-types==0.6.0anyio==3.7.1attrs==23.1.0beautifulsoup4==4.12.2certifi==2023.7.22charset-normalizer==3.3.0click==8.1.7cmake==3.27.7contourpy==1.1.1cycler==0.12.1exceptiongroup==1.1.3fastapi==0.103.2ffmpy==0.3.1filelock==3.12.4fonttools==4.43.1fsspec==2023.9.2gdown==4.7.1gradio==3.48.0gradio_client==0.6.1h11==0.14.0httpcore==0.18.0httpx==0.25.0huggingface-hub==0.18.0idna==3.4imageio==2.31.5imageio-ffmpeg==0.4.9importlib-resources==6.1.0Jinja2==3.1.2jsonschema==4.19.1jsonschema-specifications==2023.7.1kiwisolver==1.4.5lazy_loader==0.3lit==17.0.3MarkupSafe==2.1.3matplotlib==3.8.0mpmath==1.3.0networkx==3.1numpy==1.25.2orjson==3.9.9packaging==23.2pandas==2.1.1Pillow==10.1.0psutil==5.9.6pydantic==2.4.2pydantic_core==2.10.1pydub==0.25.1pyparsing==3.1.1PySocks==1.7.1python-dateutil==2.8.2pytz==2021.1PyWavelets==1.1.1PyYAMLscikit-imagescikit-learnscipypython-multipart==0.0.6pytz==2023.3.post1PyYAML==6.0.1referencing==0.30.2requests==2.31.0rpds-py==0.10.6scikit-image==0.22.0scipy==1.11.3semantic-version==2.10.0setuptools-scm==8.0.4six==1.16.0torch==1.11.0torchvision==0.12.0tqdm==4.62.3gradiogdownsniffio==1.3.0soupsieve==2.5starlette==0.27.0sympy==1.12tifffile==2023.9.26tomli==2.0.1toolz==0.12.0torch==2.0.0torchvision==0.15.1tqdm==4.66.1triton==2.0.0typing_extensions==4.8.0tzdata==2023.3urllib3==2.0.7uvicorn==0.23.2websockets==11.0.3README.md+1-1
app.py+32-43
requirements.txt+76-25