File size: 2,081 Bytes
da2362d
547bc6e
b877500
f8b1e61
da2362d
 
547bc6e
d8647a5
547bc6e
 
 
 
 
 
cecc2bb
b877500
cecc2bb
b877500
cecc2bb
 
b877500
fe59321
 
 
 
cecc2bb
f8b1e61
b877500
aa56b02
d142771
cf75ce8
b877500
 
 
 
cecc2bb
d62198c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import subprocess
import os
import gradio as gr
import spaces

subprocess.run(["git", "clone", "https://github.com/fat-ai/MuseV.git"])

os.chdir("./MuseV")
subprocess.run(["pip", "install", "-r", "requirements.txt"])
subprocess.run(["pip", "install", "--no-cache-dir", "-U", "openmim"])
subprocess.run(["mim", "install", "mmengine"])
subprocess.run(["mim", "install", "mmcv>=2.0.1"])
subprocess.run(["mim", "install", "mmdet>=3.1.0"])
subprocess.run(["mim", "install", "mmpose>=1.1.0"])
subprocess.run(["git", "clone", "--recursive", "https://github.com/fat-ai/MuseV.git"])
subprocess.run(["git", "clone", "https://huggingface.co/TMElyralab/MuseV", "./checkpoints"])

os.chdir("..")
command = "\"import sys; sys.path.append('./MuseV/MuseV'); sys.path.append('./MuseV/MuseV/MMCM'); sys.path.append('./MuseV/MuseV/diffusers/src'); sys.path.append('./MuseV/MuseV/controlnet_aux/src')\""
subprocess.run(["python","-c",command])
subprocess.run(["mv", "./MuseV/scripts/inference/text2video.py", "./MuseV/text2video.py"])
subprocess.run(["mv", "./MuseV/scripts/inference/video2video.py", "./MuseV/video2video.py"])
with open ("./MuseV/scripts/inference/text2video.py","r+") as scrip:
    s = scrip.read()
    s = s.replace('PROJECT_DIR = os.path.join(os.path.dirname(__file__), "")', "PROJECT_DIR = /home/user")

@spaces.GPU
def run():
  subprocess.run(["python", "./MuseV/text2video.py", "--sd_model_name", "majicmixRealv6Fp16", "--unet_model_name", "musev_referencenet", "--referencenet_model_name", "musev_referencenet", "--ip_adapter_model_name", "musev_referencenet", "-test_data_path", "./MuseV/configs/tasks/example.yaml", "--output_dir", "./MuseV",  "--n_batch", "1",  "--target_datas", "Mona_Lisa.",  "--vision_clip_extractor_class_name", "ImageClipVisionFeatureExtractor", "--vision_clip_model_path", "./MuseV/checkpoints/IP-Adapter/models/image_encoder", "--motion_speed", "5.0", "--time_size", "120", "--fps", "24"])
  return "./MuseV/Mona_Lisa.mp4"
    
with gr.Blocks() as demo:
  button = gr.Button()
  video = gr.Video()
  button.click(fn=run,outputs=video)

demo.launch()