Skip to content

Commit 38ccc05

Browse files
committed
some fixes
1 parent 5b7d179 commit 38ccc05

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ git submodule update
9494
#### Build from scratch
9595

9696
```shell
97-
git submodule init
98-
git submodule update
9997
mkdir build
10098
cd build
10199
cmake ..

examples/cli/main.cpp

+21-24
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct SDParams {
9696
bool vae_tiling = false;
9797
bool control_net_cpu = false;
9898
bool canny_preprocess = false;
99-
int upscale_repeats = 1;
99+
int upscale_repeats = 1;
100100
};
101101

102102
void print_params(SDParams params) {
@@ -174,7 +174,7 @@ void print_usage(int argc, const char* argv[]) {
174174
printf(" --vae-tiling process vae in tiles to reduce memory usage\n");
175175
printf(" --control-net-cpu keep controlnet in cpu (for low vram)\n");
176176
printf(" --canny apply canny preprocessor (edge detection)\n");
177-
printf(" -v, --verbose print extra info\n");
177+
printf(" -v, --verbose print extra info\n");
178178
}
179179

180180
void parse_args(int argc, const char** argv, SDParams& params) {
@@ -714,34 +714,31 @@ int main(int argc, const char* argv[]) {
714714

715715
int upscale_factor = 4; // unused for RealESRGAN_x4plus_anime_6B.pth
716716
if (params.esrgan_path.size() > 0 && params.upscale_repeats > 0) {
717-
upscaler_ctx_t* upscaler_ctx = new_upscaler_ctx(params.esrgan_path.c_str(),
718-
params.n_threads,
719-
params.wtype);
717+
upscaler_ctx_t* upscaler_ctx = new_upscaler_ctx(params.esrgan_path.c_str(),
718+
params.n_threads,
719+
params.wtype);
720720

721-
if (upscaler_ctx == NULL) {
722-
printf("new_upscaler_ctx failed\n");
723-
} else {
724-
for (int i = 0; i < params.batch_count; i++) {
725-
if (results[i].data == NULL) {
726-
continue;
727-
}
728-
sd_image_t current_image = results[i];
729-
for (int u = 0; u < params.upscale_repeats; ++u) {
730-
sd_image_t upscaled_image = upscale(upscaler_ctx, current_image, upscale_factor);
731-
if (u > 0) { // Free the previous iteration's image data if not the first upscale
732-
free(current_image.data);
721+
if (upscaler_ctx == NULL) {
722+
printf("new_upscaler_ctx failed\n");
723+
} else {
724+
for (int i = 0; i < params.batch_count; i++) {
725+
if (results[i].data == NULL) {
726+
continue;
733727
}
734-
if (upscaled_image.data == NULL) {
735-
printf("upscale failed\n");
736-
break;
728+
sd_image_t current_image = results[i];
729+
for (int u = 0; u < params.upscale_repeats; ++u) {
730+
sd_image_t upscaled_image = upscale(upscaler_ctx, current_image, upscale_factor);
731+
if (upscaled_image.data == NULL) {
732+
printf("upscale failed\n");
733+
break;
734+
}
735+
free(current_image.data);
736+
current_image = upscaled_image;
737737
}
738-
current_image = upscaled_image;
738+
results[i] = current_image; // Set the final upscaled image as the result
739739
}
740-
results[i] = current_image; // Set the final upscaled image as the result
741740
}
742741
}
743-
}
744-
745742

746743
size_t last = params.output_path.find_last_of(".");
747744
std::string dummy_name = last != std::string::npos ? params.output_path.substr(0, last) : params.output_path;

stable-diffusion.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,11 @@ class StableDiffusionGGML {
173173
if (version == VERSION_XL) {
174174
scale_factor = 0.13025f;
175175
if (vae_path.size() == 0 && taesd_path.size() == 0) {
176-
LOG_WARN("!!!It looks like you are using SDXL model. "
177-
"If you find that the generated images are completely black, "
178-
"try specifying SDXL VAE FP16 Fix with the --vae parameter. "
179-
"You can find it here: https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/blob/main/sdxl_vae.safetensors");
176+
LOG_WARN(
177+
"!!!It looks like you are using SDXL model. "
178+
"If you find that the generated images are completely black, "
179+
"try specifying SDXL VAE FP16 Fix with the --vae parameter. "
180+
"You can find it here: https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/blob/main/sdxl_vae.safetensors");
180181
}
181182
}
182183

0 commit comments

Comments
 (0)