Giter VIP home page Giter VIP logo

scrabblegan's Introduction

ScrabbleGAN - Handwritten Text Generation

A PyTorch implementation of the ScrabbleGAN: Semi-Supervised Varying Length Handwritten Text Generation paper.

The main code was taken from amzn/convolutional-handwriting-gan and arshjot/ScrabbleGAN.

Quick setup and start

The provided Dockerfile is supplied to build an image with CUDA support and cuDNN.

Preparations

  • Clone the repo.
  • Download and extract dataset to the data/ folder.
  • sudo make all to build a docker image and create a container. Or sudo make all GPUS=device=0 CPUS=10 if you want to specify gpu devices and limit CPU-resources.

If you don't want to use Docker, you can install dependencies via requirements.txt

Preprocess data

The dataset should contain a folder with text images and csv file with annotations. The csv file should consist of two columns: "filename" with the relative path to the images (folder-name/image-name.png), and "text"-column with the image transcription.

To preprocess data and to create pickle:

python prepare_data.py \
	--data_csv_path data/hkr/folder-name.csv \
	--output_pkl_name data/folder-name_data.pkl

You can pass data_csv_path argument multuple times if you have a lot of csv files.

Train

python train.py \
	--data_pkl_path data/folder-name_data.pkl \
	--unlabeled_pkl_path data/folder-name_unlabeled_data.pkl \
	--lexicon_path path/to/lexicon.txt
  • unlabeled_pkl_path - path to unlabeled data, if you need to train model with images without transcriptions (these images will be used to train discriminator only).
  • lexicon_path - the path to the txt-file with text in each line.

Generate images

python generate_images.py \
	--checkpoint_path weights/model_checkpoint.pth.tar \
	--char_map_path data/folder-name_data.pkl \
	--num_imgs 10000 \
	--lexicon_path path/to/lexicon.txt \
	--output_path generated_synth/test
  • char_map_path - path to labeled pickle data, that contains the alphabet of the data (char_map).
  • lexicon_path - the path to the txt-file with text in each line. It may differ from the lexicon used for training the model.

scrabblegan's People

Contributors

arshjot avatar skalinin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

koryakovdmitry

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.