import os import torch import sys import spaces import gradio as gr import random from configs.infer_config import get_parser from huggingface_hub import hf_hub_download i2v_examples = [ ['test/images/boy.png', 0, 1.0, '0 40', '0 0', '0 0', 50, 123], ['test/images/car.jpeg', 0, 1.0, '0 -35', '0 0', '0 -0.1', 50, 123], ['test/images/fruit.jpg', 0, 1.0, '0 -3 -15 -20 -17 -5 0', '0 -2 -5 -10 -8 -5 0 2 5 3 0', '0 0', 50, 123], ['test/images/room.png', 5, 1.0, '0 3 10 20 17 10 0', '0 -2 -8 -6 0 2 5 3 0', '0 -0.02 -0.09 -0.16 -0.09 0', 50, 123], ['test/images/castle.png', 0, 1.0, '0 30', '0 -1 -5 -4 0 1 5 4 0', '0 -0.2', 50, 123], ] max_seed = 2 ** 31 def download_model(): REPO_ID = 'Drexubery/ViewCrafter_25' filename_list = ['model.ckpt'] for filename in filename_list: local_file = os.path.join('./checkpoints/', filename) if not os.path.exists(local_file): hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='./checkpoints/', force_download=True) download_model() parser = get_parser() # infer_config.py opts = parser.parse_args() # default device: 'cuda:0' opts.save_dir = './' os.makedirs(opts.save_dir,exist_ok=True) test_tensor = torch.Tensor([0]).cuda() opts.device = str(test_tensor.device) # install pytorch3d pyt_version_str=torch.__version__.split("+")[0].replace(".", "") version_str="".join([ f"py3{sys.version_info.minor}_cu", torch.version.cuda.replace(".",""), f"_pyt{pyt_version_str}" ]) print(version_str) os.system(f"{sys.executable} -m pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html") os.system("mkdir -p checkpoints/ && wget https://download.europe.naverlabs.com/ComputerVision/DUSt3R/DUSt3R_ViTLarge_BaseDecoder_512_dpt.pth -P checkpoints/") print(f'>>> System info: {version_str}') from viewcrafter import ViewCrafter def viewcrafter_demo(opts): css = """#input_img {max-width: 1024px !important} #output_vid {max-width: 1024px; max-height:576px} #random_button {max-width: 100px !important}""" image2video = ViewCrafter(opts, gradio = True) image2video.run_gradio = spaces.GPU(image2video.run_gradio, duration=300) with gr.Blocks(analytics_enabled=False, css=css) as viewcrafter_iface: gr.Markdown("