remove tensor renaming; fixing names in the photomaker model file

This commit is contained in:
bssrdf
2024-02-26 14:37:04 -05:00
parent 77b6a42bc3
commit 464f1f8d8b
4 changed files with 6 additions and 16 deletions

View File

@@ -699,10 +699,10 @@ int main(int argc, const char* argv[]) {
int width, height;
input_image_buffer = stbi_load(img_file.c_str(), &width, &height, &c, 3);
if (input_image_buffer == NULL) {
fprintf(stderr, "load image from '%s' failed\n", img_file.c_str());
LOG_ERROR("PhotoMaker load image from '%s' failed", img_file.c_str());
return 1;
}else{
fprintf(stderr, "successfully loaded image from '%s' \n", img_file.c_str());
LOG_INFO("PhotoMaker loaded image from '%s'", img_file.c_str());
}
sd_image_t* input_image = NULL;
input_image = new sd_image_t{(uint32_t)width,
@@ -711,7 +711,7 @@ int main(int argc, const char* argv[]) {
input_image_buffer};
input_image = preprocess_id_image(input_image);
if(input_image == NULL){
fprintf(stderr, "preprocess input id image from '%s' failed\n", img_file.c_str());
LOG_ERROR("preprocess input id image from '%s' failed", img_file.c_str());
return 1;
}
input_id_images.push_back(input_image);

View File

@@ -828,17 +828,7 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
return false;
}
}
// fix photomaker model file to remove the following name fix
size_t pos = name.find("layrnorm");
if(pos != std::string::npos){
name.replace(pos, strlen("layrnorm"), "layernorm");
}
if(starts_with(prefix, "pmid")){
pos = name.find("visual_projection.w");
if(pos != std::string::npos){
name.replace(0, 0, "vision_model.");
}
}
TensorStorage tensor_storage(prefix + name, type, ne, n_dims, file_index, ST_HEADER_SIZE_LEN + header_size_ + begin);
tensor_storage.reverse_ne();

View File

@@ -361,7 +361,7 @@ public:
size_t get_params_mem_size() {
size_t params_mem_size = vision_model.get_params_mem_size();
params_mem_size += fuse_module.get_params_mem_size();
params_mem_size += ggml_row_size(wtype, 1280*1024);
params_mem_size += visual_projection_2.get_params_mem_size();
return params_mem_size;
}

View File

@@ -374,7 +374,7 @@ public:
unet_params_mem_size / 1024.0 / 1024.0,
vae_params_mem_size / 1024.0 / 1024.0,
control_net_params_mem_size / 1024.0 / 1024.0,
pmid_params_mem_size);
pmid_params_mem_size/ 1024.0 / 1024.0);
}
int64_t t1 = ggml_time_ms();