Spaces:
Paused
Paused
Update app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435import spacesimport gradio as grimport sysimport osimport subprocessimport uuidimport shutilfrom huggingface_hub import snapshot_download, list_repo_files, hf_hub_downloadimport importlib, site# Re-discover all .pth/.egg-link filesfor sitedir in site.getsitepackages():site.addsitedir(sitedir)# Clear caches so importlib will pick up new modulesimportlib.invalidate_caches()def sh(cmd): subprocess.check_call(cmd, shell=True)flash_attention_installed = Falsetry:flash_attention_wheel = hf_hub_download(repo_id="alexnasa/flash-attn-3",repo_type="model",filename="128/flash_attn_3-3.0.0b1-cp39-abi3-linux_x86_64.whl",)sh(f"pip install {flash_attention_wheel}")print("Attempting to download and install FlashAttention wheel...")# sh("pip install flash-attn")sh("pip install --no-build-isolation transformer_engine-2.5.0+f05f12c9-cp310-cp310-linux_x86_64.whl")# tell Python to re-scan site-packages now that the egg-link existsimport importlib, site; site.addsitedir(site.getsitepackages()[0]); importlib.invalidate_caches()flash_attention_installed = Trueexcept Exception as e:print(f"⚠️ Could not install FlashAttention: {e}")print("Continuing without FlashAttention...")try:te_wheel = hf_hub_download(repo_id="alexnasa/transformer_engine_wheels",repo_type="model",filename="transformer_engine-2.5.0+f05f12c9-cp310-cp310-linux_x86_64.whl",)sh(f"pip install {te_wheel}")print("Attempting to download and install Transformer Engine wheel...")# tell Python to re-scan site-packages now that the egg-link existsimport importlib, site; site.addsitedir(site.getsitepackages()[0]); importlib.invalidate_caches()except Exception as e:print(f"⚠️ Could not install Transformer Engine : {e}")print("Continuing without Transformer Engine ...")import torchprint(f"Torch version: {torch.__version__}")print(f"FlashAttention available: {flash_attention_installed}")import tempfilefrom pathlib import Pathfrom torch._inductor.runtime.runtime_utils import cache_dir as _inductor_cache_dirfrom huggingface_hub import HfApisnapshot_download(repo_id="bytedance-research/HuMo", local_dir="./weights/HuMo")snapshot_download(repo_id="Wan-AI/Wan2.1-T2V-1.3B", local_dir="./weights/Wan2.1-T2V-1.3B")snapshot_download(repo_id="openai/whisper-large-v3", local_dir="./weights/whisper-large-v3")os.environ["PROCESSED_RESULTS"] = f"{os.getcwd()}/proprocess_results"path_to_insert = "humo"if path_to_insert not in sys.path:sys.path.insert(0, path_to_insert)from common.config import load_config, create_objectconfig = load_config("./humo/configs/inference/generate.yaml",["dit.sp_size=1","generation.frames=97","generation.scale_t=5.5","generation.scale_a=5.0","generation.mode=TIA","generation.height=480","generation.width=832",],)runner = create_object(config)os.environ.setdefault("TORCHINDUCTOR_CACHE_DIR", f"{os.getcwd()}/torchinductor_space") # or another writable pathdef restore_inductor_cache_from_hub(repo_id: str, filename: str = "torch_compile_cache.zip",path_in_repo: str = "inductor_cache", repo_type: str = "model",hf_token: str | None = None):cache_root = Path(_inductor_cache_dir()).resolve()cache_root.mkdir(parents=True, exist_ok=True)zip_path = hf_hub_download(repo_id=repo_id, filename=f"{path_in_repo}/{filename}",repo_type=repo_type, token=hf_token)shutil.unpack_archive(zip_path, extract_dir=str(cache_root))print(f"✓ Restored cache into {cache_root}")# restore_inductor_cache_from_hub("alexnasa/humo-compiled")def get_duration(prompt_text, steps, image_file, audio_file_path, tea_cache_l1_thresh, max_duration, session_id):return calculate_required_time(steps, max_duration)def calculate_required_time(steps, max_duration):warmup_s = 60max_duration_duration_mapping = {1: 8,2: 8,3: 11,4: 20,5: 30,}each_step_s = max_duration_duration_mapping[max_duration]duration_s = (each_step_s * steps) + warmup_sprint(f'estimated duration:{duration_s}')return int(duration_s)def get_required_time_string(steps, max_duration):duration_s = calculate_required_time(steps, max_duration)duration_m = duration_s / 60return f"<center>⌚ Zero GPU Required: ~{duration_s}.0s ({duration_m:.1f} mins)</center>"def update_required_time(steps, max_duration):return get_required_time_string(steps, max_duration)def generate_scene(prompt_text, steps, image_paths, audio_file_path, tea_cache_l1_thresh, max_duration = 2, session_id = None):print(image_paths)prompt_text_check = (prompt_text or "").strip()if not prompt_text_check:raise gr.Error("Please enter a prompt.")if not audio_file_path and not image_paths:raise gr.Error("Please provide a reference image or a lipsync audio.")return run_pipeline(prompt_text, steps, image_paths, audio_file_path, tea_cache_l1_thresh, max_duration, session_id)def upload_inductor_cache_to_hub(repo_id: str,path_in_repo: str = "inductor_cache",repo_type: str = "model", # or "dataset" if you preferhf_token: str | None = None,):"""Zips the current TorchInductor cache and uploads it to the given repo path.Assumes the model was already run once with torch.compile() so the cache exists."""cache_dir = Path(_inductor_cache_dir()).resolve()if not cache_dir.exists():raise FileNotFoundError(f"TorchInductor cache not found at {cache_dir}. ""Run a compiled model once to populate it.")# Create a zip archive of the entire cache directorywith tempfile.TemporaryDirectory() as tmpdir:archive_base = Path(tmpdir) / "torch_compile_cache"archive_path = shutil.make_archive(str(archive_base), "zip", root_dir=str(cache_dir))archive_path = Path(archive_path)# Upload to Hubapi = HfApi(token=hf_token)api.create_repo(repo_id=repo_id, repo_type=repo_type, exist_ok=True)# Put each artifact under path_in_repo, including a tiny metadata stamp for traceability# Upload the zipdest_path = f"{path_in_repo}/{archive_path.name}"api.upload_file(path_or_fileobj=str(archive_path),path_in_repo=dest_path,repo_id=repo_id,repo_type=repo_type,)# Upload a small metadata file (optional but handy)meta_txt = (f"pytorch={torch.__version__}\n"f"inductor_cache_dir={cache_dir}\n"f"cuda_available={torch.cuda.is_available()}\n"f"cuda_device={torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'cpu'}\n")api.upload_file(path_or_fileobj=meta_txt.encode(),path_in_repo=f"{path_in_repo}/INDUCTOR_CACHE_METADATA.txt",repo_id=repo_id,repo_type=repo_type,)print("✔ Uploaded TorchInductor cache to the Hub.")@spaces.GPU(duration=get_duration)def run_pipeline(prompt_text, steps, image_paths, audio_file_path, tea_cache_l1_thresh = 0.0, max_duration = 2, session_id = None):if session_id is None:session_id = uuid.uuid4().hexinference_mode = "TIA"# Validate inputsprompt_text = (prompt_text or "").strip()if not prompt_text:raise gr.Error("Please enter a prompt.")if not audio_file_path and not image_paths:raise gr.Error("Please provide a reference image or a lipsync audio.")if not audio_file_path:inference_mode = "TI"audio_path = Noneelse:audio_path = audio_file_path if isinstance(audio_file_path, str) else getattr(audio_file_path, "name", str(audio_file_path))if not image_paths:inference_mode = "TA"img_paths = Noneelse:img_paths = [image_data[0] for image_data in image_paths]# Prepare outputoutput_dir = os.path.join(os.environ["PROCESSED_RESULTS"], session_id)os.makedirs(output_dir, exist_ok=True)# Random filenamefilename = f"gen_{uuid.uuid4().hex[:10]}"width, height = 832, 480duration_frame_mapping = {1:25,2:45,3:70,4:97,5:129}# Run inferencerunner.inference_loop(prompt_text,img_paths,audio_path,output_dir,filename,inference_mode,width,height,steps,frames = int(duration_frame_mapping[max_duration]),tea_cache_l1_thresh = tea_cache_l1_thresh,)# Return resulting video pathvideo_path = os.path.join(output_dir, f"{filename}.mp4")if os.path.exists(video_path):# upload_inductor_cache_to_hub("alexnasa/humo-compiled")return video_pathelse:candidates = [os.path.join(output_dir, f) for f in os.listdir(output_dir) if f.endswith(".mp4")]if candidates:return max(candidates, key=lambda p: os.path.getmtime(p))return Nonecss = """#col-container {margin: 0 auto;width: 100%;max-width: 720px;}"""def cleanup(request: gr.Request):sid = request.session_hashif sid:d1 = os.path.join(os.environ["PROCESSED_RESULTS"], sid)shutil.rmtree(d1, ignore_errors=True)def start_session(request: gr.Request):return request.session_hashwith gr.Blocks(css=css) as demo:session_state = gr.State()demo.load(start_session, outputs=[session_state])with gr.Sidebar(width=400):gr.HTML("""<div style="text-align: center;"><p style="font-size:16px; display: inline; margin: 0;"><strong>HuMo</strong> – Human-Centric Video Generation via Collaborative Multi-Modal Conditioning</p><a href="https://github.com/Phantom-video/HuMo" style="display: inline-block; vertical-align: middle; margin-left: 0.5em;">[Github]</a></div>""")gr.Markdown("**REFERENCE IMAGES**")img_input = gr.Gallery(show_label=False,label="",interactive=True,rows=1, columns=3, object_fit="contain", height="280",file_types=['image'])gr.Markdown("**LIPSYNC AUDIO**")audio_input = gr.Audio(sources=["upload"],show_label=False,type="filepath",)gr.Markdown("**SETTINGS**")default_steps = 10default_max_duration = 2max_duration = gr.Slider(minimum=2, maximum=5, value=default_max_duration, step=1, label="Max Duration")steps_input = gr.Slider(minimum=5, maximum=50, value=default_steps, step=5, label="Diffusion Steps")tea_cache_l1_thresh = gr.Slider(minimum=0.0, maximum=1.0, value=0.0, step=0.01, label="Cache", visible=False)with gr.Column(elem_id="col-container"):gr.HTML("""<div style="text-align: center;"><strong>HF Space by:</strong><a href="https://twitter.com/alexandernasa/" style="display: inline-block; vertical-align: middle; margin-left: 0.5em;"><img src="https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow Me" alt="GitHub Repo"></a></div>""")video_output = gr.Video(show_label=False)gr.Markdown("<center><h2>PROMPT</h2></center>")prompt_tb = gr.Textbox(show_label=False,lines=5,placeholder="Describe the scene and the person talking....",)gr.Markdown("")time_required = gr.Markdown(get_required_time_string(default_steps, default_max_duration))run_btn = gr.Button("🎬 Action", variant="primary")gr.Examples(examples=[["A handheld tracking shot follows a female warrior walking through a cave. Her determined eyes are locked straight ahead. She speaks with intensity.",5,["./examples/naomi.png"],"./examples/dream.mp3",],["A reddish-brown haired and bearded man sits pensively against swirling blue-and-white brushstrokes, dressed in a blue coat and dark waistcoat. The artistic backdrop and his thoughtful pose evoke a Post-Impressionist style in a studio-like setting.",10,["./examples/vangogh.jpg"],"./examples/art.wav",],["A handheld tracking shot follows a female through a science lab. Her determined eyes are locked straight ahead. The clip is in black and white and patchy as she is explaining something to someone standing opposite her",10,["./examples/naomi.png"],"./examples/science.wav",],["A woman with long, wavy dark hair looking at a person sitting opposite her whilst holding a book, wearing a leather jacket, long-sleeved jacket with a semi purple color one seen on a photo. Warm, window-like light bathes her figure, highlighting the outfit's elegant design and her graceful movements.",50,["./examples/amber.png", "./examples/jacket.png"],"./examples/fictional.mp3",],],inputs=[prompt_tb, steps_input, img_input, audio_input],outputs=[video_output],fn=run_pipeline,cache_examples=True,)max_duration.change(update_required_time, [steps_input, max_duration], time_required)steps_input.change(update_required_time, [steps_input, max_duration], time_required)run_btn.click(fn=generate_scene,inputs=[prompt_tb, steps_input, img_input, audio_input, tea_cache_l1_thresh, max_duration, session_state],outputs=[video_output],)if __name__ == "__main__":demo.unload(cleanup)demo.queue()demo.launch(ssr_mode=False)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435import spacesimport gradio as grimport sysimport osimport subprocessimport uuidimport shutilfrom huggingface_hub import snapshot_download, list_repo_files, hf_hub_downloadimport importlib, site# Re-discover all .pth/.egg-link filesfor sitedir in site.getsitepackages():site.addsitedir(sitedir)# Clear caches so importlib will pick up new modulesimportlib.invalidate_caches()def sh(cmd): subprocess.check_call(cmd, shell=True)flash_attention_installed = Falsetry:flash_attention_wheel = hf_hub_download(repo_id="alexnasa/flash-attn-3",repo_type="model",filename="128/flash_attn_3-3.0.0b1-cp39-abi3-linux_x86_64.whl",)sh(f"pip install {flash_attention_wheel}")print("Attempting to download and install FlashAttention wheel...")# sh("pip install flash-attn")sh("pip install --no-build-isolation transformer_engine-2.5.0+f05f12c9-cp310-cp310-linux_x86_64.whl")# tell Python to re-scan site-packages now that the egg-link existsimport importlib, site; site.addsitedir(site.getsitepackages()[0]); importlib.invalidate_caches()flash_attention_installed = Trueexcept Exception as e:print(f"⚠️ Could not install FlashAttention: {e}")print("Continuing without FlashAttention...")try:te_wheel = hf_hub_download(repo_id="alexnasa/transformer_engine_wheels",repo_type="model",filename="transformer_engine-2.5.0+f05f12c9-cp310-cp310-linux_x86_64.whl",)sh(f"pip install {te_wheel}")print("Attempting to download and install Transformer Engine wheel...")# tell Python to re-scan site-packages now that the egg-link existsimport importlib, site; site.addsitedir(site.getsitepackages()[0]); importlib.invalidate_caches()except Exception as e:print(f"⚠️ Could not install Transformer Engine : {e}")print("Continuing without Transformer Engine ...")import torchprint(f"Torch version: {torch.__version__}")print(f"FlashAttention available: {flash_attention_installed}")import tempfilefrom pathlib import Pathfrom torch._inductor.runtime.runtime_utils import cache_dir as _inductor_cache_dirfrom huggingface_hub import HfApisnapshot_download(repo_id="bytedance-research/HuMo", local_dir="./weights/HuMo")snapshot_download(repo_id="Wan-AI/Wan2.1-T2V-1.3B", local_dir="./weights/Wan2.1-T2V-1.3B")snapshot_download(repo_id="openai/whisper-large-v3", local_dir="./weights/whisper-large-v3")os.environ["PROCESSED_RESULTS"] = f"{os.getcwd()}/proprocess_results"path_to_insert = "humo"if path_to_insert not in sys.path:sys.path.insert(0, path_to_insert)from common.config import load_config, create_objectconfig = load_config("./humo/configs/inference/generate.yaml",["dit.sp_size=1","generation.frames=97","generation.scale_t=5.5","generation.scale_a=5.0","generation.mode=TIA","generation.height=480","generation.width=832",],)runner = create_object(config)os.environ.setdefault("TORCHINDUCTOR_CACHE_DIR", f"{os.getcwd()}/torchinductor_space") # or another writable pathdef restore_inductor_cache_from_hub(repo_id: str, filename: str = "torch_compile_cache.zip",path_in_repo: str = "inductor_cache", repo_type: str = "model",hf_token: str | None = None):cache_root = Path(_inductor_cache_dir()).resolve()cache_root.mkdir(parents=True, exist_ok=True)zip_path = hf_hub_download(repo_id=repo_id, filename=f"{path_in_repo}/{filename}",repo_type=repo_type, token=hf_token)shutil.unpack_archive(zip_path, extract_dir=str(cache_root))print(f"✓ Restored cache into {cache_root}")# restore_inductor_cache_from_hub("alexnasa/humo-compiled")def get_duration(prompt_text, steps, image_file, audio_file_path, tea_cache_l1_thresh, max_duration, session_id):return calculate_required_time(steps, max_duration)def calculate_required_time(steps, max_duration):warmup_s = 60max_duration_duration_mapping = {1: 8,2: 8,3: 11,4: 20,5: 30,}each_step_s = max_duration_duration_mapping[max_duration]duration_s = (each_step_s * steps) + warmup_sprint(f'estimated duration:{duration_s}')return int(duration_s)def get_required_time_string(steps, max_duration):duration_s = calculate_required_time(steps, max_duration)duration_m = duration_s / 60return f"<center>⌚ Zero GPU Required: ~{duration_s}.0s ({duration_m:.1f} mins)</center>"def update_required_time(steps, max_duration):return get_required_time_string(steps, max_duration)def generate_scene(prompt_text, steps, image_paths, audio_file_path, tea_cache_l1_thresh, max_duration = 2, session_id = None):print(image_paths)prompt_text_check = (prompt_text or "").strip()if not prompt_text_check:raise gr.Error("Please enter a prompt.")if not audio_file_path and not image_paths:raise gr.Error("Please provide a reference image or a lipsync audio.")return run_pipeline(prompt_text, steps, image_paths, audio_file_path, tea_cache_l1_thresh, max_duration, session_id)def upload_inductor_cache_to_hub(repo_id: str,path_in_repo: str = "inductor_cache",repo_type: str = "model", # or "dataset" if you preferhf_token: str | None = None,):"""Zips the current TorchInductor cache and uploads it to the given repo path.Assumes the model was already run once with torch.compile() so the cache exists."""cache_dir = Path(_inductor_cache_dir()).resolve()if not cache_dir.exists():raise FileNotFoundError(f"TorchInductor cache not found at {cache_dir}. ""Run a compiled model once to populate it.")# Create a zip archive of the entire cache directorywith tempfile.TemporaryDirectory() as tmpdir:archive_base = Path(tmpdir) / "torch_compile_cache"archive_path = shutil.make_archive(str(archive_base), "zip", root_dir=str(cache_dir))archive_path = Path(archive_path)# Upload to Hubapi = HfApi(token=hf_token)api.create_repo(repo_id=repo_id, repo_type=repo_type, exist_ok=True)# Put each artifact under path_in_repo, including a tiny metadata stamp for traceability# Upload the zipdest_path = f"{path_in_repo}/{archive_path.name}"api.upload_file(path_or_fileobj=str(archive_path),path_in_repo=dest_path,repo_id=repo_id,repo_type=repo_type,)# Upload a small metadata file (optional but handy)meta_txt = (f"pytorch={torch.__version__}\n"f"inductor_cache_dir={cache_dir}\n"f"cuda_available={torch.cuda.is_available()}\n"f"cuda_device={torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'cpu'}\n")api.upload_file(path_or_fileobj=meta_txt.encode(),path_in_repo=f"{path_in_repo}/INDUCTOR_CACHE_METADATA.txt",repo_id=repo_id,repo_type=repo_type,)print("✔ Uploaded TorchInductor cache to the Hub.")@spaces.GPU(duration=get_duration)def run_pipeline(prompt_text, steps, image_paths, audio_file_path, tea_cache_l1_thresh = 0.0, max_duration = 2, session_id = None):if session_id is None:session_id = uuid.uuid4().hexinference_mode = "TIA"# Validate inputsprompt_text = (prompt_text or "").strip()if not prompt_text:raise gr.Error("Please enter a prompt.")if not audio_file_path and not image_paths:raise gr.Error("Please provide a reference image or a lipsync audio.")if not audio_file_path:inference_mode = "TI"audio_path = Noneelse:audio_path = audio_file_path if isinstance(audio_file_path, str) else getattr(audio_file_path, "name", str(audio_file_path))if not image_paths:inference_mode = "TA"img_paths = Noneelse:img_paths = [image_data[0] for image_data in image_paths]# Prepare outputoutput_dir = os.path.join(os.environ["PROCESSED_RESULTS"], session_id)os.makedirs(output_dir, exist_ok=True)# Random filenamefilename = f"gen_{uuid.uuid4().hex[:10]}"width, height = 832, 480duration_frame_mapping = {1:25,2:45,3:70,4:97,5:129}# Run inferencerunner.inference_loop(prompt_text,img_paths,audio_path,output_dir,filename,inference_mode,width,height,steps,frames = int(duration_frame_mapping[max_duration]),tea_cache_l1_thresh = tea_cache_l1_thresh,)# Return resulting video pathvideo_path = os.path.join(output_dir, f"{filename}.mp4")if os.path.exists(video_path):# upload_inductor_cache_to_hub("alexnasa/humo-compiled")return video_pathelse:candidates = [os.path.join(output_dir, f) for f in os.listdir(output_dir) if f.endswith(".mp4")]if candidates:return max(candidates, key=lambda p: os.path.getmtime(p))return Nonecss = """#col-container {margin: 0 auto;width: 100%;max-width: 720px;}"""def cleanup(request: gr.Request):sid = request.session_hashif sid:d1 = os.path.join(os.environ["PROCESSED_RESULTS"], sid)shutil.rmtree(d1, ignore_errors=True)def start_session(request: gr.Request):return request.session_hashwith gr.Blocks(css=css) as demo:session_state = gr.State()demo.load(start_session, outputs=[session_state])with gr.Sidebar(width=400):gr.HTML("""<div style="text-align: center;"><p style="font-size:16px; display: inline; margin: 0;"><strong>HuMo</strong> – Human-Centric Video Generation via Collaborative Multi-Modal Conditioning</p><a href="https://github.com/Phantom-video/HuMo" style="display: inline-block; vertical-align: middle; margin-left: 0.5em;">[Github]</a></div>""")gr.Markdown("**REFERENCE IMAGES**")img_input = gr.Gallery(show_label=False,label="",interactive=True,rows=1, columns=3, object_fit="contain", height="280",file_types=['image'])gr.Markdown("**LIPSYNC AUDIO**")audio_input = gr.Audio(sources=["upload"],show_label=False,type="filepath",)gr.Markdown("**SETTINGS**")default_steps = 10default_max_duration = 2max_duration = gr.Slider(minimum=2, maximum=5, value=default_max_duration, step=1, label="Max Duration")steps_input = gr.Slider(minimum=5, maximum=50, value=default_steps, step=5, label="Diffusion Steps")tea_cache_l1_thresh = gr.Slider(minimum=0.0, maximum=1.0, value=0.0, step=0.01, label="Cache", visible=False)with gr.Column(elem_id="col-container"):gr.HTML("""<div style="text-align: center;"><strong>HF Space by:</strong><a href="https://twitter.com/alexandernasa/" style="display: inline-block; vertical-align: middle; margin-left: 0.5em;"><img src="https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow Me" alt="GitHub Repo"></a></div>""")video_output = gr.Video(show_label=False)gr.Markdown("<center><h2>PROMPT</h2></center>")prompt_tb = gr.Textbox(show_label=False,lines=5,placeholder="Describe the scene and the person talking....",)gr.Markdown("")time_required = gr.Markdown(get_required_time_string(default_steps, default_max_duration))run_btn = gr.Button("🎬 Action", variant="primary")gr.Examples(examples=[["A handheld tracking shot follows a female warrior walking through a cave. Her determined eyes are locked straight ahead. She speaks with intensity.",5,["./examples/naomi.png"],"./examples/dream.mp3",],["A reddish-brown haired and bearded man sits pensively against swirling blue-and-white brushstrokes, dressed in a blue coat and dark waistcoat. The artistic backdrop and his thoughtful pose evoke a Post-Impressionist style in a studio-like setting.",10,["./examples/vangogh.jpg"],"./examples/art.wav",],["A handheld tracking shot follows a female through a science lab. Her determined eyes are locked straight ahead. The clip is in black and white and patchy as she is explaining something to someone standing opposite her",10,["./examples/naomi.png"],"./examples/science.wav",],["A woman with long, wavy dark hair looking at a person sitting opposite her whilst holding a book, wearing a leather jacket, long-sleeved jacket with a semi purple color one seen on a photo. Warm, window-like light bathes her figure, highlighting the outfit's elegant design and her graceful movements.",50,["./examples/amber.png", "./examples/jacket.png"],"./examples/fictional.wav",],],inputs=[prompt_tb, steps_input, img_input, audio_input],outputs=[video_output],fn=run_pipeline,cache_examples=True,)max_duration.change(update_required_time, [steps_input, max_duration], time_required)steps_input.change(update_required_time, [steps_input, max_duration], time_required)run_btn.click(fn=generate_scene,inputs=[prompt_tb, steps_input, img_input, audio_input, tea_cache_l1_thresh, max_duration, session_state],outputs=[video_output],)if __name__ == "__main__":demo.unload(cleanup)demo.queue()demo.launch(ssr_mode=False)
app.py+435-435