Initial commit
This commit is contained in:
commit
46cd5a28d8
4 changed files with 55 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
venv/
|
||||||
|
*.png
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 Julian Müller (ChaoticByte)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
3
requirements.txt
Normal file
3
requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
diffusers
|
||||||
|
transformers
|
||||||
|
accelerate
|
29
sdxl.py
Executable file
29
sdxl.py
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Copyright (c) 2024 Julian Müller (ChaoticByte)
|
||||||
|
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
|
from diffusers import AutoPipelineForText2Image
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# parse cmdline args
|
||||||
|
argp = ArgumentParser()
|
||||||
|
argp.add_argument("-m", "--model", type=str, help="Path to the sdxl model folder", required=True)
|
||||||
|
argp.add_argument("-p", "--prompt", type=str, help="Prompt for image inference")
|
||||||
|
argp.add_argument("-n", "--steps", type=int, help="Number of inference steps", default=1)
|
||||||
|
argp.add_argument("-o", "--output", type=str, help="Image output file", default="output.png")
|
||||||
|
args = argp.parse_args()
|
||||||
|
# create pipeline, process prompt(s), output file
|
||||||
|
pipe = AutoPipelineForText2Image.from_pretrained(args.model, local_files_only=True)
|
||||||
|
pipe.to("cpu")
|
||||||
|
if args.prompt is None:
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
prompt = input("> ")
|
||||||
|
pipe(prompt=prompt, num_inference_steps=args.steps, guidance_scale=0.0).images[0].save(args.output)
|
||||||
|
except (EOFError, KeyboardInterrupt):
|
||||||
|
print("bye.")
|
||||||
|
exit(0)
|
||||||
|
else:
|
||||||
|
pipe(prompt=args.prompt, num_inference_steps=args.steps, guidance_scale=0.0).images[0].show(args.output)
|
Reference in a new issue