Spaces:
Paused
Paused
Commit
·
1dd069e
1
Parent(s):
b440279
Upload 2 files
Browse files- app.py +45 -53
- example_input.png +0 -0
app.py
CHANGED
|
@@ -1,37 +1,27 @@
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
-
import re
|
| 4 |
-
from typing import List, Optional, Tuple, Union
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
import dnnlib
|
| 8 |
import numpy as np
|
| 9 |
import PIL.Image
|
| 10 |
import torch
|
| 11 |
from tqdm import tqdm
|
| 12 |
|
| 13 |
-
|
| 14 |
import legacy
|
| 15 |
from camera_utils import LookAtPoseSampler
|
| 16 |
from huggingface_hub import hf_hub_download
|
| 17 |
-
|
| 18 |
from matplotlib import pyplot as plt
|
| 19 |
-
|
| 20 |
from pathlib import Path
|
| 21 |
-
|
| 22 |
-
import json
|
| 23 |
import gradio as gr
|
| 24 |
-
|
| 25 |
from training.utils import color_mask, color_list
|
| 26 |
import plotly.graph_objects as go
|
| 27 |
from tqdm import tqdm
|
| 28 |
-
|
| 29 |
import imageio
|
| 30 |
-
|
| 31 |
-
import argparse
|
| 32 |
-
|
| 33 |
import trimesh
|
| 34 |
-
import pyrender
|
| 35 |
import mcubes
|
| 36 |
|
| 37 |
os.environ["PYOPENGL_PLATFORM"] = "egl"
|
|
@@ -198,11 +188,13 @@ def get_all(cfg,input,truncation_psi,mesh_resolution,random_seed,fps,num_frames)
|
|
| 198 |
fig_mesh=return_plot_go(mesh_trimesh)
|
| 199 |
return fig_mesh,image_color,image_seg,video,video_label
|
| 200 |
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
[Arxiv: "3D-aware Conditional Image Synthesis".](https://arxiv.org/abs/2302.08509)
|
|
|
|
| 205 |
[Project Page.](https://www.cs.cmu.edu/~pix2pix3D/)
|
|
|
|
| 206 |
[For the official implementation.](https://github.com/dunbar12138/pix2pix3D)
|
| 207 |
|
| 208 |
### Future Work based on interest
|
|
@@ -214,39 +206,39 @@ markdown=f'''
|
|
| 214 |
The process can take long time.Especially ,To generate videos and the time of process depends the number of frames,Mesh Resolution and current compiler device.
|
| 215 |
|
| 216 |
'''
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
gr.
|
| 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 |
-
|
|
|
|
| 1 |
import sys
|
| 2 |
import os
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
os.system("https://github.com/dunbar12138/pix2pix3D.git")
|
| 5 |
+
sys.path.append("pix2pix3D")
|
| 6 |
+
|
| 7 |
+
from typing import List, Optional, Tuple, Union
|
| 8 |
import dnnlib
|
| 9 |
import numpy as np
|
| 10 |
import PIL.Image
|
| 11 |
import torch
|
| 12 |
from tqdm import tqdm
|
| 13 |
|
|
|
|
| 14 |
import legacy
|
| 15 |
from camera_utils import LookAtPoseSampler
|
| 16 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 17 |
from matplotlib import pyplot as plt
|
|
|
|
| 18 |
from pathlib import Path
|
|
|
|
|
|
|
| 19 |
import gradio as gr
|
|
|
|
| 20 |
from training.utils import color_mask, color_list
|
| 21 |
import plotly.graph_objects as go
|
| 22 |
from tqdm import tqdm
|
|
|
|
| 23 |
import imageio
|
|
|
|
|
|
|
|
|
|
| 24 |
import trimesh
|
|
|
|
| 25 |
import mcubes
|
| 26 |
|
| 27 |
os.environ["PYOPENGL_PLATFORM"] = "egl"
|
|
|
|
| 188 |
fig_mesh=return_plot_go(mesh_trimesh)
|
| 189 |
return fig_mesh,image_color,image_seg,video,video_label
|
| 190 |
|
| 191 |
+
title="3D-aware Conditional Image Synthesis"
|
| 192 |
+
desc=f'''
|
| 193 |
+
|
| 194 |
[Arxiv: "3D-aware Conditional Image Synthesis".](https://arxiv.org/abs/2302.08509)
|
| 195 |
+
|
| 196 |
[Project Page.](https://www.cs.cmu.edu/~pix2pix3D/)
|
| 197 |
+
|
| 198 |
[For the official implementation.](https://github.com/dunbar12138/pix2pix3D)
|
| 199 |
|
| 200 |
### Future Work based on interest
|
|
|
|
| 206 |
The process can take long time.Especially ,To generate videos and the time of process depends the number of frames,Mesh Resolution and current compiler device.
|
| 207 |
|
| 208 |
'''
|
| 209 |
+
demo_inputs=[
|
| 210 |
+
gr.Dropdown(choices=["seg2cat"],label="Choose Model",value="seg2cat"),
|
| 211 |
+
gr.Image(type="filepath",shape=(512, 512),label="Mask"),
|
| 212 |
+
gr.Slider( minimum=0, maximum=2,label='Truncation PSI',value=1),
|
| 213 |
+
gr.Slider( minimum=32, maximum=512,label='Mesh Resolution',value=32),
|
| 214 |
+
gr.Slider( minimum=0, maximum=2**16,label='Seed',value=128),
|
| 215 |
+
gr.Slider( minimum=10, maximum=120,label='FPS',value=30),
|
| 216 |
+
gr.Slider( minimum=10, maximum=120,label='The Number of Frames',value=30),
|
| 217 |
+
|
| 218 |
+
]
|
| 219 |
+
demo_outputs=[
|
| 220 |
+
gr.Plot(),
|
| 221 |
+
gr.Image(type="pil",shape=(256,256)),
|
| 222 |
+
gr.Image(type="pil",shape=(256,256)),
|
| 223 |
+
gr.Video(),
|
| 224 |
+
gr.Video()
|
| 225 |
+
|
| 226 |
+
]
|
| 227 |
+
examples = [
|
| 228 |
+
["seg2cat", "example_input.png", 1, 32, 128, 30, 30],
|
| 229 |
+
|
| 230 |
+
]
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
demo_app = gr.Interface(
|
| 234 |
+
fn=get_all,
|
| 235 |
+
inputs=demo_inputs,
|
| 236 |
+
outputs=demo_outputs,
|
| 237 |
+
cache_examples=True,
|
| 238 |
+
title=title,
|
| 239 |
+
theme="huggingface",
|
| 240 |
+
description=desc,
|
| 241 |
+
examples=examples,
|
| 242 |
+
cache_examples=True,
|
| 243 |
+
)
|
| 244 |
+
demo_app.launch(debug=True, enable_queue=True)
|
example_input.png
ADDED
|