alexnasa commited on
Commit
1a9a496
Β·
verified Β·
1 Parent(s): be0edb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -128,12 +128,12 @@ def preprocess_image(image_array, session_id):
128
  # Step 2: Normals inference β†’ normals image
129
  @spaces.GPU()
130
  def step2_normals(session_id):
131
-
 
132
  base_conf = OmegaConf.load("configs/base.yaml")
133
 
134
  if "normals_model" not in _model_cache:
135
- from pixel3dmm.lightning.p3dmm_system import system as p3dmm_system
136
-
137
  model = p3dmm_system.load_from_checkpoint(f"{env_paths.CKPT_N_PRED}", strict=False)
138
  model = model.eval().to(DEVICE)
139
  _model_cache["normals_model"] = model
@@ -149,12 +149,12 @@ def step2_normals(session_id):
149
  # Step 3: UV map inference β†’ uv map image
150
  @spaces.GPU()
151
  def step3_uv_map(session_id):
152
-
 
153
  base_conf = OmegaConf.load("configs/base.yaml")
154
 
155
  if "uv_model" not in _model_cache:
156
- from pixel3dmm.lightning.p3dmm_system import system as p3dmm_system
157
-
158
  model = p3dmm_system.load_from_checkpoint(f"{env_paths.CKPT_UV_PRED}", strict=False)
159
  model = model.eval().to(DEVICE)
160
  _model_cache["uv_model"] = model
@@ -171,21 +171,21 @@ def step3_uv_map(session_id):
171
  # Step 4: Tracking β†’ final tracking image
172
  @spaces.GPU()
173
  def step4_track(session_id):
174
-
 
 
 
 
 
 
 
 
 
175
  tracking_conf = OmegaConf.load("configs/tracking.yaml")
176
 
177
  # Lazy init + caching of FLAME model on GPU
178
  if "flame_model" not in _model_cache:
179
- import os
180
- import torch
181
- import numpy as np
182
- import trimesh
183
- from pytorch3d.io import load_obj
184
-
185
- from pixel3dmm.tracking.flame.FLAME import FLAME
186
- from pixel3dmm.tracking.renderer_nvdiffrast import NVDRenderer
187
- from pixel3dmm.tracking.tracker import Tracker
188
-
189
  flame = FLAME(tracking_conf) # CPU instantiation
190
  flame = flame.to(DEVICE) # CUDA init happens here
191
  _model_cache["flame_model"] = flame
 
128
  # Step 2: Normals inference β†’ normals image
129
  @spaces.GPU()
130
  def step2_normals(session_id):
131
+ from pixel3dmm.lightning.p3dmm_system import system as p3dmm_system
132
+
133
  base_conf = OmegaConf.load("configs/base.yaml")
134
 
135
  if "normals_model" not in _model_cache:
136
+
 
137
  model = p3dmm_system.load_from_checkpoint(f"{env_paths.CKPT_N_PRED}", strict=False)
138
  model = model.eval().to(DEVICE)
139
  _model_cache["normals_model"] = model
 
149
  # Step 3: UV map inference β†’ uv map image
150
  @spaces.GPU()
151
  def step3_uv_map(session_id):
152
+ from pixel3dmm.lightning.p3dmm_system import system as p3dmm_system
153
+
154
  base_conf = OmegaConf.load("configs/base.yaml")
155
 
156
  if "uv_model" not in _model_cache:
157
+
 
158
  model = p3dmm_system.load_from_checkpoint(f"{env_paths.CKPT_UV_PRED}", strict=False)
159
  model = model.eval().to(DEVICE)
160
  _model_cache["uv_model"] = model
 
171
  # Step 4: Tracking β†’ final tracking image
172
  @spaces.GPU()
173
  def step4_track(session_id):
174
+ import os
175
+ import torch
176
+ import numpy as np
177
+ import trimesh
178
+ from pytorch3d.io import load_obj
179
+
180
+ from pixel3dmm.tracking.flame.FLAME import FLAME
181
+ from pixel3dmm.tracking.renderer_nvdiffrast import NVDRenderer
182
+ from pixel3dmm.tracking.tracker import Tracker
183
+
184
  tracking_conf = OmegaConf.load("configs/tracking.yaml")
185
 
186
  # Lazy init + caching of FLAME model on GPU
187
  if "flame_model" not in _model_cache:
188
+
 
 
 
 
 
 
 
 
 
189
  flame = FLAME(tracking_conf) # CPU instantiation
190
  flame = flame.to(DEVICE) # CUDA init happens here
191
  _model_cache["flame_model"] = flame