cassiebreviu / StableDiffusion

Inference Stable Diffusion with C# and ONNX Runtime
MIT License
218 stars 49 forks source link

Error when running on cpu #31

Closed LeonNerd closed 10 months ago

LeonNerd commented 10 months ago

My tool is vs2022,net6.0, I can rebuild the project from sln When I configured the model path and chose to run cpu only,an error will occur. ''' Microsoft.ML.OnnxRuntime.OnnxRuntimeException:“[ErrorCode:InvalidArgument] Tensor element data type discovered: Int64 metadata expected: Float” '''

''' I checked the code location is UNet.cs line105 input = CreateUnetModelInput(textEmbeddings, latentModelInput, timesteps[t]); // Run Inference var output = unetSession.Run(input); ''' input is a list with three objects.I don't know why this mistake happened,I guess it's because of the onnxruntime version. But the onnxruntime is built automatically by sln

cassiebreviu commented 10 months ago

One of your input types has Int64 instead of float. You need to update the input type to match what the model expects. You can use a tool like Netron to figure out which input value is wrong.