globalbridge-lsf-custom
Version:
GlobalBridge in-house labeling tool, originating from LSF.
75 lines (64 loc) • 2.63 kB
JavaScript
import React from 'react';
import { observer } from 'mobx-react';
import { types } from 'mobx-state-tree';
import LabelMixin from '../../mixins/LabelMixin';
import Registry from '../../core/Registry';
import SelectedModelMixin from '../../mixins/SelectedModel';
import Types from '../../core/Types';
import { HtxLabels, LabelsModel } from './Labels/Labels';
import { KeyPointModel } from './KeyPoint';
import ControlBase from './Base';
/**
* The `KeyPointLabels` tag creates labeled keypoints. Use to apply labels to identified key points, such as identifying facial features for a facial recognition labeling project.
*
* Use with the following data types: image.
* @example
* <!--Basic keypoint image labeling configuration for multiple regions-->
* <View>
* <KeyPointLabels name="kp-1" toName="img-1">
* <Label value="Face" />
* <Label value="Nose" />
* </KeyPointLabels>
* <Image name="img-1" value="$img" />
* </View>
* @name KeyPointLabels
* @regions KeyPointRegion
* @meta_title Keypoint Label Tag for Labeling Keypoints
* @meta_description Customize Label Studio with the KeyPointLabels tag to label keypoints for computer vision machine learning and data science projects.
* @param {string} name - Name of the element
* @param {string} toName - Name of the image to label
* @param {single|multiple=} [choice=single] - Configure whether you can select one or multiple labels
* @param {number} [maxUsages] - Maximum number of times a label can be used per task
* @param {boolean} [showInline=true] - Show labels in the same visual line
* @param {float=} [opacity=0.9] - Opacity of the keypoint
* @param {number=} [strokeWidth=1] - Width of the stroke
*/
const Validation = types.model({
controlledTags: Types.unionTag(['Image']),
});
const ModelAttrs = types
.model('KeyPointLabelsModel', {
type: 'keypointlabels',
children: Types.unionArray(['label', 'header', 'view', 'hypertext']),
})
.views(self => ({
get hasStates() {
const states = self.states();
return states && states.length > 0;
},
}));
const Composition = types.compose(
LabelsModel,
ModelAttrs,
KeyPointModel,
Validation,
LabelMixin,
SelectedModelMixin.props({ _child: 'LabelModel' }),
ControlBase,
);
const KeyPointLabelsModel = types.compose('KeyPointLabelsModel', Composition);
const HtxKeyPointLabels = observer(({ item }) => {
return <HtxLabels item={item} />;
});
Registry.addTag('keypointlabels', KeyPointLabelsModel, HtxKeyPointLabels);
export { HtxKeyPointLabels, KeyPointLabelsModel };