mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-11 03:24:30 +00:00
added a WIN32 get_files_from_dir; turn off Photomakder if receiving no input images
This commit is contained in:
1 parent
70c3397b60
commit
16c9da0cca
2 files changed
+45
-1
No files matched your search
@@ -1679,6 +1679,7 @@ sd_image_t* txt2img(sd_ctx_t* sd_ctx,
|
|||||||
// ggml_tensor* class_tokens_mask = NULL;
|
// ggml_tensor* class_tokens_mask = NULL;
|
||||||
std::vector<bool> class_tokens_mask;
|
std::vector<bool> class_tokens_mask;
|
||||||
if(sd_ctx->sd->stacked_id){
|
if(sd_ctx->sd->stacked_id){
|
||||||
|
if(input_id_images.size() > 0){
|
||||||
sd_ctx->sd->pmid_model->style_strength = style_ratio;
|
sd_ctx->sd->pmid_model->style_strength = style_ratio;
|
||||||
int32_t w = input_id_images[0]->width;
|
int32_t w = input_id_images[0]->width;
|
||||||
int32_t h = input_id_images[0]->height;
|
int32_t h = input_id_images[0]->height;
|
||||||
@@ -1716,8 +1717,12 @@ sd_image_t* txt2img(sd_ctx_t* sd_ctx,
|
|||||||
LOG_INFO("sampling steps increases from %d to 50 for PHOTOMAKER", sample_steps);
|
LOG_INFO("sampling steps increases from %d to 50 for PHOTOMAKER", sample_steps);
|
||||||
sample_steps = 50;
|
sample_steps = 50;
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
LOG_WARN("Provided PhotoMaker model file, but NO input ID images");
|
||||||
|
LOG_WARN("Turn off PhotoMaker");
|
||||||
|
sd_ctx->sd->stacked_id = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
t0 = ggml_time_ms();
|
t0 = ggml_time_ms();
|
||||||
|
|||||||
@@ -91,6 +91,45 @@ std::string get_full_path(const std::string& dir, const std::string& filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> get_files_from_dir(const std::string& dir) {
|
||||||
|
|
||||||
|
std::vector<std::string> files;
|
||||||
|
|
||||||
|
WIN32_FIND_DATA findFileData;
|
||||||
|
HANDLE hFind;
|
||||||
|
|
||||||
|
char currentDirectory[MAX_PATH];
|
||||||
|
GetCurrentDirectory(MAX_PATH, currentDirectory);
|
||||||
|
|
||||||
|
char directoryPath[MAX_PATH]; // this is absolute path
|
||||||
|
sprintf(directoryPath, "%s\\%s\\*", currentDirectory, dir.c_str());
|
||||||
|
|
||||||
|
// Find the first file in the directory
|
||||||
|
hFind = FindFirstFile(directoryPath, &findFileData);
|
||||||
|
|
||||||
|
// Check if the directory was found
|
||||||
|
if (hFind == INVALID_HANDLE_VALUE) {
|
||||||
|
printf("Unable to find directory.\n");
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loop through all files in the directory
|
||||||
|
do {
|
||||||
|
// Check if the found file is a regular file (not a directory)
|
||||||
|
if (!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||||
|
files.push_back(std::string(currentDirectory) + "\\" + dir + "\\" + std::string(findFileData.cFileName));
|
||||||
|
}
|
||||||
|
} while (FindNextFile(hFind, &findFileData) != 0);
|
||||||
|
|
||||||
|
// Close the handle
|
||||||
|
FindClose(hFind);
|
||||||
|
|
||||||
|
|
||||||
|
sort(files.begin(), files.end());
|
||||||
|
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
#else // Unix
|
#else // Unix
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|||||||
Reference in new issue
Block a user