๐ŸชŸ Windows Installation Guide for Virtual Sketching

June 12, 2025 ยท View on GitHub

This guide provides step-by-step instructions to set up and run the Virtual Sketching project on Windows using Anaconda and Python 3.6.

โœ… Requirements

  • Windows 10 or newer
  • Anaconda installed
  • Git installed (optional, but recommended)

๐Ÿ“ฆ Step 1: Create and Activate Conda Environment

conda create -n virtual_sketching python=3.6 -y
conda activate virtual_sketching

๐Ÿ“‚ Step 2: Clone the Repository

cd D:\
git clone https://github.com/MarkMoHR/virtual_sketching.git
cd virtual_sketching

(If you plan to contribute, consider forking the repo and using your own URL.)


๐Ÿ”ง Step 3: Install Required Packages

From conda:

conda install opencv=3.4.2 pillow=6.2.0 scipy=1.5.2 -y
conda install -c conda-forge pycairo gtk3 cffi -y

Then remove default TensorFlow (if installed via conda):

conda remove tensorflow

Install required packages via pip:

pip install tensorflow==1.15.0
pip install numpy gizeh cairocffi matplotlib svgwrite

โš ๏ธ Do not upgrade pillow, scipy, or tensorflow โ€” newer versions are incompatible.


๐Ÿ› ๏ธ Step 4: Fix Backend Compatibility

In utils.py, near the top, ensure the following:

from PIL import Image
import matplotlib
matplotlib.use('TkAgg')  # force compatible backend
import matplotlib.pyplot as plt

This ensures proper rendering with tkinter on Windows.


๐Ÿš€ Step 5: Run a Demo

From the project directory:

python test_vectorization.py --input sample_inputs\muten.png --sample 5

โš ๏ธ This script only generates .npz and .png files. To convert to .svg, see next section.


๐Ÿ–ผ๏ธ Optional: Use GUI Tool (Windows Only)

Step 1: Launch GUI with provided batch file

Use the runme.bat file to activate the conda environment and launch the Python GUI:

rem runme.bat
set CONDAPATH=C:\ProgramData\anaconda3
set ENVNAME=virtual_sketching
call %CONDAPATH%\Scripts\activate.bat %ENVNAME%
python virtual_sketch_gui.py
pause

Step 2: Select an input image and model

The GUI allows you to:

  • Choose input image (PNG, JPEG, BMP, etc.)
  • Select one of the three models
  • Automatically runs processing and converts results to SVG
  • Saves all outputs into a sketches/ subfolder of the input image directory

๐Ÿง  Known Compatibility Notes

  • Python 3.6 and TensorFlow 1.15 are required (due to use of tensorflow.contrib)
  • Windows support requires manual setup of Gizeh and Cairo backends
  • GPU usage optional โ€” TensorFlow 1.15 requires CUDA 10.0 and cuDNN 7

๐Ÿงฉ Troubleshooting Tips

  • โŒ No module named '_cffi_backend' โ†’ Run: conda install -c conda-forge cffi
  • โŒ ImportError: cannot import name 'draw_svg_from_npz' โ†’ Use svg_conversion.py instead
  • โŒ .svg looks wrong โ†’ Make sure you're using the official svg_conversion.py from tools/
  • โŒ Missing .svg? โ†’ Use virtual_sketch_gui.py or run tools/svg_conversion.py manually on .npz

๐Ÿค Contributing

Feel free to open issues or pull requests if you encounter bugs or want to improve the Windows support!


๐Ÿ“ Folder Structure Suggestion

virtual_sketching/
โ”œโ”€โ”€ sample_inputs/
โ”œโ”€โ”€ tools/
โ”œโ”€โ”€ outputs/
โ”œโ”€โ”€ virtual_sketch_gui.py
โ”œโ”€โ”€ runme.bat
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ WINDOWS_INSTALL_GUIDE.md   โ† You are here

Made with โค๏ธ by the community to help Windows users get started!