Skip to content

Commit

Permalink
Mixin and fix Image (#59)
Browse files Browse the repository at this point in the history
* Initial Develop branch

* update stage width even for plain images (#57)

* Header var fix (#56)

* add templated header

* fix test

* removing debug messages

* Add gitter badge

* HOC of controls (#58)

* Completion up

* Labels module to HOC function

* Label Mixin

* Release v.0.1.2

* Added pycache in gitignore
  • Loading branch information
shevchenkonik authored Sep 26, 2019
1 parent e6f4dc8 commit bc41bf8
Show file tree
Hide file tree
Showing 18 changed files with 127 additions and 151 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*~
__pycache__/

# Logs
logs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="./images/heartex_icon_opossum_green.svg" align="right" title="Label Studio by Heartex Labs" height="140">

![GitHub](https://img.shields.io/github/license/heartexlabs/label-studio?logo=heartex) [![Build Status](https://travis-ci.com/heartexlabs/label-studio.svg?branch=master)](https://travis-ci.com/heartexlabs/label-studio) [![codecov](https://codecov.io/gh/heartexlabs/label-studio/branch/master/graph/badge.svg)](https://codecov.io/gh/heartexlabs/label-studio) ![GitHub release](https://img.shields.io/github/v/release/heartexlabs/label-studio?include_prereleases)
![GitHub](https://img.shields.io/github/license/heartexlabs/label-studio?logo=heartex) [![Build Status](https://travis-ci.com/heartexlabs/label-studio.svg?branch=master)](https://travis-ci.com/heartexlabs/label-studio) [![codecov](https://codecov.io/gh/heartexlabs/label-studio/branch/master/graph/badge.svg)](https://codecov.io/gh/heartexlabs/label-studio) ![GitHub release](https://img.shields.io/github/v/release/heartexlabs/label-studio?include_prereleases) [![Gitter](https://badges.gitter.im/label-studio/community.svg)](https://gitter.im/label-studio/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

Label Studio is an open-source, configurable data annotation tool. Its purpose is to enable you to label different types of data using the most convenient interface with a standardized output format.

Expand Down
6 changes: 3 additions & 3 deletions build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"main.css": "/static/css/main.f5b8907f.chunk.css",
"main.js": "/static/js/main.dc283c49.chunk.js",
"main.js": "/static/js/main.af5ff5e7.chunk.js",
"static/css/1.d031dc33.chunk.css": "/static/css/1.d031dc33.chunk.css",
"static/js/1.3ba35965.chunk.js": "/static/js/1.3ba35965.chunk.js",
"static/js/1.aeef6680.chunk.js": "/static/js/1.aeef6680.chunk.js",
"runtime~main.js": "/static/js/runtime~main.229c360f.js",
"static/media/semantic.min.css": "/static/media/brand-icons.a1a749e8.svg",
"static/media/config.xml": "/static/media/config.c5233796.xml",
"index.html": "/index.html",
"precache-manifest.d288bd8db6a84bc7ce19fd06c0acc006.js": "/precache-manifest.d288bd8db6a84bc7ce19fd06c0acc006.js",
"precache-manifest.2eece7d8fb6632ba49e2bc375ba51624.js": "/precache-manifest.2eece7d8fb6632ba49e2bc375ba51624.js",
"service-worker.js": "/service-worker.js"
}
2 changes: 1 addition & 1 deletion build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><link rel="shortcut icon" href="/favicon.ico"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><style>body{position:relative;padding-top:10px}.footer{text-align:center;margin:0 auto;bottom:0;left:0;right:0;margin-bottom:14px;margin-top:14px}</style><link rel="manifest" href="/manifest.json"><title>Label Studio</title><link href="/static/css/1.d031dc33.chunk.css" rel="stylesheet"><link href="/static/css/main.f5b8907f.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><img src="logo.png" alt="Heartex Logo" style="display:block;margin:0 auto;width:100px;height:100px"/><h1 style="text-align:center;margin-top:20px">Label Studio</h1><h2 style="text-align:center;margin-bottom:20px">Annotations for different types of data</h2><div id="label-studio"></div><footer class="footer">Made by <a target="_blank" href="https://heartex.net">Heartex</a> in San Francisco</footer><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],p[t]&&i.push(p[t][0]),p[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return c.push.apply(c,u||[]),a()}function a(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==p[u]&&(n=!1)}n&&(c.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},p={2:0},c=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="/static/js/1.3ba35965.chunk.js"></script><script src="/static/js/main.dc283c49.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><link rel="shortcut icon" href="/favicon.ico"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><style>body{position:relative;padding-top:10px}.footer{text-align:center;margin:0 auto;bottom:0;left:0;right:0;margin-bottom:14px;margin-top:14px}</style><link rel="manifest" href="/manifest.json"><title>Label Studio</title><link href="/static/css/1.d031dc33.chunk.css" rel="stylesheet"><link href="/static/css/main.f5b8907f.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><img src="logo.png" alt="Heartex Logo" style="display:block;margin:0 auto;width:100px;height:100px"/><h1 style="text-align:center;margin-top:20px">Label Studio</h1><h2 style="text-align:center;margin-bottom:20px">Annotations for different types of data</h2><div id="label-studio"></div><footer class="footer">Made by <a target="_blank" href="https://heartex.net">Heartex</a> in San Francisco</footer><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],p[t]&&i.push(p[t][0]),p[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return c.push.apply(c,u||[]),a()}function a(){for(var e,r=0;r<c.length;r++){for(var t=c[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==p[u]&&(n=!1)}n&&(c.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},p={2:0},c=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var r=window.webpackJsonp=window.webpackJsonp||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="/static/js/1.aeef6680.chunk.js"></script><script src="/static/js/main.af5ff5e7.chunk.js"></script></body></html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ self.__precacheManifest = [
"url": "/static/media/outline-icons.cd6c777f.woff2"
},
{
"revision": "dc283c4939ff11143827",
"revision": "af5ff5e7bbdc9c7c3442",
"url": "/static/css/main.f5b8907f.chunk.css"
},
{
"revision": "a1a749e89f578a49306ec2b055c073da",
"url": "/static/media/brand-icons.a1a749e8.svg"
},
{
"revision": "3ba3596589236c233d60",
"url": "/static/js/1.3ba35965.chunk.js"
"revision": "aeef66800f0d5c43c35e",
"url": "/static/js/1.aeef6680.chunk.js"
},
{
"revision": "229c360febb4351a89df",
Expand Down Expand Up @@ -64,21 +64,21 @@ self.__precacheManifest = [
"url": "/static/media/config.1890026d.xml"
},
{
"revision": "dc283c4939ff11143827",
"url": "/static/js/main.dc283c49.chunk.js"
"revision": "af5ff5e7bbdc9c7c3442",
"url": "/static/js/main.af5ff5e7.chunk.js"
},
{
"revision": "ef60a4f6c25ef7f39f2d25a748dbecfe",
"url": "/static/media/outline-icons.ef60a4f6.woff"
},
{
"revision": "701ae6abd4719e9c2ada3535a497b341",
"url": "/static/media/outline-icons.701ae6ab.eot"
},
{
"revision": "ad97afd3337e8cda302d10ff5a4026b8",
"url": "/static/media/outline-icons.ad97afd3.ttf"
},
{
"revision": "701ae6abd4719e9c2ada3535a497b341",
"url": "/static/media/outline-icons.701ae6ab.eot"
},
{
"revision": "0ab54153eeeca0ce03978cc463b257f7",
"url": "/static/media/icons.0ab54153.woff2"
Expand All @@ -99,14 +99,6 @@ self.__precacheManifest = [
"revision": "9c74e172f87984c48ddf5c8108cabe67",
"url": "/static/media/flags.9c74e172.png"
},
{
"revision": "13db00b7a34fee4d819ab7f9838cc428",
"url": "/static/media/brand-icons.13db00b7.eot"
},
{
"revision": "c5ebe0b32dc1b5cc449a76c4204d13bb",
"url": "/static/media/brand-icons.c5ebe0b3.ttf"
},
{
"revision": "8e3c7f5520f5ae906c6cf6d7f3ddcd19",
"url": "/static/media/icons.8e3c7f55.eot"
Expand All @@ -115,6 +107,14 @@ self.__precacheManifest = [
"revision": "b87b9ba532ace76ae9f6edfe9f72ded2",
"url": "/static/media/icons.b87b9ba5.ttf"
},
{
"revision": "13db00b7a34fee4d819ab7f9838cc428",
"url": "/static/media/brand-icons.13db00b7.eot"
},
{
"revision": "c5ebe0b32dc1b5cc449a76c4204d13bb",
"url": "/static/media/brand-icons.c5ebe0b3.ttf"
},
{
"revision": "82f60bd0b94a1ed68b1e6e309ce2e8c3",
"url": "/static/media/outline-icons.82f60bd0.svg"
Expand All @@ -124,11 +124,11 @@ self.__precacheManifest = [
"url": "/static/media/icons.962a1bf3.svg"
},
{
"revision": "3ba3596589236c233d60",
"revision": "aeef66800f0d5c43c35e",
"url": "/static/css/1.d031dc33.chunk.css"
},
{
"revision": "c0ead814f97a82f21020a727a4b551a3",
"revision": "207ba8e666cd6644765c8913ee4b2cc7",
"url": "/index.html"
}
];
2 changes: 1 addition & 1 deletion build/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");

importScripts(
"/precache-manifest.d288bd8db6a84bc7ce19fd06c0acc006.js"
"/precache-manifest.2eece7d8fb6632ba49e2bc375ba51624.js"
);

workbox.clientsClaim();
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/static/js/main.af5ff5e7.chunk.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion build/static/js/main.dc283c49.chunk.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "label-studio",
"version": "0.1.1",
"version": "0.1.2",
"private": true,
"description": "Label Studio is a multi-domain data labeling tool with standardized output format",
"author": {
Expand Down
56 changes: 17 additions & 39 deletions src/interfaces/control/Labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Types from "../../core/Types";
import { LabelModel } from "./Label"; // eslint-disable-line no-unused-vars
import { guidGenerator } from "../../core/Helpers";
import SelectedModelMixin from "../mixins/SelectedModel";
import LabelMixin from "../mixins/LabelMixin";

/**
* Labels tag, create a group of labels
Expand All @@ -35,35 +36,26 @@ const TagAttrs = types.model({
selectionstyle: types.maybeNull(types.optional(types.string, "basic", "border", "bottom")),
});

const Model = types
.model({
id: types.optional(types.identifier, guidGenerator),
pid: types.optional(types.string, guidGenerator),
type: "labels",
showinline: types.optional(types.boolean, true),
children: Types.unionArray(["labels", "label", "choices", "choice"]),
})
/**
* @param {boolean} showinline
* @param {identifier} id
* @param {string} pid
*/
const ModelAttrs = types.model({
id: types.optional(types.identifier, guidGenerator),
pid: types.optional(types.string, guidGenerator),
type: "labels",
showinline: types.optional(types.boolean, true),
children: Types.unionArray(["labels", "label", "choice"]),
});

const Model = LabelMixin.props({ _type: "labels" })
.views(self => ({
get shouldBeUnselected() {
return self.choice === "single";
},
}))
.actions(self => ({
getSelectedColor() {
// return first selected label color
const sel = self.children.find(c => c.selected === true);
return sel && sel.background;
},
/**
* Usage check of selected labels before send completion to server
*/
beforeSend() {
const names = self.getSelectedNames();

if (names && self.type === "labels") {
self.unselectAll();
}
},
toStateJSON() {
const names = self.getSelectedNames();
if (names && names.length) {
Expand All @@ -78,25 +70,11 @@ const Model = types
};
}
},

fromStateJSON(obj, fromModel) {
self.unselectAll();

if (!obj.value.labels) throw new Error("No labels param");

if (obj.id) self.pid = obj.id;

obj.value.labels.forEach(l => {
const label = self.findLabel(l);
if (!label) throw new Error("No label " + obj.value.label);

label.markSelected(true);
});
},
}));

const LabelsModel = types.compose(
"LabelsModel",
ModelAttrs,
TagAttrs,
Model,
SelectedModelMixin,
Expand All @@ -112,7 +90,7 @@ const HtxLabels = observer(({ item }) => {
flexFlow: "wrap",
};

if (item.showinline == "false") {
if (!item.showinline) {
style["flexDirection"] = "column";
style["alignItems"] = "flex-start";
style["marginTop"] = "0";
Expand Down
84 changes: 14 additions & 70 deletions src/interfaces/control/RectangleLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import Registry from "../../core/Registry";

import { guidGenerator } from "../../core/Helpers";
import SelectedModelMixin from "../mixins/SelectedModel";
import InfoModal from "../../components/Infomodal/Infomodal";

import { HtxLabels, LabelsModel } from "./Labels";
import { RectangleModel } from "./Rectangle";
import LabelMixin from "../mixins/LabelMixin";

/**
* RectangleLabels tag creates labeled rectangles
Expand All @@ -38,90 +37,35 @@ const TagAttrs = types.model({
toname: types.maybeNull(types.string),
});

const Model = types
.model("RectangleLabelsModel", {
id: types.optional(types.identifier, guidGenerator),
pid: types.optional(types.string, guidGenerator),
type: "rectanglelabels",
children: Types.unionArray(["labels", "label", "choice"]),
})
.views(self => ({
get shouldBeUnselected() {
return self.choice === "single";
},
}))
.actions(self => ({
getSelectedColor() {
// return first selected label color
const sel = self.children.find(c => c.selected === true);
return sel && sel.background;
},

/**
* Usage check of selected labels before send completion to server
*/
beforeSend() {
const names = self.getSelectedNames();

if (names && self.type === "rectanglelabels") {
self.unselectAll();
}
},

fromStateJSON(obj, fromModel) {
self.unselectAll();

if (!obj.value.rectanglelabels) {
InfoModal.error("Error with labels.");
return;
}

if (obj.id) self.pid = obj.id;

/**
* Found correct label from config
*/
obj.value.rectanglelabels.forEach(inLabel => {
const label = self.findLabel(inLabel);

if (!label) {
InfoModal.error("Error with labels. Not found: " + obj.value.rectanglelabels);
return;
}
const ModelAttrs = types.model("RectangleLabelsModel", {
id: types.optional(types.identifier, guidGenerator),
pid: types.optional(types.string, guidGenerator),
type: "rectanglelabels",
children: Types.unionArray(["labels", "label", "choice"]),
});

label.markSelected(true);
});
},
}));
const Model = LabelMixin.props({ _type: "rectanglelabels" }).views(self => ({
get shouldBeUnselected() {
return self.choice === "single";
},
}));

const Composition = types.compose(
LabelsModel,
ModelAttrs,
RectangleModel,
TagAttrs,
Model,
SelectedModelMixin,
);

const RectangleLabelsModel = types.compose(
"RectangleLabelsModel",
Composition,
);

const HtxRectangleLabels = observer(({ item }) => {
return <HtxLabels item={item} />;
// return (
// <div
// style={{
// marginTop: "1em",
// marginBottom: "1em",
// display: "flex",
// justifyContent: "flex-start",
// alignItems: "center",
// flexFlow: "wrap",
// }}
// >
// {Tree.renderChildren(item)}
// </div>
// );
});

Registry.addTag("rectanglelabels", RectangleLabelsModel, HtxRectangleLabels);
Expand Down
Loading

0 comments on commit bc41bf8

Please sign in to comment.