SerdarHelli commited on
Commit
933cc55
1 Parent(s): 61d2ddd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -10,6 +10,7 @@ import random
10
  os.system("git clone https://github.com/luost26/diffusion-point-cloud")
11
  sys.path.append("diffusion-point-cloud")
12
 
 
13
 
14
  from models.vae_gaussian import *
15
  from models.vae_flow import *
@@ -44,7 +45,10 @@ def normalize_point_clouds(pcs,mode):
44
  pcs[i] = pc
45
  return pcs
46
 
47
- def predict(Seed,ckpt):
 
 
 
48
  if Seed==None:
49
  Seed=777
50
  seed_all(Seed)
@@ -59,14 +63,14 @@ def predict(Seed,ckpt):
59
  gen_pcs = []
60
  with torch.no_grad():
61
  z = torch.randn([1, ckpt['args'].latent_dim]).to(device)
62
- x = model.sample(z, 2048, flexibility=ckpt['args'].flexibility)
63
  gen_pcs.append(x.detach().cpu())
64
  gen_pcs = torch.cat(gen_pcs, dim=0)[:1]
65
  gen_pcs = normalize_point_clouds(gen_pcs, mode="shape_bbox")
66
 
67
  return gen_pcs[0]
68
 
69
- def generate(seed,value):
70
  if value=="Airplane":
71
  ckpt=ckpt_airplane
72
  elif value=="Chair":
@@ -75,7 +79,7 @@ def generate(seed,value):
75
  ckpt=ckpt_airplane
76
 
77
  colors=(238, 75, 43)
78
- points=predict(seed,ckpt)
79
  num_points=points.shape[0]
80
 
81
 
@@ -99,9 +103,18 @@ def generate(seed,value):
99
 
100
  markdown=f'''
101
  # Diffusion Probabilistic Models for 3D Point Cloud Generation
 
 
102
  [The space demo for the CVPR 2021 paper "Diffusion Probabilistic Models for 3D Point Cloud Generation".](https://arxiv.org/abs/2103.01458)
 
103
  [For the official implementation.](https://github.com/luost26/diffusion-point-cloud)
104
 
 
 
 
 
 
 
105
  It is running on {device}
106
 
107
 
@@ -113,6 +126,7 @@ with gr.Blocks() as demo:
113
  with gr.Row():
114
  seed = gr.Slider( minimum=0, maximum=2**16,label='Seed')
115
  value=gr.Dropdown(choices=["Airplane","Chair"],label="Choose Model Type")
 
116
 
117
  btn = gr.Button(value="Generate")
118
  point_cloud = gr.Plot()
 
10
  os.system("git clone https://github.com/luost26/diffusion-point-cloud")
11
  sys.path.append("diffusion-point-cloud")
12
 
13
+ #Codes reference : https://github.com/luost26/diffusion-point-cloud
14
 
15
  from models.vae_gaussian import *
16
  from models.vae_flow import *
 
45
  pcs[i] = pc
46
  return pcs
47
 
48
+
49
+
50
+
51
+ def predict(Seed,ckpt,truncate_std):
52
  if Seed==None:
53
  Seed=777
54
  seed_all(Seed)
 
63
  gen_pcs = []
64
  with torch.no_grad():
65
  z = torch.randn([1, ckpt['args'].latent_dim]).to(device)
66
+ x = model.sample(z, 2048, flexibility=ckpt['args'].flexibility,truncate_std=truncate_std))
67
  gen_pcs.append(x.detach().cpu())
68
  gen_pcs = torch.cat(gen_pcs, dim=0)[:1]
69
  gen_pcs = normalize_point_clouds(gen_pcs, mode="shape_bbox")
70
 
71
  return gen_pcs[0]
72
 
73
+ def generate(seed,value,truncate_std):
74
  if value=="Airplane":
75
  ckpt=ckpt_airplane
76
  elif value=="Chair":
 
79
  ckpt=ckpt_airplane
80
 
81
  colors=(238, 75, 43)
82
+ points=predict(seed,ckpt,truncate_std)
83
  num_points=points.shape[0]
84
 
85
 
 
103
 
104
  markdown=f'''
105
  # Diffusion Probabilistic Models for 3D Point Cloud Generation
106
+
107
+
108
  [The space demo for the CVPR 2021 paper "Diffusion Probabilistic Models for 3D Point Cloud Generation".](https://arxiv.org/abs/2103.01458)
109
+
110
  [For the official implementation.](https://github.com/luost26/diffusion-point-cloud)
111
 
112
+ ### Future Work based on interest
113
+ - Adding new models for new type objects
114
+ - New Customization
115
+
116
+
117
+
118
  It is running on {device}
119
 
120
 
 
126
  with gr.Row():
127
  seed = gr.Slider( minimum=0, maximum=2**16,label='Seed')
128
  value=gr.Dropdown(choices=["Airplane","Chair"],label="Choose Model Type")
129
+ truncate_std = gr.Slider( minimum=1, maximum=2,label='Truncate Std')
130
 
131
  btn = gr.Button(value="Generate")
132
  point_cloud = gr.Plot()