-
Notifications
You must be signed in to change notification settings - Fork 343
Open
Description
Trying to use the OneFormer-ADE20K-SemSegPreprocessor or COCO-Segmentor on MPS fails with
"Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead."
I looked into this and AI suggested to pin this to CPU when running on MPS, as I did not want to mess around with the dtypes (no significant impact in overall processing time when I use CPU).
I used a very quick n dirty fix in oneformer.py. I'm not sure if this really fixes the issue as alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union-2.1 doesn't seem to understand the segmentation map which resulted after this fix, but maybe it's a starting point.
from ..utils import common_annotator_call, define_preprocessor_inputs, INPUT
import comfy.model_management as model_management
class OneFormer_COCO_SemSegPreprocessor:
@classmethod
def INPUT_TYPES(s):
return define_preprocessor_inputs(resolution=INPUT.RESOLUTION())
RETURN_TYPES = ("IMAGE",)
FUNCTION = "semantic_segmentate"
CATEGORY = "ControlNet Preprocessors/Semantic Segmentation"
def semantic_segmentate(self, image, resolution=512):
from custom_controlnet_aux.oneformer import OneformerSegmentor
model = OneformerSegmentor.from_pretrained(filename="150_16_swin_l_oneformer_coco_100ep.pth")
## original
# model = model.to(model_management.get_torch_device())
import torch
from comfy import model_management
model = model.to(torch.device("cpu"))
out = common_annotator_call(model, image, resolution=resolution)
del model
return (out,)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels