From 8a2a831c80b67e595f419ad8ec1abbf30c6f4802 Mon Sep 17 00:00:00 2001 From: hodanov <1031hoda@gmail.com> Date: Mon, 4 Nov 2024 08:53:43 +0900 Subject: [PATCH] Remove cmd/sd15_txt2img.py. Rename cmd/sdxl_txt2img.py -> cmd/txt2img_handler.p. --- cmd/sd15_txt2img.py | 72 --------------------- cmd/{sdxl_txt2img.py => txt2img_handler.py} | 0 2 files changed, 72 deletions(-) delete mode 100644 cmd/sd15_txt2img.py rename cmd/{sdxl_txt2img.py => txt2img_handler.py} (100%) diff --git a/cmd/sd15_txt2img.py b/cmd/sd15_txt2img.py deleted file mode 100644 index dcd38c7..0000000 --- a/cmd/sd15_txt2img.py +++ /dev/null @@ -1,72 +0,0 @@ -import logging -import time - -import domain -import modal - -app = modal.App("run-stable-diffusion-cli") -run_inference = modal.Function.from_name( - "stable-diffusion-cli", - "SD15.run_txt2img_inference", -) - - -@app.local_entrypoint() -def main( - prompt: str, - n_prompt: str, - height: int = 512, - width: int = 512, - samples: int = 5, - steps: int = 20, - seed: int = -1, - use_upscaler: str = "", - fix_by_controlnet_tile: str = "False", - output_format: str = "png", -) -> None: - """main() is the entrypoint for the Runway CLI. - This pass the given prompt to StableDiffusion on Modal, gets back a list of images and outputs images to local. - """ - logging.basicConfig( - level=logging.INFO, - format="[%(levelname)s] %(asctime)s - %(message)s", - datefmt="%Y-%m-%d %H:%M:%S", - ) - logger = logging.getLogger("run-stable-diffusion-cli") - - output_directory = domain.OutputDirectory() - directory_path = output_directory.make_directory() - logger.info("Made a directory: %s", directory_path) - - prompts = domain.Prompts(prompt, n_prompt, height, width, samples, steps) - sd_output_manager = domain.StableDiffusionOutputManger(prompts, directory_path) - for sample_index in range(samples): - new_seed = domain.Seed(seed) - start_time = time.time() - images = run_inference.remote( - prompt=prompt, - n_prompt=n_prompt, - height=height, - width=width, - batch_size=1, - steps=steps, - seed=new_seed.value, - use_upscaler=use_upscaler == "True", - fix_by_controlnet_tile=fix_by_controlnet_tile == "True", - output_format=output_format, - ) - for generated_image_index, image_bytes in enumerate(images): - saved_path = sd_output_manager.save_image( - image_bytes, - new_seed.value, - sample_index, - generated_image_index, - output_format, - ) - logger.info("Saved image to the: %s", saved_path) - - total_time = time.time() - start_time - logger.info("Sample %s, took %ss (%ss / image).", sample_index, total_time, (total_time) / len(images)) - - saved_prompts_path = sd_output_manager.save_prompts() - logger.info("Saved prompts: %s", saved_prompts_path) diff --git a/cmd/sdxl_txt2img.py b/cmd/txt2img_handler.py similarity index 100% rename from cmd/sdxl_txt2img.py rename to cmd/txt2img_handler.py