# Image2image SDLX finetuning using python

**URL:** <https://discuss.huggingface.co/t/image2image-sdlx-finetuning-using-python/142654>\
**Category:** 🧨 Diffusers\
**Created:** [February 24, 2025, 11:27am UTC](https://discuss.huggingface.co/t/image2image-sdlx-finetuning-using-python/142654 "2025-02-24T11:27:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![EgorKolpakov](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/egorkolpakov/32/41854_2.png) [@EgorKolpakov](https://discuss.huggingface.co/u/EgorKolpakov)\
**Post date:** [February 24, 2025, 11:27am UTC](https://discuss.huggingface.co/t/image2image-sdlx-finetuning-using-python/142654/1 "2025-02-24T11:27:08Z")

</div>

Hi guys,

Don’t know which category I should pick but… Recently I faced with an issue. I want to create a script to fine-tune SDXL on my local machine using GPU. I want to train the model on the set of images with masking and without. Basically the task is that it has an image and in a certain region it generates polygons or something I want to place there. I have this paired dataset already.

The result should looks as following. In the inference.py I give an image and the prompt, and model modifies the image.

I started to surf the internet to have an example for this type of generation. But unfortunately all I see is a low-code or no-code solutions. Or solutions which got somewhat outdated due to multiple changes introduced by HuggingFace hub.

I tried multiple ways how to make it but all the time I’m facing with some weird errors, which I’m not always able to address.

If you have a code snippet that could help me out to fine tune model, save it and then inference, please let me know.

🙏🙏🙏 Thank you in advance!

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [February 24, 2025, 1:49pm UTC](https://discuss.huggingface.co/t/image2image-sdlx-finetuning-using-python/142654/2 "2025-02-24T13:49:43Z")

</div>

Is there anything similar to Inpainting or existing ControlNet?

SDXL is not a model architecture specialized for image processing, so I don’t think there are many options.

> **[Inpainting](https://huggingface.co/docs/diffusers/using-diffusers/inpaint)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> **[ControlNet with Stable Diffusion XL](https://huggingface.co/docs/diffusers/v0.32.2/api/pipelines/controlnet_sdxl)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> **[Spaces - Hugging Face](https://huggingface.co/spaces?category=image-editing)**
>
> Discover amazing ML apps made by the community

---

<div class="post-metadata">

**Author:** ![EgorKolpakov](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/egorkolpakov/32/41854_2.png) [@EgorKolpakov](https://discuss.huggingface.co/u/EgorKolpakov)\
**Post date:** [February 25, 2025, 10:34am UTC](https://discuss.huggingface.co/t/image2image-sdlx-finetuning-using-python/142654/3 "2025-02-25T10:34:58Z")

</div>

Is it possible to finetune Kadinsky for certain image generation?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [February 25, 2025, 12:25pm UTC](https://discuss.huggingface.co/t/image2image-sdlx-finetuning-using-python/142654/4 "2025-02-25T12:25:06Z")

</div>

It seems that fine-tuning is possible, but the sample is old, so it is unknown whether it will work as is. Basically, in this type of model, the training results for Text-to-Image also directly affect Image-to-Image.

> **[GitHub - ai-forever/Kandinsky-2: Kandinsky 2 — multilingual text2image latent...](https://github.com/ai-forever/Kandinsky-2)**
>
> Kandinsky 2 — multilingual text2image latent diffusion model
