Skip to content

pkarnstein-SI/Stiptacular

 
 

Repository files navigation

Contributors Forks Stargazers Issues Unlicense License


Stiptacular Next Gen

Turn Images Into Stippled B&W

Result

Remember how old scientific papers couldn't print in color in journals, so they did cool stippling and shit?

PERSEPHONE REMEMBERS

so anyway I found a project that converts images into stippled b&w and fixed it and am currently fixing it up to work with new versions of python + adding some features

(back to top)

Getting Started

Installation

  1. Clone the repo
    git clone --recursive https://github.com/pkarnstein-SI/Stiptacular.git
  2. Install requirements
    python -m pip install -r requirements.txt
  3. Run the setup script
    chmod +x setup.sh && ./setup.sh

(back to top)

Usage

Runtime

Will write this later when i'm back on adderall

(back to top)

Training your own model

Note

These steps are automated by setup.sh --train; the steps below only need to be run manually if you want to change settings, or are running on a device (i.e., a macbook) that doesn't support CUDA

  1. Download the fonts you want to train on, and text to train with (the wikipedia training dependency for font-classify hasn't been updated in a while and will throw BeautifulSoup errors)
  2. Move to the font-classify directory
    cd font-classify
  3. If you're training on a Apple Silicon Mac, edit the device = line at the beginning of font-classify/train.py to enable mps devices
    -     device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    +     device = torch.device("cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu")
  4. If you're training on a Apple Silicon Mac, you will also have to edit line 297 of font-classify/train.py as shown, as mps cannot handle float64 tensors.
       epoch_loss = running_loss / dataset_sizes[phase]
    -  epoch_acc = running_corrects.double() / dataset_sizes[phase]
    +  if device.type != "mps":
    +    epoch_acc = running_corrects.double() / dataset_sizes[phase]
    +  else:
    +    epoch_acc = running_corrects.to(torch.float32).to("mps") / dataset_sizes[phase]
  5. Generate training data
    python dataset_generation.py 10000 \
      --backgrounds="<<path to background images>>" \
        --fonts="<<path to downloaded fonts>>" \
          --textfile="<<path to training text>>" \
            --text_source="textfile"
  6. Train OCR on generated data
    python train.py --image_folder="sample_data/output"

(back to top)

Roadmap

Result

  • Update for Python3 and Shapely2
  • Replace deprecated svgwrite dependency
  • Auto-estimate parameters if you don't manually enter them
  • Improve runtime estimate by fitting W.R.T. image size as well as number of points
  • Implement OCR
    • Implement deep font detection

(back to top)

About

Making Stiptacular more powerful and user friendly

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 91.8%
  • Shell 8.2%