2.0.6 • Published 1 month ago

labeling-tool v2.0.6

Weekly downloads
-
License
-
Repository
github
Last release
1 month ago

labeling-tool

labeling-tool is powerful package built with React. It is designed for data labeling to assist with document markup tasks and training ML models.

Data labeling involves adding relevant keywords to unstructured data, such as text or images, enabling machines to automatically recognize and categorize the information. As the crucial first step in the ML lifecycle, data labeling forms the foundation for accurate predictive models.

The labeling-tool package simplifies editing table layouts and labeling documents, ultimately improving data extraction processes and preserving document structure.

img.png

Features and Benefits

Features

  • Import/Export Markup: labeling-tool allows users to seamlessly import and export markup data.
  • Feature-rich interface: A comprehensive panel with document controls such as zoom, undo, and pointer tool for selecting and moving markup.
  • Markup Creation: Easily create data markups within the document.
  • Merge/Split Table Cells: Allows managing table cells manually as needed during the labeling process.
  • Data Extraction: labeling-tool interface allows to extract data from the labeling tool (when the appropriate API handler is passed) improving efficiency and saving time.
  • Editable Extracted Content: Users have the ability to create, modify, and delete extracted content for each label, providing greater flexibility over the labeling process.
  • Delete Markup: Allows users to delete unnecessary or incorrect markup to maintain organized and accurate data labeling.
  • Labels Assignment: Assign selected labels to existing fields, simplifying data organization and extraction.
  • Markup Object Panel: Easily view and manage markup objects in a dedicated panel, with JSON preview available.
  • Hotkeys: Enhance productivity by using hotkeys to quickly access different tools.
  • Table Detection: Allows automatic table detection feature within the document (when the appropriate API handler is passed).
  • AutoSave: Ensure the security of your work with an autosave functionality that periodically saves markup data automatically.

Benefits

  • Streamlines data labeling, leading to better ML model training and development.
  • Preserves document content structure, ensuring the accuracy of extracted data.
  • Simplify data labeling and extraction process.
  • Enhances workflow efficiency, saving time and effort during the ML lifecycle.

API

The root LabelingTool component accepts the following prop to configure and customize its behavior:

config (required) The config object contains all necessary settings and configurations.

config object

KeyTypeRequiredDescription
apiObjectYesContains functions related to API interactions
addFieldForm() => ReactNodeNoRenders a custom form to create a new document fields
documentObjectYesDescribes the document being labeled
eventsObjectNoContains possible handlers for events
fieldsArray of objectsYesDefines the available document fields
markupObjectNoDefines existed markup objects
ocrObjectNoContains configuration related to Optical Character Recognition (OCR)
settingsObjectNoSettings related to the appearance and capabilities of the labeling-tool

document object

KeyTypeRequiredDescription
extraNamestringNoDocument extra name (displayed on UI)
enginestringYesThe primary OCR engine for handling data extraction
languagestringNoThe document language
namestringYesDocument name (displayed on UI)
pagesstring[]YesList of images, for ex. ['https://domain/doc-page.png']

field object

KeyTypeRequiredDescription
codestringYesField code
fieldTypestringYesField type, see possible values
fieldMetaObjectNoAdditional Field data depending on Field type. See enumFieldMetaShape, listFieldMetaShape, pairFieldMetaShape here
indexnumberYes - only for fieldType listField index
namestringYesField name
requiredbooleanYesDefine whenever field is required

ocr object

KeyTypeRequiredDescription
engines{ code: string, name: string }[]NoThe list of the available OCR engines
languages{ code: string, name: string }[]NoThe list of the available languages

api object

KeyTypeRequiredDescription
closeFunctionYesThe function handles the Labeling Tool closing
detectTablesFunctionNoThe function handles automatic table detection.Required only in case the tool for Table detection is available.Format: function(imageUrl, detectCoords){}
getImageFunctionNoThe function for getting the data of the document image.Format: (imageUrl) => URL.createObjectURL(imageBlob)
notifyObjectNoContains functions for showing notifications: error, info, success, warning.Ex. { success: (text) => console.log(text) }
ocrTableFunctionNoThe function handles extracting table data.Required only in case Table tool is available and ocr prop is passed as well).Format: function(engine, imageUrl, markupTable, language){}
ocrTextFunctionNoThe function handles extracting labels data.Required only in case Label tool is available and ocr prop is passed as well).Format: function(engine, imageUrl, labelCoords, language){}
saveFunctionNoThe function handles data extraction and markup saving.Format: function(markup, rotationAngles, language){}
saveMarkupFunctionYesThe function handles markup saving.Format: function(markup, rotationAngles, language, fields){}

markup object

KeyTypeRequiredDescription
labels{ label }[]NoThe list of the existed markup labels.Required only in case Label tool is available
tables{ table }[]NoThe list of the existed markup tables.Required only in case Table tool is available

settings object

KeyTypeRequiredDescription
featuresstring[]NoList of the available features. Possible values.
mode'default' or 'markup'NoRepresents the current mode.Markup mode enables the possibility to extract and see labels' content
panelsstring[]NoList of the panels displayed on UI.Toolbar panel displayed in the header and contains available tools.Markup sidebar locates in the right sidebar, contains markup objects properties and possible actions.Left sidebar displays markup objects list
toolsstring[]NoList of the available tools. Possible values

events object

KeyTypeRequiredDescription
onCloseFunctionNoThe callback function, executed on Labeling Tool close

Check the working example of the config here. This config could be used for playing with LabelingTool package.

Requirements

Min NodeJS version is 14.16.0

Installation and Usage

To get started, follow these steps:

  1. Install the package:
# If you use npm:
npm install labeling-tool

# Or if you use Yarn:
yarn add labeling-tool
  1. Then import the LabelingTool package and use as in the example:
import { LabelingTool } from 'labeling-tool'

function App() {
  return (
    <div className="App">
      <LabelingTool config={yourConfigHere} />
    </div>
  )
}

export default App
  1. Update yourConfigHere with your desired configurations.

Demo

There is a demo hosted on Demo Labeling Tool which allows to check labeling-tool package.

License

labeling-tool is licensed under the MIT License.