Spaces:
Runtime error
Runtime error
File size: 15,015 Bytes
24f9881 0dead1b efeb5fb 24f9881 0dead1b 1cf8b36 24f9881 0dead1b 24f9881 0dead1b 0644986 0dead1b 28c2f79 efeb5fb ad5269f 28c2f79 a1687cd 1cf8b36 8f49745 3ecce45 1cf8b36 8f49745 3ecce45 259e927 1cf8b36 0dead1b 24f9881 259e927 24f9881 d74ffc1 24f9881 3ea759a 24f9881 3ea759a 24f9881 259e927 24f9881 259e927 24f9881 259e927 24f9881 8973224 24f9881 259e927 24f9881 259e927 24f9881 259e927 24f9881 259e927 24f9881 259e927 24f9881 6f1773a |
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# Copyright (C) 2023, Computer Vision Lab, Seoul National University, https://cv.snu.ac.kr
#
# Copyright 2023 LucidDreamer Authors
#
# Computer Vision Lab, SNU, its affiliates and licensors retain all intellectual
# property and proprietary rights in and to this material, related
# documentation and any modifications thereto. Any use, reproduction,
# disclosure or distribution of this material and related documentation
# without an express license agreement from the Computer Vision Lab, SNU or
# its affiliates is strictly prohibited.
#
# For permission requests, please contact [email protected], [email protected], [email protected], [email protected].
import os
import glob
import time
import pathlib
import shlex
import subprocess
import gradio as gr
from huggingface_hub import snapshot_download
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('python setup.py install'), cwd=os.path.join(root, 'submodules', 'simple-knn'))
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('python setup.py install'), cwd=os.path.join(root, 'submodules', 'depth-diff-gaussian-rasterization-min'))
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;
}
"""
ld = LucidDreamer()
with gr.Blocks(css=css) as demo:
gr.HTML(
"""
<div style="display: flex; justify-content: center; align-items: center; text-align: center;">
<div>
<h1 >LucidDreamer: Domain-free Generation of 3D Gaussian Splatting Scenes</h1>
<h5 style="margin: 0;">If you like our project, please visit our Github, too! ✨✨✨ More features are waiting!</h5>
</br>
<div style="display: flex; justify-content: center; align-items: center; text-align: center;">
<a href='https://arxiv.org/abs/2311.13384'>
<img src="https://img.shields.io/badge/Arxiv-2311.13384-red">
</a>
<a href='https://luciddreamer-cvlab.github.io'>
<img src='https://img.shields.io/badge/Project-LucidDreamer-green' alt='Project Page'>
</a>
<a href='https://github.com/luciddreamer-cvlab/LucidDreamer'>
<img src='https://img.shields.io/github/stars/luciddreamer-cvlab/LucidDreamer?label=Github&color=blue'>
</a>
<a href='https://twitter.com/_ironjr_'>
<img src='https://img.shields.io/twitter/url?label=_ironjr_&url=https%3A%2F%2Ftwitter.com%2F_ironjr_'>
</a>
</div>
<div style="display: flex; justify-content: center; align-items: center; text-align: left; border: 1px solid lightgray; padding: 10px; margin-top: 20px; margin-left: 100px; margin-right: 100px; border-radius: 10px">
<p style="align-items: center;">
<a style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/ironjr/LucidDreamer-mini"><img src="https://huggingface.co/datasets/huggingface/badges/raw/main/open-in-hf-spaces-sm.svg"></a>
<a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/ironjr/LucidDreamer?duplicate=true"><img style="margin-top:0;margin-bottom:0" src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a>
</p>
<p style="margin-left: 15px">
<b>Attention</b>: In case of high traffic, you can alternatively use our backup server (first button: without custom SD support) or clone this repository to run on your own machine (second button). We gratefully welcome any type of your contributions!
</p>
</div>
</div>
</div>
"""
)
with gr.Row():
result_gallery = gr.Video(label='RGB Video', show_label=True, autoplay=True, format='mp4')
result_depth = gr.Video(label='Depth Video', show_label=True, autoplay=True, format='mp4')
result_ply_file = gr.File(label='Gaussian splatting PLY', show_label=True)
with gr.Row():
input_image = gr.Image(
label='Image prompt',
sources='upload',
type='pil',
)
with gr.Column():
model_name = gr.Radio(
label='SD checkpoint',
choices=['SD1.5 (default)', 'Blazing Drive V11m', 'Realistic Vision V5.1', 'RealCartoon-Pixar V5',],
value='SD1.5 (default)'
)
prompt = gr.Textbox(
label='Text prompt',
value='A cozy livingroom',
)
n_prompt = gr.Textbox(
label='Negative prompt',
value='photo frame, frame, boarder, simple color, inconsistent, humans, people',
)
gen_camerapath = gr.Radio(
label='Camera trajectory for generation (STEP 1)',
choices=['lookaround', 'lookdown', 'rotate360'],
value='lookaround',
)
with gr.Row():
seed = gr.Slider(
label='Seed',
minimum=1,
maximum=2147483647,
step=1,
randomize=True,
)
diff_steps = gr.Slider(
label='SD inpainting steps',
minimum=1,
maximum=50,
step=1,
value=30,
)
render_camerapath = gr.Radio(
label='Camera trajectory for rendering (STEP 2)',
choices=['back_and_forth', 'llff', 'headbanging'],
value='llff',
)
with gr.Column():
run_button = gr.Button(value='Run! (it may take a while)', elem_id='run-button')
gr.HTML(
"""
<div style="display: flex; justify-content: center; align-items: center; text-align: center;">
<div>
<h3>...or you can run in two steps</h3>
<h5>(hint: press STEP 2 if you have already baked Gaussians in STEP 1).</h5>
</div>
</div>
"""
)
with gr.Row():
gaussian_button = gr.Button(value='STEP 1: Generate Gaussians')
render_button = gr.Button(value='STEP 2: Render A Video')
gr.HTML(
"""
<div style="display: flex; justify-content: center; align-items: center; text-align: center;">
<div>
<h5>...or you can just watch a quick preload we have baked already.</h5>
</div>
</div>
"""
)
example_name = gr.Radio(
label='Quick load',
choices=['girl', 'ruin', 'doge', 'christmas', 'elf', 'animelake', 'fantasy', 'kitchen', 'DON\'T'],
value='DON\'T',
)
ips = [example_name, input_image, prompt, n_prompt, gen_camerapath, seed, diff_steps, render_camerapath, model_name]
run_button.click(fn=ld.run, inputs=ips[1:] + ips[:1], outputs=[result_ply_file, result_gallery, result_depth])
gaussian_button.click(fn=ld.create, inputs=ips[1:-2] + ips[-1:] + ips[:1], outputs=[result_ply_file])
render_button.click(fn=ld.render_video, inputs=ips[-2:-1] + ips[:1], outputs=[result_gallery, result_depth])
gr.Examples(
examples=[
[
'girl',
'examples/girl.jpg',
'dark messy room, noir style, indoors, bottle, shoe soles, jacket, cup, window, blurry, black footwear, depth of field, box, couch, table, gun, chair, foreshortening',
'photo frame, frame, boarder, simple color, inconsistent',
'lookaround',
10,
25,
'back_and_forth',
'Blazing Drive V11m',
],
[
'ruin',
'examples/ruin.png',
'Postapocalyptic city in desert',
'photo frame, frame, boarder, simple color, inconsistent, humans, people',
'lookaround',
4,
25,
'back_and_forth',
'Blazing Drive V11m',
],
[
'doge',
'examples/doge.png',
'a cozy livingroom',
'photo frame, frame, boarder, simple color, inconsistent, humans, people',
'lookaround',
10,
25,
'back_and_forth',
'Realistic Vision V5.1',
],
[
'christmas',
'examples/christmas.png',
'Cozy livingroom in christmas',
'photo frame, frame, boarder, simple color, inconsistent, humans, people',
'lookaround',
3,
25,
'back_and_forth',
'Realistic Vision V5.1',
],
[
'elf',
'examples/elf.png',
'serene deep forest',
'photo frame, frame, boarder, simple color, inconsistent, humans, people',
'lookaround',
10,
25,
'back_and_forth',
'RealCartoon-Pixar V5',
],
[
'animelake',
'examples/Image015_animelakehouse.jpg',
'anime style, animation, best quality, a boat on lake, trees and rocks near the lake. a house and port in front of a house',
'photo frame, frame, boarder, simple color, inconsistent',
'lookdown',
1,
50,
'back_and_forth',
'SD1.5 (default)',
],
[
'fantasy',
'examples/Image003_fantasy.jpg',
'A vibrant, colorful floating community city, clouds above a beautiful, enchanted landscape filled with whimsical flora, enchanted forest landscape, Magical and dreamy woodland with vibrant green foliage and sparkling flowers, Landscape with twisted trees and vines, natural lighting and dark shadows, unique fantastical elements like floating islands and floating orbs, Highly detailed vegetation and foliage, deep contrast and color vibrancy,', # texture and intricate details in a floating element',
'photo frame, frame, boarder, simple color, inconsistent',
'lookaround',
30,
50,
'back_and_forth',
'SD1.5 (default)',
],
[
'kitchen',
'examples/image020.png',
'High-resolution photography kitchen design, wooden floor, small windows opening onto the garden, Bauhaus furniture and decoration, high ceiling, beige blue salmon pastel palette, interior design magazine, cozy atmosphere; 8k, intricate detail, photorealistic, realistic light, wide angle, kinfolk photography, A+D architecture, Kitchen Sink, Basket of fruits and vegetables, a bottle of ', #drinking water, walls painted magazine style photo, looking towards a sink under a window, with a door on the left of the sink with a 25 cm distance from the kitchen, the kitchen is an L shaped starting from the right corner, on the far right a fridge nest to it a stove, next the dishwasher then the sink, a smokey grey kitchen with modern touches, taupe walls, a taup ceiling with spotlights inside the ceiling with 90 cm distance, wooden parquet floor',
'photo frame, frame, boarder, simple color, inconsistent',
'rotate360',
1,
50,
'headbanging',
'SD1.5 (default)',
],
],
inputs=ips,
outputs=[result_ply_file, result_gallery, result_depth],
fn=ld.run,
cache_examples=False,
)
gr.HTML(
"""
<div style="display: flex; justify-content: center; align-items: center; text-align: left;">
</br>
<div>
<h5 style="margin: 0;">Acknowledgement and Disclaimer</h5>
</br>
<p>We deeply thank <a href="https://twitter.com/br_d">br_d</a>, <a href="https://ko-fi.com/7whitefire7">7whitefire7</a>, and <a href="https://huggingface.co/SG161222">SG161222</a> for their awesome Stable Diffusion models. We also appreciate <a href="https://twitter.com/ai_pictures21">ai_pictures21</a> and <a href="https://twitter.com/recatm">recatm</a> 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.</p>
</div>
</div>
"""
)
if __name__ == '__main__':
demo.launch()
|