Add sapiens2 matting as a mask generator. Begin transition to model paths and model folders.
This commit is contained in:
1 parent
15d4fb89ff
commit
aecd554128
8 files changed
+209
-34
No files matched your search
@@ -148,7 +148,7 @@ class ControlGenerator:
|
||||
img = img.convert('RGB')
|
||||
img.save(save_path)
|
||||
return save_path
|
||||
elif control_type == 'inpaint' or control_type == 'mask':
|
||||
elif control_type in ['inpaint', 'mask']:
|
||||
self.debug_print("Generating inpaint/mask control")
|
||||
img = image.copy()
|
||||
if self.control_bg_remover is None:
|
||||
@@ -188,6 +188,18 @@ class ControlGenerator:
|
||||
img = img.convert('RGB')
|
||||
img.save(save_path)
|
||||
return save_path
|
||||
elif control_type in ['sapiens2_mask']:
|
||||
self.debug_print("Generating sapiens2_mask control")
|
||||
if self.control_bg_remover is None:
|
||||
from toolkit.models.sapiens2 import Sapiens2Matting
|
||||
self.control_bg_remover = Sapiens2Matting.from_pretrained(
|
||||
device=device,
|
||||
dtype=torch.float16
|
||||
)
|
||||
img = image.copy()
|
||||
img = self.control_bg_remover(img)
|
||||
img.save(save_path)
|
||||
return save_path
|
||||
else:
|
||||
raise Exception(f"Error: unknown control type {control_type}")
|
||||
|
||||
|
||||
Reference in new issue
Block a user