Original size 1599x2000

Training a Generative Neural Network. Portraits in the Style of Kuzma Petrov-Vodkin

PROTECT STATUS: not protected
Longread translated automatically

The goal of the project is to explore the capabilities of generative neural networks to create a series of images in the style of Petrov-Vodkin’s paintings and to apply this style to create portraits of various ages.

Paintings by Petrov-Vodkin

Kuzma Petrov-Vodkin’s style in his portraits features a vibrant color palette, yet the models are depicted with accentuated psychological depth, their gaze directed toward the artist himself. His manner of painting blends elements of realism and symbolism, creating a feeling of a nature that is simultaneously real and slightly unreal.

Petrov-Vodkin’s paintings

The project creates a version of Stable Diffusion trained on paintings by Petrov-Vodkin, capable of generating images in his style using a limited set of source images (dataset: 52 paintings) and efficient adaptation methods (LoRA).

Neural Network Training

0
1/2

First, I checked GPU availability using nvidia-smi, and then I installed the necessary libraries: bitsandbytes (for model quantization), transformers (for text and image processing), diffusers (for working with diffusion models), peft (for parameter-efficient fine-tuning, including LoRA), and a script for training Dreambooth-LoRA from the Hugging Face repository.

big
Original size 2436x522

I compiled a dataset of Petrov-Vodkin paintings: 52 objects, uploaded them to Google Colab in a separate directory, applying the resize method to format the images to 1:1, and reviewed the first 5 images.

Original size 2497x805

Generated image captions using the BLIP model: each caption in the image titles is prefixed with «portrait in the style of Petrov-Vodkin.» I saved the metadata (file paths and captions) in metadata.jsonl (verifying the code execution).

Advanced Training

Original size 1557x856

I utilized the Dreambooth-LoRA technique to fine-tune Stable Diffusion. I am using the following base models:

Also: stabilityai/stable-diffusion-xl-base-1.0 VAE madebyollin/sdxl-vae-fp16-fix

Key training parameters: Resolution: 512×512 Batch size: 2 Learning rate: 1e-4 Number of steps: 500 8-bit Adam (memory optimization) FP16

I launched the training using accelerate.

Saving the resulting model and its publication

Original size 2161x877

Saved the model on Hugging Face using upload_folder. A model card with metadata was created using save_model_card.

Image Generation

After training, saving, and publishing—I uploaded the trained LoRA model.

I used the DiffusionPipeline to generate images based on the prompt: «portrait in the style of Petrov-Vodkin.» Generation settings: 25 steps, FP16.

Original size 1178x191

generation result

1/3

Image generation result using the trained model

In my project, I set a goal to create portraits of different age groups, so I used various prompts for this purpose.

Original size 2238x157
Original size 1024x1024

Generation result

Generation result

Original size 2433x166
Original size 1024x1024

Generation result

generation result

Training a Generative Neural Network. Portraits in the Style of Kuzma Petrov-Vodkin
Project created at 10.04.2025