Spaces:
Runtime error
Runtime error
Use huggingface_hub to download models
Browse files8 unmodified lines9101112131472 unmodified lines8788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715886 unmodified lines245246247248249250251252253254255376 unmodified lines6326336346356366376 unmodified lines6446456466476486496506516526536546556566576586596606616626638 unmodified linesimport torchvisionfrom diffusers import AutoencoderKL, DDIMSchedulerfrom einops import rearrangefrom omegaconf import OmegaConffrom PIL import Imagefrom torchvision import transforms72 unmodified lines# """os.makedirs("models/personalized")os.makedirs("models/sd1-5")if not os.path.exists("models/flow_controlnet.ckpt"):os.system(f"wget -q https://huggingface.co/TencentARC/ImageConductor/resolve/main/flow_controlnet.ckpt?download=true -P models/")os.system(f"mv models/flow_controlnet.ckpt?download=true models/flow_controlnet.ckpt")print("flow_controlnet Download!",)if not os.path.exists("models/image_controlnet.ckpt"):os.system(f"wget -q https://huggingface.co/TencentARC/ImageConductor/resolve/main/image_controlnet.ckpt?download=true -P models/")os.system(f"mv models/image_controlnet.ckpt?download=true models/image_controlnet.ckpt")print("image_controlnet Download!",)if not os.path.exists("models/unet.ckpt"):os.system(f"wget -q https://huggingface.co/TencentARC/ImageConductor/resolve/main/unet.ckpt?download=true -P models/")os.system(f"mv models/unet.ckpt?download=true models/unet.ckpt")print("unet Download!",)if not os.path.exists("models/sd1-5/config.json"):os.system(f"wget -q https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/unet/config.json?download=true -P models/sd1-5/")os.system(f"mv models/sd1-5/config.json?download=true models/sd1-5/config.json")print("config Download!",)if not os.path.exists("models/sd1-5/unet.ckpt"):os.system(f"cp -r models/unet.ckpt models/sd1-5/unet.ckpt")# os.system(f'wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/unet/diffusion_pytorch_model.bin?download=true -P models/sd1-5/')if not os.path.exists("models/personalized/helloobjects_V12c.safetensors"):os.system(f"wget -q https://huggingface.co/TencentARC/ImageConductor/resolve/main/helloobjects_V12c.safetensors?download=true -P models/personalized")os.system(f"mv models/personalized/helloobjects_V12c.safetensors?download=true models/personalized/helloobjects_V12c.safetensors")print("helloobjects_V12c Download!",)if not os.path.exists("models/personalized/TUSUN.safetensors"):os.system(f"wget -q https://huggingface.co/TencentARC/ImageConductor/resolve/main/TUSUN.safetensors?download=true -P models/personalized")os.system(f"mv models/personalized/TUSUN.safetensors?download=true models/personalized/TUSUN.safetensors")print("TUSUN Download!",)# mv1 = os.system(f'mv /usr/local/lib/python3.10/site-packages/gradio/helpers.py /usr/local/lib/python3.10/site-packages/gradio/helpers_bkp.py')# mv2 = os.system(f'mv helpers.py /usr/local/lib/python3.10/site-packages/gradio/helpers.py')86 unmodified linesDREAM_BOOTH = {"HelloObject": "models/personalized/helloobjects_V12c.safetensors",}LORA = {"TUSUN": "models/personalized/TUSUN.safetensors",}LORA_ALPHA = {376 unmodified linesreturn {tracking_points_var: tracking_points, input_image: trajectory_map}block = gr.Blocks(theme=gr.themes.Soft(radius_size=gr.themes.sizes.radius_none, text_size=gr.themes.sizes.text_md))with block:with gr.Row():6 unmodified lineswith gr.Row(equal_height=True):gr.Markdown(instructions)# device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")device = torch.device("cuda")unet_path = "models/unet.ckpt"image_controlnet_path = "models/image_controlnet.ckpt"flow_controlnet_path = "models/flow_controlnet.ckpt"ImageConductor_net = ImageConductor(device=device,unet_path=unet_path,image_controlnet_path=image_controlnet_path,flow_controlnet_path=flow_controlnet_path,height=256,width=384,model_length=16,)first_frame_path_var = gr.State(value=None)tracking_points_var = gr.State([])8 unmodified lines910111213141572 unmodified lines88899091929394959697989910010110210310410510686 unmodified lines193194195196197198199200201202203376 unmodified lines5805815825835845855865875885895905915925935945955966 unmodified lines6036046056066076088 unmodified linesimport torchvisionfrom diffusers import AutoencoderKL, DDIMSchedulerfrom einops import rearrangefrom huggingface_hub import hf_hub_downloadfrom omegaconf import OmegaConffrom PIL import Imagefrom torchvision import transforms72 unmodified lines# """flow_controlnet_path = hf_hub_download("TencentARC/ImageConductor", "flow_controlnet.ckpt")image_controlnet_path = hf_hub_download("TencentARC/ImageConductor", "image_controlnet.ckpt")unet_path = hf_hub_download("TencentARC/ImageConductor", "unet.ckpt")helloobjects_path = hf_hub_download("TencentARC/ImageConductor", "helloobjects_V12c.safetensors")tusun_path = hf_hub_download("TencentARC/ImageConductor", "TUSUN.safetensors")os.makedirs("models/sd1-5", exist_ok=True)sd15_config_path = hf_hub_download("runwayml/stable-diffusion-v1-5", "config.json", subfolder="unet")if not os.path.exists("models/sd1-5/config.json"):os.symlink(sd15_config_path, "models/sd1-5/config.json")if not os.path.exists("models/sd1-5/unet.ckpt"):os.symlink(unet_path, "models/sd1-5/unet.ckpt")# mv1 = os.system(f'mv /usr/local/lib/python3.10/site-packages/gradio/helpers.py /usr/local/lib/python3.10/site-packages/gradio/helpers_bkp.py')# mv2 = os.system(f'mv helpers.py /usr/local/lib/python3.10/site-packages/gradio/helpers.py')86 unmodified linesDREAM_BOOTH = {"HelloObject": helloobjects_path,}LORA = {"TUSUN": tusun_path,}LORA_ALPHA = {376 unmodified linesreturn {tracking_points_var: tracking_points, input_image: trajectory_map}device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")ImageConductor_net = ImageConductor(device=device,unet_path=unet_path,image_controlnet_path=image_controlnet_path,flow_controlnet_path=flow_controlnet_path,height=256,width=384,model_length=16,)block = gr.Blocks(theme=gr.themes.Soft(radius_size=gr.themes.sizes.radius_none, text_size=gr.themes.sizes.text_md))with block:with gr.Row():6 unmodified lineswith gr.Row(equal_height=True):gr.Markdown(instructions)first_frame_path_var = gr.State(value=None)tracking_points_var = gr.State([])
app.py+23-78