SerdarHelli commited on
Commit
1dd069e
1 Parent(s): b440279

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +45 -53
  2. 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
- import click
 
 
 
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
- markdown=f'''
202
- # 3D-aware Conditional Image Synthesis
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
- with gr.Blocks() as demo:
220
- gr.Markdown(markdown)
221
- with gr.Row():
222
- with gr.Column():
223
- input=gr.Image(type="filepath",shape=(512, 512))
224
- with gr.Column():
225
- cfg=gr.Dropdown(choices=["seg2cat"],label="Choose Model",value="seg2cat")
226
- truncation_psi = gr.Slider( minimum=0, maximum=2,label='Truncation PSI',value=1)
227
- mesh_resolution = gr.Slider( minimum=32, maximum=512,label='Mesh Resolution',value=32)
228
- random_seed = gr.Slider( minimum=0, maximum=2**16,label='Seed',value=128)
229
- fps = gr.Slider( minimum=10, maximum=120,label='FPS',value=30)
230
- num_frames = gr.Slider( minimum=10, maximum=120,label='The Number of Frames',value=30)
231
-
232
- with gr.Row():
233
- btn = gr.Button(value="Generate")
234
-
235
- with gr.Row():
236
- with gr.Column():
237
- image_color=gr.Image(type="pil",shape=(256,256))
238
- with gr.Column():
239
- image_label=gr.Image(type="pil",shape=(256,256))
240
- with gr.Row():
241
- mesh = gr.Plot()
242
- with gr.Row():
243
- with gr.Column():
244
- video_color=gr.Video()
245
- with gr.Column():
246
- video_label=gr.Video()
247
-
248
-
249
-
250
- btn.click(get_all, [cfg,input,truncation_psi,mesh_resolution,random_seed,fps,num_frames],[ mesh,image_color,image_label,video_color,video_label])
251
-
252
- demo.launch(debug=True,share=True)
 
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