Giter Site home page Giter Site logo

nuspect-alan / scatteract Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bloomberg/scatteract

0.0 0.0 0.0 84.54 MB

Project which implements extraction of data from scatter plots

Jupyter Notebook 70.19% Python 25.15% Makefile 0.05% C++ 4.61%

scatteract's Introduction

Scatteract

Scatteract

Scatteract is a framework to automatically extract data from the image of scatter plots. We use TensorBox1 to detect the relevant objects (points, tick marks and tick values), Tesseract for the OCR, and several heuristics to extract the points in chart coordinates. See the paper for details. This repository is meant to support the paper and is not an attempt at creating an actual open source project.

1Disclaimer: We vendored the TensorBox dependency into the tensorbox folder since there is no way to pull it in from pypi. We have made no change to this code.

Requirements:

tensorflow==0.10.0rc0
scipy (tested on 0.17.1)
scikit-learn (tested on 0.17.1)
pandas (tested on 0.18.1)
Pillow (PIL) (tested on 3.2.0)
numpy (tested on 1.10.4)
opencv-python (cv2) (tested on 2.4.10)
matplotlib (tested on 1.5.1)
runcython (tested on 0.25)
pyocr (tested on 0.4.6)
tesseract-ocr (tested on 3.02)

On Python 2.7+, the following compatibility module is also required:

backports.functools_lru_cache

How to use:

Generate training and testing data

$ python generate_random_scatter.py --directory plots_v1 --n_train 25000 --n_test 500 

Train object detection models

Note that we are using an older version of TensorBox which crashes once training is done because of threading issues, nevertheless the trained models are successfully saved.

& cd tensorbox/utils/ && make && cd ../..
$ python tensorbox/train_obj_model.py --hypes hypes/lstm_rezoom_plot_points.json --gpu 0 --logdir output  --name points_v1
$ python tensorbox/train_obj_model.py --hypes hypes/lstm_rezoom_plot_ticks.json --gpu 0 --logdir output  --name ticks_v1
$ python tensorbox/train_obj_model.py --hypes hypes/lstm_rezoom_plot_labels.json --gpu 0 --logdir output  --name labels_v1

IPython Notebook

The ipython notebook can be used after the object detection models are trained. It allows you to interact with the building blocks of Scatteract and visualize their outputs.

Test object detection models

On the randomly generated test set:
$ chmod +x tensorbox -R
$ python test_obj_model.py --model_dir output/points_v1 --iteration 125000 --image_dir data/plots_v1 --true_idl data/plots_v1/test_points.idl 
$ python test_obj_model.py --model_dir output/ticks_v1 --iteration 125000 --image_dir data/plots_v1 --true_idl data/plots_v1/test_ticks.idl 
$ python test_obj_model.py --model_dir output/labels_v1 --iteration 125000 --image_dir data/plots_v1 --true_idl data/plots_v1/test_labels.idl 

On a currated randomly generated test set:
$ chmod +x tensorbox -R
$ python test_obj_model.py --model_dir output/points_v1 --iteration 125000 --image_dir data/plot_test --true_idl data/plot_test/points.idl
$ python test_obj_model.py --model_dir output/ticks_v1 --iteration 125000 --image_dir data/plot_test --true_idl data/plot_test/ticks.idl
$ python test_obj_model.py --model_dir output/labels_v1 --iteration 125000 --image_dir data/plot_test --true_idl data/plot_test/labels.idl 

Test OCR

On the randomly generated test set:
$ python generate_test_tesseract.py --image_dir data/plots_v1 --label_values_idl  data/plots_v1/test_label_values.idl 
$ python tesseract.py --tsv_truth data/plots_v1/label_image_values.tsv --image_dir data/plots_v1/label_images

On a currated randomly generated test set:
$ python tesseract.py --tsv_truth data/plot_test/label_image_values.tsv --image_dir data/plot_test/label_images

Test end-to-end system

On a currated randomly generated test set:
& python scatter_extract.py --model_dict '{"ticks":"./output/ticks_v1", "labels":"./output/labels_v1","points":"./output/points_v1"}' \
--true_idl_dict '{"ticks":"./data/plot_test/ticks.idl","labels":"./data/plot_test/labels.idl", "points":"./data/plot_test/points.idl"}' \
--image_output_dir image_output --csv_output_dir csv_output --true_coord_idl ./data/plot_test/coords.idl \
--iteration 125000 --image_dir data/plot_test/ 

Predict with end-to-end system (i.e. extract data points from plots with no ground truth)

On a set of plots scrapped from the web:
$ python scatter_extract.py --model_dict '{"ticks":"./output/ticks_v1", "labels":"./output/labels_v1","points":"./output/points_v1"}' \
--iteration 125000 --image_dir data/plot_real/ --predict_idl ./data/plot_real/test_real.idl --image_output_dir image_output --csv_output_dir csv_output

scatteract's People

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.