lionelgarnier commited on
Commit
5e2ea0f
·
1 Parent(s): ac52c1d

refactor image_to_3d to support numpy arrays and improve error handling

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -312,7 +312,7 @@ def unpack_state(state: dict) -> Tuple[Gaussian, edict, str]:
312
 
313
  @spaces.GPU
314
  def image_to_3d(
315
- image: Image.Image,
316
  seed: int,
317
  ss_guidance_strength: float,
318
  ss_sampling_steps: int,
@@ -332,8 +332,15 @@ def image_to_3d(
332
  # Call cuda() here in the GPU worker process
333
  pipeline.cuda()
334
 
 
 
 
 
 
 
 
335
  outputs = pipeline.run(
336
- image,
337
  seed=seed,
338
  formats=["gaussian", "mesh"],
339
  preprocess_image=False,
@@ -357,6 +364,8 @@ def image_to_3d(
357
  return state, video_path
358
  except Exception as e:
359
  print(f"Error in image_to_3d: {str(e)}")
 
 
360
  return None, f"Error generating 3D model: {str(e)}"
361
 
362
 
@@ -618,3 +627,4 @@ if __name__ == "__main__":
618
 
619
  demo = create_interface()
620
  demo.launch(debug=True)
 
 
312
 
313
  @spaces.GPU
314
  def image_to_3d(
315
+ image,
316
  seed: int,
317
  ss_guidance_strength: float,
318
  ss_sampling_steps: int,
 
332
  # Call cuda() here in the GPU worker process
333
  pipeline.cuda()
334
 
335
+ # Convert image to the right format if needed
336
+ if isinstance(image, np.ndarray):
337
+ image = Image.fromarray(image.astype('uint8'))
338
+
339
+ # Make sure we have a list of images as expected by the pipeline
340
+ input_image = [image]
341
+
342
  outputs = pipeline.run(
343
+ input_image,
344
  seed=seed,
345
  formats=["gaussian", "mesh"],
346
  preprocess_image=False,
 
364
  return state, video_path
365
  except Exception as e:
366
  print(f"Error in image_to_3d: {str(e)}")
367
+ import traceback
368
+ traceback.print_exc() # Print the full stack trace for debugging
369
  return None, f"Error generating 3D model: {str(e)}"
370
 
371
 
 
627
 
628
  demo = create_interface()
629
  demo.launch(debug=True)
630
+