xinjie.wang commited on
Commit
22e4e0c
·
1 Parent(s): 07dcc27
common.py CHANGED
@@ -165,7 +165,7 @@ if os.getenv("GRADIO_APP") == "imageto3d":
165
  RBG14_REMOVER = BMGG14Remover()
166
  SAM_PREDICTOR = SAMPredictor(model_type="vit_h", device="cpu")
167
  PIPELINE = TrellisImageTo3DPipeline.from_pretrained(
168
- "jetx/trellis-image-large"
169
  )
170
  # PIPELINE.cuda()
171
  SEG_CHECKER = ImageSegChecker(GPT_CLIENT)
@@ -179,7 +179,7 @@ elif os.getenv("GRADIO_APP") == "textto3d":
179
  RBG_REMOVER = RembgRemover()
180
  RBG14_REMOVER = BMGG14Remover()
181
  PIPELINE = TrellisImageTo3DPipeline.from_pretrained(
182
- "jetx/trellis-image-large"
183
  )
184
  # PIPELINE.cuda()
185
  text_model_dir = "weights/Kolors"
@@ -671,6 +671,7 @@ def text2image_fn(
671
  image_wh: int | tuple[int, int] = [1024, 1024],
672
  rmbg_tag: str = "rembg",
673
  n_sample: int = 3,
 
674
  req: gr.Request = None,
675
  ):
676
  if isinstance(image_wh, int):
@@ -692,6 +693,7 @@ def text2image_fn(
692
  ip_image=ip_image,
693
  image_wh=image_wh,
694
  infer_step=infer_step,
 
695
  )
696
 
697
  for idx in range(len(images)):
 
165
  RBG14_REMOVER = BMGG14Remover()
166
  SAM_PREDICTOR = SAMPredictor(model_type="vit_h", device="cpu")
167
  PIPELINE = TrellisImageTo3DPipeline.from_pretrained(
168
+ "microsoft/TRELLIS-image-large"
169
  )
170
  # PIPELINE.cuda()
171
  SEG_CHECKER = ImageSegChecker(GPT_CLIENT)
 
179
  RBG_REMOVER = RembgRemover()
180
  RBG14_REMOVER = BMGG14Remover()
181
  PIPELINE = TrellisImageTo3DPipeline.from_pretrained(
182
+ "microsoft/TRELLIS-image-large"
183
  )
184
  # PIPELINE.cuda()
185
  text_model_dir = "weights/Kolors"
 
671
  image_wh: int | tuple[int, int] = [1024, 1024],
672
  rmbg_tag: str = "rembg",
673
  n_sample: int = 3,
674
+ seed: int = None,
675
  req: gr.Request = None,
676
  ):
677
  if isinstance(image_wh, int):
 
693
  ip_image=ip_image,
694
  image_wh=image_wh,
695
  infer_step=infer_step,
696
+ seed=seed,
697
  )
698
 
699
  for idx in range(len(images)):
embodied_gen/models/text_model.py CHANGED
@@ -18,6 +18,8 @@
18
  import logging
19
 
20
  import torch
 
 
21
  from diffusers import (
22
  AutoencoderKL,
23
  EulerDiscreteScheduler,
@@ -138,11 +140,18 @@ def text2img_gen(
138
  image_wh: tuple[int, int] = [1024, 1024],
139
  infer_step: int = 50,
140
  ip_image_size: int = 512,
 
141
  ) -> list[Image.Image]:
142
  prompt = "Single " + prompt + ", in the center of the image"
143
  prompt += ", high quality, high resolution, best quality, white background, 3D style," # noqa
144
  logger.info(f"Processing prompt: {prompt}")
145
 
 
 
 
 
 
 
146
  kwargs = dict(
147
  prompt=prompt,
148
  height=image_wh[1],
@@ -150,6 +159,7 @@ def text2img_gen(
150
  num_inference_steps=infer_step,
151
  guidance_scale=guidance_scale,
152
  num_images_per_prompt=n_sample,
 
153
  )
154
  if ip_image is not None:
155
  if isinstance(ip_image, str):
 
18
  import logging
19
 
20
  import torch
21
+ import numpy as np
22
+ import random
23
  from diffusers import (
24
  AutoencoderKL,
25
  EulerDiscreteScheduler,
 
140
  image_wh: tuple[int, int] = [1024, 1024],
141
  infer_step: int = 50,
142
  ip_image_size: int = 512,
143
+ seed: int = None,
144
  ) -> list[Image.Image]:
145
  prompt = "Single " + prompt + ", in the center of the image"
146
  prompt += ", high quality, high resolution, best quality, white background, 3D style," # noqa
147
  logger.info(f"Processing prompt: {prompt}")
148
 
149
+ if seed is not None:
150
+ generator = torch.Generator(pipeline.device).manual_seed(seed)
151
+ torch.manual_seed(seed)
152
+ np.random.seed(seed)
153
+ random.seed(seed)
154
+
155
  kwargs = dict(
156
  prompt=prompt,
157
  height=image_wh[1],
 
159
  num_inference_steps=infer_step,
160
  guidance_scale=guidance_scale,
161
  num_images_per_prompt=n_sample,
162
+ generator=generator,
163
  )
164
  if ip_image is not None:
165
  if isinstance(ip_image, str):
embodied_gen/scripts/imageto3d.py CHANGED
@@ -70,7 +70,7 @@ IMAGESR_MODEL = ImageRealESRGAN(outscale=4)
70
  RBG_REMOVER = RembgRemover()
71
  RBG14_REMOVER = BMGG14Remover()
72
  SAM_PREDICTOR = SAMPredictor(model_type="vit_h", device="cpu")
73
- PIPELINE = TrellisImageTo3DPipeline.from_pretrained("jetx/trellis-image-large")
74
  PIPELINE.cuda()
75
  SEG_CHECKER = ImageSegChecker(GPT_CLIENT)
76
  GEO_CHECKER = MeshGeoChecker(GPT_CLIENT)
 
70
  RBG_REMOVER = RembgRemover()
71
  RBG14_REMOVER = BMGG14Remover()
72
  SAM_PREDICTOR = SAMPredictor(model_type="vit_h", device="cpu")
73
+ PIPELINE = TrellisImageTo3DPipeline.from_pretrained("microsoft/TRELLIS-image-large")
74
  PIPELINE.cuda()
75
  SEG_CHECKER = ImageSegChecker(GPT_CLIENT)
76
  GEO_CHECKER = MeshGeoChecker(GPT_CLIENT)
embodied_gen/scripts/text2image.py CHANGED
@@ -82,6 +82,11 @@ def parse_args():
82
  type=int,
83
  default=50,
84
  )
 
 
 
 
 
85
  args = parser.parse_args()
86
 
87
  return args
@@ -143,6 +148,7 @@ def entrypoint(
143
  ip_image=ip_img_path,
144
  image_wh=[args.resolution, args.resolution],
145
  infer_step=args.infer_step,
 
146
  )
147
 
148
  save_paths = []
 
82
  type=int,
83
  default=50,
84
  )
85
+ parser.add_argument(
86
+ "--seed",
87
+ type=int,
88
+ default=0,
89
+ )
90
  args = parser.parse_args()
91
 
92
  return args
 
148
  ip_image=ip_img_path,
149
  image_wh=[args.resolution, args.resolution],
150
  infer_step=args.infer_step,
151
+ seed=args.seed,
152
  )
153
 
154
  save_paths = []