add
Browse files
app.py
CHANGED
|
@@ -79,13 +79,12 @@ ehm_model.head.load_state_dict(_state['head'], strict=False)
|
|
| 79 |
ehm = EHM_v2("assets/FLAME", "assets/SMPLX", "assets/MANO")
|
| 80 |
|
| 81 |
|
| 82 |
-
lights = PointLights(device=TORCH_DEVICE, location=[[0.0, -1.0, -10.0]])
|
| 83 |
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
-
if TORCH_DEVICE.type == "cuda":
|
| 86 |
-
body_renderer = body_renderer.cuda()
|
| 87 |
-
ehm_model = ehm_model.cuda()
|
| 88 |
-
ehm = ehm.cuda()
|
| 89 |
|
| 90 |
|
| 91 |
|
|
@@ -259,10 +258,15 @@ def handle_video_upload(video):
|
|
| 259 |
return (json.dumps(frame_data) )
|
| 260 |
|
| 261 |
@spaces.GPU
|
| 262 |
-
def mesh_inference(
|
| 263 |
-
"""Run mesh inference on uploaded video"""
|
| 264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
|
|
|
|
| 266 |
# Setup paths
|
| 267 |
video_path = os.path.join(temp_dir, f"{video_name}.mp4")
|
| 268 |
|
|
|
|
| 79 |
ehm = EHM_v2("assets/FLAME", "assets/SMPLX", "assets/MANO")
|
| 80 |
|
| 81 |
|
| 82 |
+
# lights = PointLights(device=TORCH_DEVICE, location=[[0.0, -1.0, -10.0]])
|
| 83 |
|
| 84 |
+
# 2. 将 lights 的初始化移入函数,或确保它能动态转换
|
| 85 |
+
def get_lights(device):
|
| 86 |
+
return PointLights(device=device, location=[[0.0, -1.0, -10.0]])
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
|
|
|
|
| 258 |
return (json.dumps(frame_data) )
|
| 259 |
|
| 260 |
@spaces.GPU
|
| 261 |
+
def mesh_inference(temp_dir, video_name):
|
|
|
|
| 262 |
|
| 263 |
+
global body_renderer, ehm_model, ehm
|
| 264 |
+
body_renderer = body_renderer.to(TORCH_DEVICE)
|
| 265 |
+
ehm_model = ehm_model.to(TORCH_DEVICE)
|
| 266 |
+
ehm = ehm.to(TORCH_DEVICE)
|
| 267 |
+
lights = get_lights(TORCH_DEVICE)
|
| 268 |
|
| 269 |
+
# ... 后续推理逻辑 ...
|
| 270 |
# Setup paths
|
| 271 |
video_path = os.path.join(temp_dir, f"{video_name}.mp4")
|
| 272 |
|