xnikkon commited on
Commit
2351387
·
verified ·
1 Parent(s): c840ad0

Update routers/models.py

Browse files
Files changed (1) hide show
  1. routers/models.py +7 -28
routers/models.py CHANGED
@@ -69,24 +69,6 @@ def get_hf_service():
69
  return hf_service
70
 
71
 
72
- def cleanup_model_file(glb_path: Path):
73
- """Cleanup function to delete model file after download.
74
-
75
- This runs as a background task after the response is sent to the client.
76
-
77
- Args:
78
- glb_path: Path to the GLB file to delete
79
- """
80
- try:
81
- if glb_path.exists():
82
- glb_path.unlink()
83
- logger.info(f"✓ Deleted GLB file after download: {glb_path}")
84
- else:
85
- logger.warning(f"GLB file not found for deletion: {glb_path}")
86
- except Exception as delete_error:
87
- logger.warning(f"Failed to delete GLB file after download: {delete_error}")
88
-
89
-
90
  @router.post("/generate", response_model=GenerationResponse)
91
  async def generate_model(request: PromptRequest):
92
  """Generate a 3D model from a text prompt.
@@ -199,21 +181,18 @@ async def download_model(model_id: str, background_tasks: BackgroundTasks):
199
  raise HTTPException(status_code=404, detail="Model file not found")
200
 
201
  try:
202
- # Apply brightness normalization to GLB file before serving
203
- logger.info("Applying brightness normalization to GLB file...")
204
- # normalize_materials_for_ar(glb_path)
 
 
205
  logger.info("✓ Brightness normalization applied to GLB")
206
 
207
- # Read normalized GLB file content
208
  with open(glb_path, "rb") as f:
209
  glb_content = f.read()
210
 
211
- logger.info(
212
- f"Serving normalized GLB file: {glb_path} ({len(glb_content)} bytes)"
213
- )
214
-
215
- # Schedule cleanup task to run after response is sent
216
- # background_tasks.add_task(cleanup_model_file, glb_path)
217
 
218
  # Create response
219
  response = Response(
 
69
  return hf_service
70
 
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  @router.post("/generate", response_model=GenerationResponse)
73
  async def generate_model(request: PromptRequest):
74
  """Generate a 3D model from a text prompt.
 
181
  raise HTTPException(status_code=404, detail="Model file not found")
182
 
183
  try:
184
+ # Apply brightness normalization for AR visibility before serving
185
+ logger.info(
186
+ "Applying brightness normalization to GLB file for AR visibility..."
187
+ )
188
+ normalize_materials_for_ar(glb_path)
189
  logger.info("✓ Brightness normalization applied to GLB")
190
 
191
+ # Read GLB file content
192
  with open(glb_path, "rb") as f:
193
  glb_content = f.read()
194
 
195
+ logger.info(f"Serving GLB file: {glb_path} ({len(glb_content)} bytes)")
 
 
 
 
 
196
 
197
  # Create response
198
  response = Response(