Creating a custom_main.py file were we can give image directly instead of using UI #3726
Unanswered
tarunaditya91
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi I am trying to give a custom image directly to defooocus instead of using UI but I am facing difficulty doing it so I started with providing the custom text as input so I have created a custom_main.py file where I have provided the values for parameters but still getting an error can you tell
am I following the correct approach??
`import modules.default_pipeline as pipeline
import os
import cv2
def generate_custom_image(
positive_cond, negative_cond, width, height, steps, seed, cfg_scale=7.5,
denoise=0.5, sampler_name="karras", scheduler_name="karras", switch=None,
tiled=False, refiner_swap_method="joint", disable_preview=True
):
imgs = pipeline.process_diffusion(
positive_cond=positive_cond,
negative_cond=negative_cond,
steps=steps,
switch=switch,
width=width,
height=height,
image_seed=seed,
callback=None,
sampler_name=sampler_name,
scheduler_name=scheduler_name,
latent=None,
denoise=denoise,
tiled=tiled,
cfg_scale=cfg_scale,
refiner_swap_method=refiner_swap_method,
disable_preview=disable_preview
)
return imgs
def save_image(image, output_folder, image_name="output_image.jpg"):
if not os.path.exists(output_folder):
os.makedirs(output_folder)
output_path = os.path.join(output_folder, image_name)
cv2.imwrite(output_path, image)
print(f"Image saved at {output_path}")
if name == "main":
positive_prompt = "A futuristic cityscape during sunset"
negative_prompt = "blurry, low resolution"
width, height = 512, 512
steps = 50
seed = 12345
output_folder = "/home/tstack/workspace/DeFoocus/DeFooocus/custom_output_images"
`
Beta Was this translation helpful? Give feedback.
All reactions