commit 46cd5a28d8cff9274eb272d9ffaf93f39d658b95 Author: Julian Müller (ChaoticByte) Date: Fri Jan 5 19:39:15 2024 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..822838a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +venv/ +*.png diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..920dc4f --- /dev/null +++ b/LICENSE @@ -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. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..09ce8c6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +diffusers +transformers +accelerate diff --git a/sdxl.py b/sdxl.py new file mode 100755 index 0000000..946e9b8 --- /dev/null +++ b/sdxl.py @@ -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)