This repository contains:
C++ code with vectorization algorithm
Matlab code for debugging polyvector flow
Python code for keypoint inference
Dataset for training was released in a separate repository: line-drawing-vectorization-polyvector-flow-dataset
Paper webpage link
Contact me if you need code for speed benchmarks. This release was tuned for better vectorization accuracy.
@article{Puhachov2021KeypointPolyvector,
author = {Ivan Puhachov and William Neveu and Edward Chien and Mikhail Bessmeltsev},
title = {Keypoint-Driven Line Drawing Vectorization via PolyVector Flow},
journal = {ACM Transactions on Graphics (Proceedings of SIGGRAPH Asia)},
volume = {40}, number = {6}, year = {2021}, month = dec,
doi = {10.1145/3478513.3480529}
}
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
Running build/vectorize
will start vectorization on default input parameters: inputs/example.png
and inputs/example.pts
It will output a debug window:
To suppress debug window, provide output destination as third parameter:
build/vectorize image.png image.pts image.svg
This bash script runs both keypoint prediciton and vectorization give a single image as input:
bash run_vectorization.sh inputs/example.png
Uses PyTorch (tested on 1.10) and CUDA. Can work with CPU, but expect longer inference time.
To predict keypoints run:
python prediction/usemodel.py --model prediction/best_model_checkpoint.pth --input image.png --output image.pts
'Dracolion', 'Mouse', 'Muten', 'Sheriff' are from [Noris et al. 2013]. Please ask the authors for the .pngs.
'Banana-Tree', 'Elephant', 'Hippo', 'Kitten', 'Puppy', 'Leaf', 'Dog06', 'Dog14': (c) Ivan Huska. https://www.easy-drawings-and-sketches.com/
Tested with Gurobi 9.1.1, 9.0.3, 8.1.1. Install Gurobi and activate license, then update GUROBI_HOME
in CMakeLists.txt
:
set(GUROBI_HOME "/opt/gurobi911/linux64/")
Alternativelly, you can set your own path in cmake/FindGUROBI.cmake
Instructions: ubuntu
You may want to:
sudo apt-get install libz-dev
sudo apt-get install libbz2-dev
sudo apt install libatlas-base-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libomp-dev
Then move paal/include/paal/
folder here to paal/
We use environment variable, don't forget to setup GUROBI_HOME
and
Linux: you may need to recompile (see https://support.gurobi.com/hc/en-us/articles/360039093112-How-do-I-resolve-undefined-reference-errors-while-linking-Gurobi-in-C-)
cd /opt/gurobi903/linux64/src/build
make
cp libgurobi_c++.a ../../lib/
This one can be finicky. Here's what worked for me (William, Ubuntu 18.04).
Install the OpenCV library this way. Make sure to do sudo make install
at the very end.
Make sure that you have a FindOpenCV.cmake file in polyvector_flow/cpp/cmake.
Make sure that the CMakelists.txt file in polyvector_flow/cpp specifies the path to the OpenCV static libraries (the .a ones).
Example : find_package(OpenCV REQUIRED PATHS "/usr/lib/x86_64-linux-gnu")
Building will take at least 30 minutes
sudo apt install libeigen3-dev
cmake ../
should finish with -- Generating done
. It also outputs log info with paths, for example:
-- Qt found
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Found OpenCV: /usr/local (found version "4.5.0")
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.48")
-- Boost_INCLUDE_DIRS = /usr/include
-- GUROBI_HOME = /opt/gurobi911/linux64/
-- Found GUROBI: /opt/gurobi911/linux64/lib/libgurobi_c++.a
-- Gurobi found
-- Paal = /home/ivan/projects/polyvector_cpp/paal
-- Configuring done