d8ahazard / sd_smartprocess

Smart Pre-processing extension for Stable Diffusion
191 stars 19 forks source link

Mac M1 Issues #15

Open glitchyg opened 1 year ago

glitchyg commented 1 year ago

I have been setting this up on my mac, and I wanted to give some details on issues I had and what I did to fix it:

Loading Yolo model on crop:

Error: Error: buffer is not large enough. Must be 307200 bytes

Solution: Caused by pytorch bug on M1 Mac, Upgraded my pytorch and vision pip install torch==1.13 torchvision==0.14.1

Torch not compiled with CUDA enabled

This was caused by some code calling .cuda() clipcrop.py, line 78

I fixed it with this code:

        device_name = "cuda"
        if torch.backends.mps.is_available():
            device_name = "mps"

        device = torch.device(device_name)

        image_features.cpu().numpy()
        image_mean = torch.tensor(
            [0.48145466, 0.4578275, 0.40821073], device=device)
        image_std = torch.tensor(
            [0.26862954, 0.26130258, 0.27577711], device=device)

        images = [preprocess(im) for im in l]
        image_input = torch.tensor(np.stack(images), device=device)

After this i was able to get it running. Thanks for the awesome tool!

dirtstudio commented 1 year ago

Thank for this - I think this has worked for me