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
- Clone the repo
git clone --recursive https://github.com/pkarnstein-SI/Stiptacular.git
- Install requirements
python -m pip install -r requirements.txt
- Run the setup script
chmod +x setup.sh && ./setup.sh
Will write this later when i'm back on adderall
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
- 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) - Move to the
font-classify
directorycd font-classify
- If you're training on a Apple Silicon Mac, edit the
device =
line at the beginning offont-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")
- 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]
- 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"
- Train OCR on generated data
python train.py --image_folder="sample_data/output"
- 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