mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-06-23 14:46:39 +00:00
feat: add --prompt-file and --negative-prompt-file flags (#1693)
This commit is contained in:
parent
787d229d84
commit
854bebfe02
@ -6,6 +6,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
@ -1421,6 +1422,42 @@ ArgOptions SDGenerationParams::get_options() {
|
|||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto on_prompt_file_arg = [&](int argc, const char** argv, int index) {
|
||||||
|
if (++index >= argc) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
const char* arg = argv[index];
|
||||||
|
std::ifstream f(arg, std::ios::binary);
|
||||||
|
try {
|
||||||
|
prompt = std::string(std::istreambuf_iterator<char>{f}, {});
|
||||||
|
} catch (const std::ios_base::failure&) {
|
||||||
|
f.setstate(std::ios_base::failbit);
|
||||||
|
}
|
||||||
|
if (f.fail()) {
|
||||||
|
LOG_ERROR("error: failed to read prompt file '%s'\n", arg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto on_negative_prompt_file_arg = [&](int argc, const char** argv, int index) {
|
||||||
|
if (++index >= argc) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
const char* arg = argv[index];
|
||||||
|
std::ifstream f(arg, std::ios::binary);
|
||||||
|
try {
|
||||||
|
negative_prompt = std::string(std::istreambuf_iterator<char>{f}, {});
|
||||||
|
} catch (const std::ios_base::failure&) {
|
||||||
|
f.setstate(std::ios_base::failbit);
|
||||||
|
}
|
||||||
|
if (f.fail()) {
|
||||||
|
LOG_ERROR("error: failed to read negative prompt file '%s'\n", arg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
|
||||||
options.manual_options = {
|
options.manual_options = {
|
||||||
{"-s",
|
{"-s",
|
||||||
"--seed",
|
"--seed",
|
||||||
@ -1484,6 +1521,14 @@ ArgOptions SDGenerationParams::get_options() {
|
|||||||
"--vae-relative-tile-size",
|
"--vae-relative-tile-size",
|
||||||
"relative tile size for vae tiling, format [X]x[Y], in fraction of image size if < 1, in number of tiles per dim if >=1 (overrides --vae-tile-size)",
|
"relative tile size for vae tiling, format [X]x[Y], in fraction of image size if < 1, in number of tiles per dim if >=1 (overrides --vae-tile-size)",
|
||||||
on_relative_tile_size_arg},
|
on_relative_tile_size_arg},
|
||||||
|
{"",
|
||||||
|
"--prompt-file",
|
||||||
|
"path to the file containing the prompt to render",
|
||||||
|
on_prompt_file_arg},
|
||||||
|
{"",
|
||||||
|
"--negative-prompt-file",
|
||||||
|
"path to the file containing the negative prompt",
|
||||||
|
on_negative_prompt_file_arg},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user