kkytai commited on
Commit ·
11d85c0
1
Parent(s): d820660
fix: move PuLID components to GPU before ID embedding extraction
Browse filesWhen offload mode is enabled, PuLID face analysis components stay on CPU.
The _register_character method was calling get_id_embedding without first
moving these components to GPU, causing a device mismatch error:
'Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor)'
Now properly calls components_to_device(cuda) before ID extraction and
moves back to CPU afterwards to maintain memory efficiency.
243 unmodified lines244245246247248249250251252253254243 unmodified linesfrom pulid.utils import resize_numpy_image_longimg_array = resize_numpy_image_long(img_array, 1024)# Extract ID embedding using PuLID pipelineid_embedding, uncond_embedding = self._generator.pulid_model.get_id_embedding(img_array, cal_uncond=True)# Generate unique ID and cachechar_id = str(uuid.uuid4())self.embedding_cache[char_id] = {243 unmodified lines244245246247248249250251252253254255256257258259260261262263264243 unmodified linesfrom pulid.utils import resize_numpy_image_longimg_array = resize_numpy_image_long(img_array, 1024)# Move PuLID face analysis components to GPU when offload is enabled# This is required because offload mode keeps components on CPU by defaultif self.use_offload:self._generator.pulid_model.components_to_device(torch.device("cuda"))# Extract ID embedding using PuLID pipelineid_embedding, uncond_embedding = self._generator.pulid_model.get_id_embedding(img_array, cal_uncond=True)# Move components back to CPU if offload is enabled to free GPU memoryif self.use_offload:self._generator.pulid_model.components_to_device(torch.device("cpu"))torch.cuda.empty_cache()# Generate unique ID and cachechar_id = str(uuid.uuid4())self.embedding_cache[char_id] = {
handler.py+10