astiocr

package module
v0.0.0-...-038f07b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2018 License: MIT Imports: 31 Imported by: 0

README

Installation

$ go get -u github.com/asticode/go-astiocr/...

Train your model

For the next commands we assume you are in $GOPATH/src/github.com/asticode/go-astiocr

Set up configuration

Copy astiocr/local.toml.dist to astiocr/local.toml and replace the desired values.

Gather data

Then run:

$ go run astiocr/main.go gather -v -c astiocr/local.toml

or if make is installed on your system:

$ make gather

List available trained models

Run:

$ go run astiocr/main.go list -v -c astiocr/local.toml

or if make is installed on your system:

$ make list

Configure the model

Run:

$ go run astiocr/main.go configure -v -c astiocr/local.toml -n <model name>

Train the model

Move to your output path and run either scripts/train.bat or scripts/train.sh depending on your platform.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigurationColor

type ConfigurationColor struct {
	Background astiimage.RGBA   `toml:"background"`
	Fonts      []astiimage.RGBA `toml:"fonts"`
}

ConfigurationColor represents a color configuration

type ConfigurationDetector

type ConfigurationDetector struct {
	// Path to the model
	ModelPath string `toml:"model_path"`
}

ConfigurationDetector represents a detector configuration

type ConfigurationFont

type ConfigurationFont struct {
	File          string  `toml:"file"`
	PositionRatio float64 `toml:"position_ratio"`
}

ConfigurationFont represents a font configuration

type ConfigurationImage

type ConfigurationImage struct {
	Height int `toml:"height"`
	Width  int `toml:"width"`
}

ConfigurationImage represents an image configuration

type ConfigurationTrainer

type ConfigurationTrainer struct {
	// Path to the cache directory
	CacheDirectoryPath string `toml:"cache_directory_path"`

	// Number of images generated for both training and test purposes
	Count int `toml:"count"`

	// Color options
	Colors []ConfigurationColor `toml:"colors"`

	// Font options
	Fonts []ConfigurationFont `toml:"fonts"`

	// Image options
	Image ConfigurationImage `toml:"image"`

	// Path to the output directory
	OutputDirectoryPath string `toml:"output_directory_path"`

	// Path to the python binary
	PythonBinaryPath string `toml:"python_binary_path"`

	// Path to the scripts directory
	ScriptsDirectoryPath string `toml:"scripts_directory_path"`

	// Show box around labels
	ShowBox bool `toml:"show_box"`

	// Show entire grid
	ShowGrid bool `toml:"show_grid"`

	// Path to the tensorflow models directory
	TensorFlowModelsDirectoryPath string `toml:"tensorflow_models_directory_path"`

	// The proportion of test data in the generated images
	TestDataProportion float64 `toml:"test_data_proportion"`
}

ConfigurationTrainer represents a trainer configuration

type DetectionBox

type DetectionBox struct {
	X1, X2 float64
	Y1, Y2 float64
}

DetectionBox represents a detection box

type DetectionResult

type DetectionResult struct {
	Box         DetectionBox
	Label       string
	Probability float64
}

DetectionResult represents a detection result

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

Detector represents an object capable of detecting OCR

func NewDetector

func NewDetector(c ConfigurationDetector) (d *Detector, err error)

NewDetector creates a new detector

func (*Detector) Close

func (d *Detector) Close() error

Close implements the io.Closer interface

func (*Detector) Detect

func (d *Detector) Detect(ctx context.Context, src string) (rs []DetectionResult, err error)

Detect detects OCR on an image

type GatherSummary

type GatherSummary struct {
	Images []GatherSummaryImage `json:"images"`
}

GatherSummary represents a gather summary

type GatherSummaryBox

type GatherSummaryBox struct {
	Label      string `json:"label"`
	LabelIndex int    `json:"label_index"`
	X0         int    `json:"x0"`
	X1         int    `json:"x1"`
	Y0         int    `json:"y0"`
	Y1         int    `json:"y1"`
}

GatherSummaryBox represents a gather summary box

type GatherSummaryImage

type GatherSummaryImage struct {
	Height int                `json:"height"`
	Boxes  []GatherSummaryBox `json:"boxes"`
	Path   string             `json:"path"`
	Width  int                `json:"width"`
}

GatherSummaryImage represents a gather summary image

type Trainer

type Trainer struct {
	// contains filtered or unexported fields
}

Trainer represents an object capable of training a model

func NewTrainer

func NewTrainer(c ConfigurationTrainer) (t *Trainer, err error)

NewTrainer creates a new trainer

func (*Trainer) Configure

func (t *Trainer) Configure(ctx context.Context, modelName string) (err error)

Configure configures the model

func (*Trainer) Gather

func (t *Trainer) Gather(ctx context.Context) (err error)

Gather gathers training data

func (*Trainer) TrainedModels

func (t *Trainer) TrainedModels(ctx context.Context) (models map[string]string, err error)

List lists available trained models

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL