JeffreyXiang commited on
Commit
fbc801f
·
1 Parent(s): 2e78ab8
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -19,7 +19,7 @@ from trellis.utils import render_utils, postprocessing_utils
19
  MAX_SEED = np.iinfo(np.int32).max
20
 
21
 
22
- def preprocess_image(image: Image.Image) -> Tuple[np.ndarray, Image.Image]:
23
  """
24
  Preprocess the input image.
25
 
@@ -31,7 +31,7 @@ def preprocess_image(image: Image.Image) -> Tuple[np.ndarray, Image.Image]:
31
  Image.Image: The preprocessed image.
32
  """
33
  processed_image = pipeline.preprocess_image(image)
34
- return np.array(processed_image), processed_image
35
 
36
 
37
  def pack_state(gs: Gaussian, mesh: MeshExtractResult, model_id: str) -> dict:
@@ -76,12 +76,12 @@ def unpack_state(state: dict) -> Tuple[Gaussian, edict, str]:
76
 
77
 
78
  @spaces.GPU
79
- def image_to_3d(image: np.array, seed: int, randomize_seed: bool, ss_guidance_strength: float, ss_sampling_steps: int, slat_guidance_strength: float, slat_sampling_steps: int) -> Tuple[dict, str]:
80
  """
81
  Convert an image to a 3D model.
82
 
83
  Args:
84
- image (np.array): The input image.
85
  seed (int): The random seed.
86
  randomize_seed (bool): Whether to randomize the seed.
87
  ss_guidance_strength (float): The guidance strength for sparse structure generation.
@@ -96,7 +96,7 @@ def image_to_3d(image: np.array, seed: int, randomize_seed: bool, ss_guidance_st
96
  if randomize_seed:
97
  seed = np.random.randint(0, MAX_SEED)
98
  outputs = pipeline.run(
99
- Image.fromarray(image),
100
  seed=seed,
101
  formats=["gaussian", "mesh"],
102
  preprocess_image=False,
 
19
  MAX_SEED = np.iinfo(np.int32).max
20
 
21
 
22
+ def preprocess_image(image: Image.Image) -> Tuple[dict, Image.Image]:
23
  """
24
  Preprocess the input image.
25
 
 
31
  Image.Image: The preprocessed image.
32
  """
33
  processed_image = pipeline.preprocess_image(image)
34
+ return {'image': np.array(processed_image)}, processed_image
35
 
36
 
37
  def pack_state(gs: Gaussian, mesh: MeshExtractResult, model_id: str) -> dict:
 
76
 
77
 
78
  @spaces.GPU
79
+ def image_to_3d(image: dict, seed: int, randomize_seed: bool, ss_guidance_strength: float, ss_sampling_steps: int, slat_guidance_strength: float, slat_sampling_steps: int) -> Tuple[dict, str]:
80
  """
81
  Convert an image to a 3D model.
82
 
83
  Args:
84
+ image (dict): The input image.
85
  seed (int): The random seed.
86
  randomize_seed (bool): Whether to randomize the seed.
87
  ss_guidance_strength (float): The guidance strength for sparse structure generation.
 
96
  if randomize_seed:
97
  seed = np.random.randint(0, MAX_SEED)
98
  outputs = pipeline.run(
99
+ Image.fromarray(image['image']),
100
  seed=seed,
101
  formats=["gaussian", "mesh"],
102
  preprocess_image=False,