GuernikaCore / GuernikaKit

MIT License
39 stars 10 forks source link

Crashes: Unexpectedly found nil while unwrapping an Optional value #2

Open Dalchrome opened 9 months ago

Dalchrome commented 9 months ago

I have been trying to get guenika kit working with different models and keep running in to this error through different pipelines.. let inputImageShape = metadata.inputSchema[name: "z"]!.shape GuernikaKit/Encoder.swift:41: Fatal error: Unexpectedly found nil while unwrapping an Optional value My models, don't work in the App Store Guernika either, which looks like is behind guernika kit on samplers

Models I had trouble with are turbo models, which were either converted by someone else for sdxl-turbo, or I couldn't get to convert with your program so I used terminal with sd-turbo, which I have running on an apple coreML stable diffusion with lcm. I am pretty sure that the issue is with the way that Guernika looks for metadata, that my models seem to have in a different format. Is there currently a way to bypass the metadata check and give the variables manually? or is there a way I could add metadata that Guernika likes to the models manually?

here are the models that are causing issues https://huggingface.co/collections/BloggsMr/coreml-models-6586d877bbb04840e35a8d5c

Here is the code I was using, which works fine with your models.


        do {
            let sampleInput = SampleInput(
                size: CGSize(width: 512, height: 512),
                prompt: "a pretty bottle",
                negativePrompt: "",
                seed: 123456 ,
                stepCount: 2 ,
                guidanceScale: 1.0 ,
                scheduler: .lcm //tried others too
            )
            print("0 - settings: \(sampleInput)")
            let filepath = "\(vars.ModelFolder)/\(vars.CurrentModel)"
            let baseUrl = URL(fileURLWithPath: filepath)
            print(filepath)
                let specificPipeline = try GuernikaKit.load(at: baseUrl) as!  StableDiffusionXLPipeline
                if let image = try specificPipeline.generateImages(input: sampleInput) {
                    vars.GeneratedImage = image
}```

Edit- The answer was to only use models from Guernika huggingface or convert using Guernika Model Converter, But this is useful info that will probably affect other people so I'll leave it here.