xinjie.wang commited on
Commit
7cdd1a1
·
1 Parent(s): d4746a4
asset3d_gen/models/delight_model.py CHANGED
@@ -28,7 +28,7 @@ class DelightingModel(object):
28
  device: str = "cuda",
29
  seed: int = 0,
30
  ) -> None:
31
- self.model_path = model_path
32
  self.image_guide_scale = image_guide_scale
33
  self.text_guide_scale = text_guide_scale
34
  self.num_infer_step = num_infer_step
@@ -40,18 +40,19 @@ class DelightingModel(object):
40
  self.device = device
41
  self.pipeline = None # lazy load model adapt to @spaces.GPU
42
 
 
 
 
 
 
 
 
 
 
43
  def _lazy_init_pipeline(self):
44
  if self.pipeline is None:
45
- model_path = self.model_path
46
- if model_path is None:
47
- suffix = "hunyuan3d-delight-v2-0"
48
- model_path = snapshot_download(
49
- repo_id="tencent/Hunyuan3D-2", allow_patterns=f"{suffix}/*"
50
- )
51
- model_path = os.path.join(model_path, suffix)
52
-
53
  pipeline = StableDiffusionInstructPix2PixPipeline.from_pretrained(
54
- model_path,
55
  torch_dtype=torch.float16,
56
  safety_checker=None,
57
  )
 
28
  device: str = "cuda",
29
  seed: int = 0,
30
  ) -> None:
31
+
32
  self.image_guide_scale = image_guide_scale
33
  self.text_guide_scale = text_guide_scale
34
  self.num_infer_step = num_infer_step
 
40
  self.device = device
41
  self.pipeline = None # lazy load model adapt to @spaces.GPU
42
 
43
+ if model_path is None:
44
+ suffix = "hunyuan3d-delight-v2-0"
45
+ model_path = snapshot_download(
46
+ repo_id="tencent/Hunyuan3D-2", allow_patterns=f"{suffix}/*"
47
+ )
48
+ model_path = os.path.join(model_path, suffix)
49
+
50
+ self.model_path = model_path
51
+
52
  def _lazy_init_pipeline(self):
53
  if self.pipeline is None:
 
 
 
 
 
 
 
 
54
  pipeline = StableDiffusionInstructPix2PixPipeline.from_pretrained(
55
+ self.model_path,
56
  torch_dtype=torch.float16,
57
  safety_checker=None,
58
  )
asset3d_gen/models/sr_model.py CHANGED
@@ -73,8 +73,16 @@ class ImageRealESRGAN:
73
  sys.modules["torchvision.transforms.functional_tensor"] = functional_tensor
74
 
75
  self.outscale = outscale
76
- self.model_path = model_path
77
  self.upsampler = None
 
 
 
 
 
 
 
 
 
78
 
79
  def _lazy_init(self):
80
  if self.upsampler is None:
@@ -91,17 +99,9 @@ class ImageRealESRGAN:
91
  scale=4,
92
  )
93
 
94
- model_path = self.model_path
95
- if model_path is None:
96
- suffix = "super_resolution"
97
- model_path = snapshot_download(
98
- repo_id="xinjjj/RoboAssetGen", allow_patterns=f"{suffix}/*"
99
- )
100
- model_path = os.path.join(model_path, suffix, "RealESRGAN_x4plus.pth")
101
-
102
  self.upsampler = RealESRGANer(
103
  scale=4,
104
- model_path=model_path,
105
  model=model,
106
  pre_pad=0,
107
  half=True,
 
73
  sys.modules["torchvision.transforms.functional_tensor"] = functional_tensor
74
 
75
  self.outscale = outscale
 
76
  self.upsampler = None
77
+
78
+ if model_path is None:
79
+ suffix = "super_resolution"
80
+ model_path = snapshot_download(
81
+ repo_id="xinjjj/RoboAssetGen", allow_patterns=f"{suffix}/*"
82
+ )
83
+ model_path = os.path.join(model_path, suffix, "RealESRGAN_x4plus.pth")
84
+
85
+ self.model_path = model_path
86
 
87
  def _lazy_init(self):
88
  if self.upsampler is None:
 
99
  scale=4,
100
  )
101
 
 
 
 
 
 
 
 
 
102
  self.upsampler = RealESRGANer(
103
  scale=4,
104
+ model_path=self.model_path,
105
  model=model,
106
  pre_pad=0,
107
  half=True,