JiantaoLin
commited on
Commit
·
adbf5da
1
Parent(s):
9ba89f6
new
Browse files- pipeline/kiss3d_wrapper.py +28 -25
pipeline/kiss3d_wrapper.py
CHANGED
@@ -102,34 +102,37 @@ def init_wrapper_from_config(config_path):
|
|
102 |
# TODO: load pulid model
|
103 |
|
104 |
# init multiview model
|
105 |
-
logger.info('==> Loading multiview diffusion model ...')
|
106 |
-
multiview_device = config_['multiview'].get('device', 'cpu')
|
107 |
-
multiview_pipeline = DiffusionPipeline.from_pretrained(
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
)
|
112 |
-
multiview_pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(
|
113 |
-
|
114 |
-
)
|
115 |
|
116 |
-
# unet_ckpt_path = hf_hub_download(repo_id="LTT/Kiss3DGen", filename="flexgen_19w.ckpt", repo_type="model", token=access_token)
|
117 |
-
unet_ckpt_path = hf_hub_download(repo_id="LTT/Kiss3DGen", filename="flexgen.ckpt", repo_type="model", token=access_token)
|
118 |
-
if unet_ckpt_path is not None:
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
122 |
|
123 |
-
multiview_pipeline.to(multiview_device)
|
124 |
-
logger.warning(f"GPU memory allocated after load multiview model on {multiview_device}: {torch.cuda.memory_allocated(device=multiview_device) / 1024**3} GB")
|
125 |
|
126 |
# load caption model
|
127 |
-
logger.info('==> Loading caption model ...')
|
128 |
-
caption_device = config_['caption'].get('device', 'cpu')
|
129 |
-
caption_model = AutoModelForCausalLM.from_pretrained(config_['caption']['base_model'], \
|
130 |
-
|
131 |
-
caption_processor = AutoProcessor.from_pretrained(config_['caption']['base_model'], trust_remote_code=True)
|
132 |
-
logger.warning(f"GPU memory allocated after load caption model on {caption_device}: {torch.cuda.memory_allocated(device=caption_device) / 1024**3} GB")
|
|
|
133 |
|
134 |
# load reconstruction model
|
135 |
logger.info('==> Loading reconstruction model ...')
|
@@ -147,7 +150,7 @@ def init_wrapper_from_config(config_path):
|
|
147 |
|
148 |
# load llm
|
149 |
llm_configs = config_.get('llm', None)
|
150 |
-
if llm_configs is not None:
|
151 |
logger.info('==> Loading LLM ...')
|
152 |
llm_device = llm_configs.get('device', 'cpu')
|
153 |
llm, llm_tokenizer = load_llm_model(llm_configs['base_model'])
|
|
|
102 |
# TODO: load pulid model
|
103 |
|
104 |
# init multiview model
|
105 |
+
# logger.info('==> Loading multiview diffusion model ...')
|
106 |
+
# multiview_device = config_['multiview'].get('device', 'cpu')
|
107 |
+
# multiview_pipeline = DiffusionPipeline.from_pretrained(
|
108 |
+
# config_['multiview']['base_model'],
|
109 |
+
# custom_pipeline=config_['multiview']['custom_pipeline'],
|
110 |
+
# torch_dtype=torch.float16,
|
111 |
+
# )
|
112 |
+
# multiview_pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(
|
113 |
+
# multiview_pipeline.scheduler.config, timestep_spacing='trailing'
|
114 |
+
# )
|
115 |
|
116 |
+
# # unet_ckpt_path = hf_hub_download(repo_id="LTT/Kiss3DGen", filename="flexgen_19w.ckpt", repo_type="model", token=access_token)
|
117 |
+
# unet_ckpt_path = hf_hub_download(repo_id="LTT/Kiss3DGen", filename="flexgen.ckpt", repo_type="model", token=access_token)
|
118 |
+
# if unet_ckpt_path is not None:
|
119 |
+
# state_dict = torch.load(unet_ckpt_path, map_location='cpu')
|
120 |
+
# # state_dict = {k[10:]: v for k, v in state_dict.items() if k.startswith('unet.unet.')}
|
121 |
+
# multiview_pipeline.unet.load_state_dict(state_dict, strict=True)
|
122 |
+
|
123 |
+
# multiview_pipeline.to(multiview_device)
|
124 |
+
# logger.warning(f"GPU memory allocated after load multiview model on {multiview_device}: {torch.cuda.memory_allocated(device=multiview_device) / 1024**3} GB")
|
125 |
+
multiview_pipeline = None
|
126 |
|
|
|
|
|
127 |
|
128 |
# load caption model
|
129 |
+
# logger.info('==> Loading caption model ...')
|
130 |
+
# caption_device = config_['caption'].get('device', 'cpu')
|
131 |
+
# caption_model = AutoModelForCausalLM.from_pretrained(config_['caption']['base_model'], \
|
132 |
+
# torch_dtype=torch.bfloat16, trust_remote_code=True).to(caption_device)
|
133 |
+
# caption_processor = AutoProcessor.from_pretrained(config_['caption']['base_model'], trust_remote_code=True)
|
134 |
+
# logger.warning(f"GPU memory allocated after load caption model on {caption_device}: {torch.cuda.memory_allocated(device=caption_device) / 1024**3} GB")
|
135 |
+
caption_processor = None
|
136 |
|
137 |
# load reconstruction model
|
138 |
logger.info('==> Loading reconstruction model ...')
|
|
|
150 |
|
151 |
# load llm
|
152 |
llm_configs = config_.get('llm', None)
|
153 |
+
if llm_configs is not None and False:
|
154 |
logger.info('==> Loading LLM ...')
|
155 |
llm_device = llm_configs.get('device', 'cpu')
|
156 |
llm, llm_tokenizer = load_llm_model(llm_configs['base_model'])
|