import os import glob import time import pathlib import shlex import subprocess import gradio as gr from huggingface_hub import snapshot_download from datasets import load_from_disk import random # Fix the random seed for reproducibility random.seed(42) # You can use any fixed number as the seed # Define common combinations common_combinations = [ ("lookaround", "back_and_forth"), # Most common ("lookdown", "back_and_forth"), # Less common ("rotate360", "headbanging") # Rare ] # 下载数据集 repo_id = "svjack/3DitScene_cache" folder_path = "Genshin-Impact-Couple-with-Tags-IID-Gender-Only-Two-Joy-Caption_Head10" local_dir = snapshot_download( repo_id=repo_id, repo_type="dataset", allow_patterns=f"{folder_path}/*", cache_dir=os.getcwd(), local_dir="." ) # 加载数据集 dataset = load_from_disk(folder_path) # 提取 image 和 joy-caption examples = [] for example in dataset: examples.append({ 'image': example['image'], 'joy-caption': example['joy_caption_surrounding'] }) # 为每个例子随机分配 gen_camerapath 和 render_camerapath examples_with_combinations = [] for example in examples: # Randomly select a combination from common_combinations gen_camerapath, render_camerapath = random.choice(common_combinations) examples_with_combinations.append({ 'image': example['image'], 'joy-caption': example['joy-caption'], 'gen_camerapath': gen_camerapath, 'render_camerapath': render_camerapath }) root = pathlib.Path(__file__).parent example_root = os.path.join(root, 'examples') ckpt_root = os.path.join(root, 'stablediffusion') d = example_root if len(glob.glob(os.path.join(d, '*.ply'))) < 8: snapshot_download(repo_id="ironjr/LucidDreamerDemo", repo_type="model", local_dir=d) d = os.path.join(ckpt_root, 'Blazing Drive V11m') if not os.path.exists(d): snapshot_download(repo_id="ironjr/BlazingDriveV11m", repo_type="model", local_dir=d) d = os.path.join(ckpt_root, 'RealCartoon-Pixar V5') if not os.path.exists(d): snapshot_download(repo_id="ironjr/RealCartoon-PixarV5", repo_type="model", local_dir=d) d = os.path.join(ckpt_root, 'Realistic Vision V5.1') if not os.path.exists(d): snapshot_download(repo_id="ironjr/RealisticVisionV5-1", repo_type="model", local_dir=d) d = os.path.join(ckpt_root, 'SD1-5') if not os.path.exists(d): snapshot_download(repo_id="runwayml/stable-diffusion-inpainting", repo_type="model", local_dir=d) try: import simple_knn except ModuleNotFoundError: subprocess.run(shlex.split(f'pip install {root}/dist/simple_knn-0.0.0-cp39-cp39-linux_x86_64.whl')) try: import depth_diff_gaussian_rasterization_min except ModuleNotFoundError: subprocess.run(shlex.split(f'pip install {root}/dist/depth_diff_gaussian_rasterization_min-0.0.0-cp39-cp39-linux_x86_64.whl')) from luciddreamer import LucidDreamer css = """ #run-button { background: coral; color: white; } """ save_dir = "local_save" os.makedirs(save_dir, exist_ok=True) ld = LucidDreamer(save_dir=save_dir) with gr.Blocks(css=css) as demo: gr.HTML( """
We deeply thank br_d, 7whitefire7, and SG161222 for their awesome Stable Diffusion models. We also appreciate ai_pictures21 and recatm for the beautiful illustrations used in the examples. Please note that the authors of this work do not own the model checkpoints and the illustrations in this demo. LucidDreamer algorithm cannot be used for commercial purpose. Please contact the authors for permission requests.