Code for generating synthetic text images as described in "Synthetic Data for Text Localisation in Natural Images", Ankush Gupta, Andrea Vedaldi, Andrew Zisserman, CVPR 2016.
See the codeCode for generating synthetic text images as described in "Synthetic Data for Text Localisation in Natural Images", Ankush Gupta, Andrea Vedaldi, Andrew Zisserman, CVPR 2016.
Synthetic Scene-Text Image Samples

The code in the master branch is for Python2. Python3 is supported in the python3 branch.
The main dependencies are:
pygame==2.0.0, opencv (cv2), PIL (Image), numpy, matplotlib, h5py, scipy
python gen.py --viz [--datadir <path-to-dowloaded-renderer-data>]
where, --datadir points to the renderer_data directory included in the
data torrent.
Specifying this datadir is optional, and if not specified, the script will
automatically download and extract the same renderer.tar.gz data file (~24 M).
This data file includes:
fonts/fontlist.txt with their paths).text_utils.py to see how the text inside this file is used by the renderer.invert_font_size.py).This script will generate random scene-text image samples and store them in an h5 file in results/SynthText.h5. If the --viz option is specified, the generated output will be visualized as the script is being run; omit the --viz option to turn-off the visualizations. If you want to visualize the results stored in results/SynthText.h5 later, run:
python visualize_results.py
A dataset with approximately 800000 synthetic scene-text images generated with this code can be found in the SynthText.zip file in the torrent here; dataset detais/description in readme.txt file in the same torrent.
Segmentation and depth-maps are required to use new images as background. Sample scripts for obtaining these are available here.
predict_depth.m MATLAB script to regress a depth mask for a given RGB image; uses the network of Liu etal. However, more recent works (e.g., this) might give better results.run_ucm.m and floodFill.py for getting segmentation masks using gPb-UCM.For an explanation of the fields in sample.h5 (e.g.: seg,area,label), please check this comment.
The 8,000 background images used in the paper, along with their
segmentation and depth masks, are included in the same
torrent
as the pre-generated dataset under the bg_data directory. The files are:
| filenames | description |
|---|---|
imnames.cp | names of images which do not contain background text |
bg_img.tar.gz | images (filter these using imnames.cp) |
depth.h5 | depth maps |
seg.h5 | segmentation maps |
use_preproc_bg.py provides sample code for reading this data.
Note: We do not own the copyright to these images.
Please refer to the paper for more information, or contact me (email address in the paper).
123 followers · starred Jan 2022
76 followers · starred Dec 2016
108 followers · starred Mar 2025
1,422 followers · starred Jan 2018
Code for generating synthetic text images as described in "Synthetic Data for Text Localisation in Natural Images", Ankush Gupta, Andrea Vedaldi, Andrew Zisserman, CVPR 2016.
See the codeCode for generating synthetic text images as described in "Synthetic Data for Text Localisation in Natural Images", Ankush Gupta, Andrea Vedaldi, Andrew Zisserman, CVPR 2016.
Synthetic Scene-Text Image Samples

The code in the master branch is for Python2. Python3 is supported in the python3 branch.
The main dependencies are:
pygame==2.0.0, opencv (cv2), PIL (Image), numpy, matplotlib, h5py, scipy
python gen.py --viz [--datadir <path-to-dowloaded-renderer-data>]
where, --datadir points to the renderer_data directory included in the
data torrent.
Specifying this datadir is optional, and if not specified, the script will
automatically download and extract the same renderer.tar.gz data file (~24 M).
This data file includes:
fonts/fontlist.txt with their paths).text_utils.py to see how the text inside this file is used by the renderer.invert_font_size.py).This script will generate random scene-text image samples and store them in an h5 file in results/SynthText.h5. If the --viz option is specified, the generated output will be visualized as the script is being run; omit the --viz option to turn-off the visualizations. If you want to visualize the results stored in results/SynthText.h5 later, run:
python visualize_results.py
A dataset with approximately 800000 synthetic scene-text images generated with this code can be found in the SynthText.zip file in the torrent here; dataset detais/description in readme.txt file in the same torrent.
Segmentation and depth-maps are required to use new images as background. Sample scripts for obtaining these are available here.
predict_depth.m MATLAB script to regress a depth mask for a given RGB image; uses the network of Liu etal. However, more recent works (e.g., this) might give better results.run_ucm.m and floodFill.py for getting segmentation masks using gPb-UCM.For an explanation of the fields in sample.h5 (e.g.: seg,area,label), please check this comment.
The 8,000 background images used in the paper, along with their
segmentation and depth masks, are included in the same
torrent
as the pre-generated dataset under the bg_data directory. The files are:
| filenames | description |
|---|---|
imnames.cp | names of images which do not contain background text |
bg_img.tar.gz | images (filter these using imnames.cp) |
depth.h5 | depth maps |
seg.h5 | segmentation maps |
use_preproc_bg.py provides sample code for reading this data.
Note: We do not own the copyright to these images.
Please refer to the paper for more information, or contact me (email address in the paper).
123 followers · starred Jan 2022
76 followers · starred Dec 2016
108 followers · starred Mar 2025
1,422 followers · starred Jan 2018