-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_image_generation.py
More file actions
56 lines (48 loc) · 2.7 KB
/
run_image_generation.py
File metadata and controls
56 lines (48 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# run_image_generation.py
#
# This script allows you to call any of the image generation scripts (Flux or Realistic Photo)
# from the command line or a batch file, passing the prompt and other parameters as arguments.
#
# Usage example (PowerShell or CMD):
# python run_image_generation.py flux "a beautiful landscape" --seed 123 --width 1024 --height 768
# python run_image_generation.py realistic "a cat on a windowsill" --negative "blurry, low quality" --seed 42
import sys
import subprocess
import argparse
# Map script types to their corresponding Python files
SCRIPT_MAP = {
'flux': 'flux.py',
'realistic': 'realistic_photo.py',
'jugger': 'jugger.py',
}
def main():
parser = argparse.ArgumentParser(description="Run image generation scripts with custom prompts and parameters.")
parser.add_argument('script', choices=SCRIPT_MAP.keys(), help="Which script to run: 'flux' or 'realistic'")
parser.add_argument('--prompt', required=True, help="Prompt for image generation (named argument)")
parser.add_argument('--negative', help="Negative prompt (named argument, only for realistic)")
parser.add_argument('--seed', type=int, default=-1, help="Seed value (default: -1 for random)")
parser.add_argument('--width', type=int, default=896, help="Image width (default: 896)")
parser.add_argument('--height', type=int, default=1152, help="Image height (default: 1152)")
parser.add_argument('--steps', type=int, default=20, help="Number of inference steps (default: 20)")
parser.add_argument('--output', default=".", help="Output directory (default: current directory)")
args = parser.parse_args()
script_file = SCRIPT_MAP[args.script]
prompt = args.prompt
negative = args.negative
# Build the command to call the target script with the right parameters
if args.script == 'flux':
cmd = [sys.executable, script_file, '--prompt', prompt, '--seed', str(args.seed), '--width', str(args.width), '--height', str(args.height), '--steps', str(args.steps), '--output', args.output]
elif args.script == 'jugger':
cmd = [sys.executable, script_file, '--prompt', prompt]
if negative:
cmd += ['--negative', negative]
cmd += ['--seed', str(args.seed), '--width', str(args.width), '--height', str(args.height), '--steps', str(args.steps), '--output', args.output]
else:
cmd = [sys.executable, script_file, '--prompt', prompt]
if negative:
cmd += ['--negative', negative]
cmd += ['--seed', str(args.seed), '--width', str(args.width), '--height', str(args.height), '--steps', str(args.steps), '--output', args.output]
print(f"Running: {' '.join(cmd)}")
subprocess.run(cmd)
if __name__ == "__main__":
main()