Home

Awesome

:smiley::heart_eyes::fire::fire: Segmentation-Based Parametric Painting :fire::fire::heart_eyes::smiley:

This repository contains a semantic-based painting optimization algorithm which aims to transform a given input image into a painting. The algorithm takes advantage of modern computer vision techniques, segmentation networks, and a differentiable renderer to generate results.

Project Website

Reference Image 1

Reference Image 2

Reference Image 3

<!-- ![Reference Image 2](media_readme/dinner_dog_process_text_mask_person_lvl_3.jpg) -->

What It Does

Reference Image 4

The algorithm aims to efficiently optimize a collection of stroke parameters to create a painting from a given image input. The method starts with an image and optimizes a parameter vector of strokes. When rendered on a canvas, it recreates the input image in the form of a painting. The approach is designed to efficiently manage any input size or aspect ratio. It divides the canvas into semantic areas using a segmentation network. This provides a higher control over the painting compared to previous optimization and neural methods.

How To Use

1. Requirements:

pip install -r requirements.txt
pip install -r requirements_os.txt
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

By:

# device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") # 
device = "mps" if torch.backends.mps.is_available() else "cpu"
# Set default tensor type to float32
torch.set_default_dtype(torch.float32)

You will likely need to add some .float() at some parts in the code

2. Command:

python main.py [options]

3. Arguments:

To paint with a painterly style set style to "painterly". To get a realistic style, set it to "realistic". Currently supports 4 styles: realistic, painterly, abstract, and expressionist.

4. Example:

python main.py --image_path /path/to/image.jpg --save_dir /path/to/save_directory --style painterly

Method Overview

The method uses various techniques and algorithms to produce a painting from an input image. Key components include:

Implementation Details:

More Results:

Reference Image 5

Reference Image 6

Reference Image 7

References

Citation

@misc{deguevara2023segmentationbased,
      title={Segmentation-Based Parametric Painting}, 
      author={Manuel Ladron de Guevara and Matthew Fisher and Aaron Hertzmann},
      year={2023},
      eprint={2311.14271},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      }

Feedback

For any queries or feedback related to the algorithm, please open an issue on GitHub or contact the authors directly.