Skip to content

peterschenk01/CLIPascene-in-cpp

Repository files navigation

CLIPascene-in-cpp

A C++ port of CLIPascene / SceneSketch with the long-term goal of running on Android.

This project was created as part of my bachelor's thesis.


! This project was not finished. Below is a demonstration of what my implementation can do. !


Input

Input Image


Intermediate Maps


Attention Map
(CLIP)

Edge Map
(XDoG)

Distribution Map
(Attention + Edge)

Strokes Initialization
(rasterized with diffvg)

Repository layout

  • clipascene.cpp — main executable entry point
  • CMakeLists.txt — build configuration
  • download_model.py — helper fetching the CLIP model
  • CLIP/ - CLIP implementation
  • diffvg/ - diffvg implementation
  • libdiffvg.so — shared library of diffvg
  • tinyxml2/ - tinyxml implementation
  • helper/ — My C++ implementation of CLIPascene
  • input_images/ — inputs
  • output/ — outputs
  • tests/ — tests

Installation (Ubuntu / Debian)

Hint: This implementation currently requires CUDA.

1. Clone this repository

git clone https://github.com/peterschenk01/CLIPascene-in-cpp.git
cd CLIPascene-in-cpp

2. Install Libtorch

  • Go to the official PyTorch download page and select:

    • Package: LibTorch
    • Language: C++
    • Compute platform: CUDA (check which version you have installed)
  • Download the archive (e.g. libtorch-shared-with-deps-2.9.1%2Bcu128.zip) into this directory

curl -O https://download.pytorch.org/libtorch/cu128/libtorch-shared-with-deps-2.9.1%2Bcu128.zip
  • Extract the archive
unzip libtorch-shared-with-deps-2.9.1%2Bcu128.zip
  • Remove archive
rm libtorch-shared-with-deps-2.9.1%2Bcu128.zip

3. Install OpenCV

sudo apt-get update
sudo apt-get install -y libopencv-dev

4. Install CMake

sudo apt-get update
sudo apt-get install -y cmake

5. Create python environment and install requirements

python -m venv .venv
source ./.venv/bin/activate
pip install -r requirements.txt

Running CLIPascene (C++)

1. Download CLIP model

python download_model.py

2. Build

mkdir build
cd build
cmake ..
make

3. Run

./clipascene

This will create following files in the output/ directory:

  • attention_map.png
  • distribution_map.png
  • edge_map.png
  • strokes_init.png
  • strokes_init.svg

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published