madebyollin / maple-diffusion

Stable Diffusion inference on iOS / macOS using MPSGraph
https://madebyoll.in/posts/maple_diffusion/
MIT License
793 stars 51 forks source link

Fatal error: Unexpectedly found nil while unwrapping an Optional value #18

Closed Moebits closed 1 year ago

Moebits commented 1 year ago

I ran all the steps but I get this error whenever I run the project.

2022-10-20 09:15:18.949607-0400 maple-diffusion[47219:9588173] Metal GPU Frame Capture Enabled
2022-10-20 09:15:18.949813-0400 maple-diffusion[47219:9588173] Metal API Validation Enabled
maple_diffusion/MapleDiffusion.swift:18: Fatal error: Unexpectedly found nil while unwrapping an Optional value
2022-10-20 09:15:20.564156-0400 maple-diffusion[47219:9588746] maple_diffusion/MapleDiffusion.swift:18: Fatal error: Unexpectedly found nil while unwrapping an Optional value

I am using the NovelAI model not the original Stable Diffusion.

madebyollin commented 1 year ago

There's probably some tensor that is present in the original SD ckpt but not in the NAI one. You can add a print("loading bin file \(name)") before line 18 (or just check the name variable in Xcode's debugger) to see which filename is failing to load. From there you can figure out how to get it into the bins folder (you might be able to copy the missing file from the original ckpt, or modify the conversion script, or something else, not sure since I haven't messed with the NAI model 🤷).

Moebits commented 1 year ago

I got to run by running these commands in order: ./maple-convert.py ~/Downloads/sd-v1-4.ckpt ./maple-convert.py ~/Downloads/novelai.ckpt

I assume that the bins that are the same just got replaced. However, even though it runs a bit faster than the webui the results seem to be a lot worse. This isn't the result that you would expect from the NovelAI model. I don't think this supports other models apart from SD, unfortunately.

スクリーンショット 2022-10-20 午後3 09 02
alelordelo commented 1 year ago

HI @Tenpi , I also ran into the same issue... https://github.com/madebyollin/maple-diffusion/issues/22

Did you manage to make this work with other models? I am trying with DreamBooth