Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Height and width issue with SDXL image to image #20

Open
rafationgson opened this issue Sep 7, 2023 · 3 comments
Open

Height and width issue with SDXL image to image #20

rafationgson opened this issue Sep 7, 2023 · 3 comments

Comments

@rafationgson
Copy link

This issue is for stability-ai/sdxl model. When I use the model for img2img predictions and set custom width and height, the resulting output still follows the dimensions of the original image. For example I set the width to 1024 and height to 768 and the parameters are ignored. Can we add the width and height args to the img2img_pipe?

    if image and mask:
        print("inpainting mode")
        sdxl_kwargs["image"] = self.load_image(image)
        sdxl_kwargs["mask_image"] = self.load_image(mask)
        sdxl_kwargs["strength"] = prompt_strength
        sdxl_kwargs["width"] = width
        sdxl_kwargs["height"] = height
        pipe = self.inpaint_pipe
    elif image:
        print("img2img mode")
        sdxl_kwargs["image"] = self.load_image(image)
        sdxl_kwargs["strength"] = prompt_strength
        pipe = self.img2img_pipe
    else:
        print("txt2img mode")
        sdxl_kwargs["width"] = width
        sdxl_kwargs["height"] = height
        pipe = self.txt2img_pipe
@JarvisSan22
Copy link

Found this issue today.
There seem there two options. One resize the image before putting it replicate . Two create an alternative version of the repo and fix all the issues as the dev dont seem to be developing it anymore ( ノД`)シクシク…

@JarvisSan22
Copy link

JarvisSan22 commented Nov 14, 2023

My Current quck fix to this issue for a discord bot using replicate, is to use backblaze api to hold a resized image then use that for the imgurl.
May help out

def BB_imageFix(self,img_url,width,height):
        #Download discord image and resize 
        r=requests.get(img_url)
        image = Image.open(io.BytesIO(r.content))
        image=image.resize((width,height))
        file_name=f"placeholder_{os.path.basename(img_url)}"
        image.save(file_name)
        #Upload to backblaze 
        local_file = Path(file_name).resolve()
        metadata = {"key": "value"}
        uploaded_file = self.BB_bucket.upload_local_file(
                local_file=local_file,
                file_name=file_name,
                file_infos=metadata,
        )
        img_url=self.b2_api.get_download_url_for_fileid(uploaded_file.id_)
        os.remove(file_name) #Delete placeholder file from local 
        return img_url   

@JarvisSan22
Copy link

https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py
Going through the StableDiffusionXLImg2ImgPipeline that replicate uses there no width or height setting as these values seem to be based of the input image size but there is a target_size what could solve this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants