mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-10-28 07:23:20 +08:00
fix: open model files with UTF-8 paths on Windows (#2144)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <cinttypes>
|
||||
#include <cstdarg>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
@@ -333,7 +334,7 @@ bool ModelLoader::init_from_safetensors_index_file(const std::string& file_path,
|
||||
}
|
||||
}
|
||||
|
||||
std::ifstream index_file(file_path);
|
||||
std::ifstream index_file(std::filesystem::u8path(file_path));
|
||||
const auto index = nlohmann::json::parse(index_file);
|
||||
for (const auto& entry : index.at("weight_map").items()) {
|
||||
const auto expected = (std::filesystem::u8path(file_path).parent_path() /
|
||||
@@ -1150,7 +1151,7 @@ bool ModelLoader::load_tensors(on_new_tensor_cb_t on_new_tensor_cb,
|
||||
return;
|
||||
}
|
||||
} else if (!mmapped) {
|
||||
file.open(file_path, std::ios::binary);
|
||||
file.open(std::filesystem::u8path(file_path), std::ios::binary);
|
||||
if (!file.is_open()) {
|
||||
LOG_ERROR("failed to open '%s'", file_path.c_str());
|
||||
failed = true;
|
||||
|
||||
Reference in New Issue
Block a user