StableDiffusion.NET icon indicating copy to clipboard operation
StableDiffusion.NET copied to clipboard

Model initialization failed when run after installed

Open billqu01 opened this issue 1 year ago • 1 comments

image I am using a. NET 8 winform program, which can run directly in VS2022 without any issues. However, when packaged as a. msix package and installed on my computer, an error message appears as shown in the picture above. May I ask how to solve this?

my codes: public Form1() { InitializeComponent(); //this.BackColor = System.Drawing.Color.FromArgb(40, 48, 51); InitModel(); }

private void InitModel() { try { // 获取当前应用的安装目录 //string model_folder = Path.Combine(AppContext.BaseDirectory, "model"); string app_folder = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); string model_folder = Path.Combine(app_folder, "model");

    // 构建完整的模型路径
    var fluxPath = Path.Combine(model_folder, "flux1-schnell-q4_k.gguf");
    var clipPath = Path.Combine(model_folder, "clip_l.safetensors");
    var t5xxlPath = Path.Combine(model_folder, "t5xxl_fp8_e4m3fn.safetensors");
    var aePath = Path.Combine(model_folder, "ae.safetensors");

    // 初始化模型
    model = ModelBuilder.Flux(fluxPath, clipPath, t5xxlPath, aePath)
                    .WithMultithreading()
                    .Build();


    // 如果有需要,可以在模型初始化后执行其他任务
}
catch (Exception ex)
{
    // 记录错误日志
    System.Diagnostics.Debug.WriteLine($"Model initialization failed: {ex.Message}");
    // 显示错误信息给用户
    MessageBox.Show(this, $"Model initialization failed: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

}

billqu01 avatar Dec 18 '24 08:12 billqu01

This looks like the stable-diffusion.dll is not packed/installed and therefore not found. Have you verified, that it is placed in the installation directory?

DarthAffe avatar Dec 19 '24 12:12 DarthAffe