Skip to content

Commit

Permalink
1.6.0-alpha relese merge (#93)
Browse files Browse the repository at this point in the history
* Merge pull request #70 from SkalskiP/develop (#71)

* new gif with ssd and posenet

* Add Docker Support (#74)

* add Dockerfile for make-sense

* Update README for Docker

* README updated

* README updated with docker logs

* readme updated

* Update Dockerfile

* Update README.md

* basic stats

* README.md update (#78) (#79)

* Merge pull request #70 from SkalskiP/develop (#71)

* new gif with ssd and posenet

* Add Docker Support (#74)

* add Dockerfile for make-sense

* Update README for Docker

* README updated

* README updated with docker logs

* readme updated

* Update Dockerfile

* Update README.md

* basic stats

Co-authored-by: Fatih Baltacı <[email protected]>

Co-authored-by: Fatih Baltacı <[email protected]>

* add cross hair (#90)

* Piotr | Line labels creation and export (#89)

* initial changes: adding line labels to redux + addling line tab to right side navigation bar

* adding new lines and base rendering

* up

* line style + snapping to rect added

* highlight logic added

* line rendering engine is working

* line rendering engine update + marking line labeled images added

* serializing to CSV

* up

* after PR

* after PR

* quick fix

* Piotr | Image recognition (#92)

* image recognition initial commit

* setup before image recognition tagging

* base tag assignment added

* default screen when empty label list

* image recognition added

* after CR

Co-authored-by: PLE12366003 <[email protected]>
Co-authored-by: Fatih Baltacı <[email protected]>
  • Loading branch information
3 people authored Jun 15, 2020
1 parent 0d3cbb1 commit 16b06c8
Show file tree
Hide file tree
Showing 52 changed files with 1,186 additions and 88 deletions.
Binary file added public/ico/cross-hair.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/ico/line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/ico/object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/ico/point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/data/enums/LabelType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export enum LabelType {
NAME = "NAME",
POINT = "POINT",
RECTANGLE = "RECTANGLE",
POLYGON = "POLYGON"
POLYGON = "POLYGON",
LINE = "LINE"
}
4 changes: 4 additions & 0 deletions src/data/enums/LineAnchorType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum LineAnchorType {
START = "START",
END = "END"
}
9 changes: 9 additions & 0 deletions src/data/export/LineExportFormatData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {IExportFormat} from "../../interfaces/IExportFormat";
import {ExportFormatType} from "../enums/ExportFormatType";

export const LineExportFormatData: IExportFormat[] = [
{
type: ExportFormatType.CSV,
label: "Single CSV file."
}
];
9 changes: 9 additions & 0 deletions src/data/export/TagExportFormatData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {IExportFormat} from "../../interfaces/IExportFormat";
import {ExportFormatType} from "../enums/ExportFormatType";

export const TagExportFormatData: IExportFormat[] = [
{
type: ExportFormatType.CSV,
label: "Single CSV file."
}
];
2 changes: 1 addition & 1 deletion src/data/info/EditorFeatureData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const EditorFeatureData: IEditorFeature[] = [
imageAlt: "private",
},
{
displayText: "Support multiple label types - bounding box, polygon, point",
displayText: "Support multiple label types - rects, lines, points and polygons",
imageSrc: "img/labels.png",
imageAlt: "labels",
},
Expand Down
8 changes: 7 additions & 1 deletion src/data/info/LabelToolkitData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const LabelToolkitData: ILabelToolkit[] = [
},
{
labelType: LabelType.RECTANGLE,
headerText: "Bounding box",
headerText: "Rect",
imageSrc: "ico/rectangle.png",
imageAlt: "rectangle",
},
Expand All @@ -26,6 +26,12 @@ export const LabelToolkitData: ILabelToolkit[] = [
imageSrc: "ico/point.png",
imageAlt: "point",
},
{
labelType: LabelType.LINE,
headerText: "Line",
imageSrc: "ico/line.png",
imageAlt: "line",
},
{
labelType: LabelType.POLYGON,
headerText: "Polygon",
Expand Down
4 changes: 4 additions & 0 deletions src/logic/actions/EditorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {ImageUtil} from "../../utils/ImageUtil";
import {GeneralSelector} from "../../store/selectors/GeneralSelector";
import {ViewPortHelper} from "../helpers/ViewPortHelper";
import {CustomCursorStyle} from "../../data/enums/CustomCursorStyle";
import {LineRenderEngine} from "../render/LineRenderEngine";

export class EditorActions {

Expand All @@ -34,6 +35,9 @@ export class EditorActions {
case LabelType.POINT:
EditorModel.supportRenderingEngine = new PointRenderEngine(EditorModel.canvas);
break;
case LabelType.LINE:
EditorModel.supportRenderingEngine = new LineRenderEngine(EditorModel.canvas);
break;
case LabelType.POLYGON:
EditorModel.supportRenderingEngine = new PolygonRenderEngine(EditorModel.canvas);
break;
Expand Down
13 changes: 12 additions & 1 deletion src/logic/actions/LabelActions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {LabelsSelector} from "../../store/selectors/LabelsSelector";
import {ImageData, LabelName, LabelPoint, LabelPolygon, LabelRect} from "../../store/labels/types";
import {ImageData, LabelLine, LabelName, LabelPoint, LabelPolygon, LabelRect} from "../../store/labels/types";
import {filter} from "lodash";
import {store} from "../../index";
import {updateImageData, updateImageDataById} from "../../store/labels/actionCreators";
Expand Down Expand Up @@ -48,6 +48,17 @@ export class LabelActions {
store.dispatch(updateImageDataById(imageData.id, newImageData));
}

public static deleteLineLabelById(imageId: string, labelLineId: string) {
const imageData: ImageData = LabelsSelector.getImageDataById(imageId);
const newImageData = {
...imageData,
labelLines: filter(imageData.labelLines, (currentLabel: LabelLine) => {
return currentLabel.id !== labelLineId;
})
};
store.dispatch(updateImageDataById(imageData.id, newImageData));
}

public static deletePolygonLabelById(imageId: string, labelPolygonId: string) {
const imageData: ImageData = LabelsSelector.getImageDataById(imageId);
const newImageData = {
Expand Down
13 changes: 11 additions & 2 deletions src/logic/context/EditorContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {ViewPortActions} from "../actions/ViewPortActions";
import {Direction} from "../../data/enums/Direction";
import {PlatformUtil} from "../../utils/PlatformUtil";
import {LabelActions} from "../actions/LabelActions";
import {LineRenderEngine} from "../render/LineRenderEngine";

export class EditorContext extends BaseContext {
public static actions: HotKeyAction[] = [
Expand All @@ -26,8 +27,16 @@ export class EditorContext extends BaseContext {
{
keyCombo: ["Escape"],
action: (event: KeyboardEvent) => {
if (EditorModel.supportRenderingEngine && EditorModel.supportRenderingEngine.labelType === LabelType.POLYGON)
(EditorModel.supportRenderingEngine as PolygonRenderEngine).cancelLabelCreation();
if (EditorModel.supportRenderingEngine) {
switch (EditorModel.supportRenderingEngine.labelType) {
case LabelType.POLYGON:
(EditorModel.supportRenderingEngine as PolygonRenderEngine).cancelLabelCreation();
break;
case LabelType.LINE:
(EditorModel.supportRenderingEngine as LineRenderEngine).cancelLabelCreation();
break;
}
}
EditorActions.fullRender();
}
},
Expand Down
59 changes: 59 additions & 0 deletions src/logic/export/LineLabelExport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {ExportFormatType} from "../../data/enums/ExportFormatType";
import {LabelsSelector} from "../../store/selectors/LabelsSelector";
import {ImageData, LabelLine, LabelName} from "../../store/labels/types";
import {saveAs} from "file-saver";
import {ExporterUtil} from "../../utils/ExporterUtil";
import {ImageRepository} from "../imageRepository/ImageRepository";
import {findLast} from "lodash";

export class LineLabelsExporter {
public static export(exportFormatType: ExportFormatType): void {
switch (exportFormatType) {
case ExportFormatType.CSV:
LineLabelsExporter.exportAsCSV();
break;
default:
return;
}
}

private static exportAsCSV(): void {
const content: string = LabelsSelector.getImagesData()
.map((imageData: ImageData) => {
return LineLabelsExporter.wrapLineLabelsIntoCSV(imageData)})
.filter((imageLabelData: string) => {
return !!imageLabelData})
.join("\n");

const blob = new Blob([content], {type: "text/plain;charset=utf-8"});
try {
saveAs(blob, `${ExporterUtil.getExportFileName()}.csv`);
} catch (error) {
// TODO
throw new Error(error);
}
}

private static wrapLineLabelsIntoCSV(imageData: ImageData): string {
if (imageData.labelLines.length === 0 || !imageData.loadStatus)
return null;

const image: HTMLImageElement = ImageRepository.getById(imageData.id);
const labelNames: LabelName[] = LabelsSelector.getLabelNames();
const labelLinesString: string[] = imageData.labelLines.map((labelLine: LabelLine) => {
const labelName: LabelName = findLast(labelNames, {id: labelLine.labelId});
const labelFields = !!labelName ? [
labelName.name,
Math.round(labelLine.line.start.x).toString(),
Math.round(labelLine.line.start.y).toString(),
Math.round(labelLine.line.end.x).toString(),
Math.round(labelLine.line.end.y).toString(),
imageData.fileData.name,
image.width.toString(),
image.height.toString()
] : [];
return labelFields.join(",")
});
return labelLinesString.join("\n");
}
}
8 changes: 4 additions & 4 deletions src/logic/export/PointLabelsExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export class PointLabelsExporter {
const labelName: LabelName = findLast(labelNames, {id: labelPoint.labelId});
const labelFields = !!labelName ? [
labelName.name,
Math.round(labelPoint.point.x) + "",
Math.round(labelPoint.point.y) + "",
Math.round(labelPoint.point.x).toString(),
Math.round(labelPoint.point.y).toString(),
imageData.fileData.name,
image.width + "",
image.height + ""
image.width.toString(),
image.height.toString()
] : [];
return labelFields.join(",")
});
Expand Down
20 changes: 10 additions & 10 deletions src/logic/export/RectLabelsExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ export class RectLabelsExporter {
const labelRectsString: string[] = imageData.labelRects.map((labelRect: LabelRect) => {
const labelFields = [
findIndex(labelNames, {id: labelRect.labelId}).toString(),
((labelRect.rect.x + labelRect.rect.width / 2) / image.width).toFixed(6) + "",
((labelRect.rect.y + labelRect.rect.height / 2) / image.height).toFixed(6) + "",
(labelRect.rect.width / image.width).toFixed(6) + "",
(labelRect.rect.height / image.height).toFixed(6) + ""
((labelRect.rect.x + labelRect.rect.width / 2) / image.width).toFixed(6).toString(),
((labelRect.rect.y + labelRect.rect.height / 2) / image.height).toFixed(6).toString(),
(labelRect.rect.width / image.width).toFixed(6).toString(),
(labelRect.rect.height / image.height).toFixed(6).toString()
];
return labelFields.join(" ")
});
Expand Down Expand Up @@ -179,13 +179,13 @@ export class RectLabelsExporter {
const labelName: LabelName = findLast(labelNames, {id: labelRect.labelId});
const labelFields = !!labelName ? [
labelName.name,
Math.round(labelRect.rect.x) + "",
Math.round(labelRect.rect.y) + "",
Math.round(labelRect.rect.width) + "",
Math.round(labelRect.rect.height) + "",
Math.round(labelRect.rect.x).toString(),
Math.round(labelRect.rect.y).toString(),
Math.round(labelRect.rect.width).toString(),
Math.round(labelRect.rect.height).toString(),
imageData.fileData.name,
image.width + "",
image.height + ""
image.width.toString(),
image.height.toString()
] : [];
return labelFields.join(",")
});
Expand Down
53 changes: 53 additions & 0 deletions src/logic/export/TagLabelsExport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {ExportFormatType} from "../../data/enums/ExportFormatType";
import {LabelsSelector} from "../../store/selectors/LabelsSelector";
import {ImageData, LabelName} from "../../store/labels/types";
import {saveAs} from "file-saver";
import {ExporterUtil} from "../../utils/ExporterUtil";
import {ImageRepository} from "../imageRepository/ImageRepository";
import {findLast} from "lodash";

export class TagLabelsExporter {
public static export(exportFormatType: ExportFormatType): void {
switch (exportFormatType) {
case ExportFormatType.CSV:
TagLabelsExporter.exportAsCSV();
break;
default:
return;
}
}

private static exportAsCSV(): void {
const content: string = LabelsSelector.getImagesData()
.map((imageData: ImageData) => {
return TagLabelsExporter.wrapLineLabelsIntoCSV(imageData)})
.filter((imageLabelData: string) => {
return !!imageLabelData})
.join("\n");

const blob = new Blob([content], {type: "text/plain;charset=utf-8"});
try {
saveAs(blob, `${ExporterUtil.getExportFileName()}.csv`);
} catch (error) {
// TODO
throw new Error(error);
}
}

private static wrapLineLabelsIntoCSV(imageData: ImageData): string {
if (imageData.labelTagId === null || !imageData.loadStatus)
return null;

const image: HTMLImageElement = ImageRepository.getById(imageData.id);
const labelNames: LabelName[] = LabelsSelector.getLabelNames();
const labelName: LabelName = findLast(labelNames, {id: imageData.labelTagId});
const labelFields = !!labelName ? [
labelName.name,
imageData.fileData.name,
image.width.toString(),
image.height.toString()
] : [];
return labelFields.join(",")

}
}
15 changes: 12 additions & 3 deletions src/logic/export/__tests__/PolygonLabelsExporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ describe("PolygonLabelsExporter mapImageDataToVGG method", () => {
labelPoints: [],
labelRects: [],
labelPolygons: [],
labelLines: [],
labelTagId: null,
fileData: {} as File,
isVisitedByObjectDetector: true
isVisitedByObjectDetector: true,
isVisitedByPoseDetector: true
};
expect(PolygonLabelsExporter.mapImageDataToVGG(givenImageData, [])).toBeNull();
});
Expand Down Expand Up @@ -69,8 +72,11 @@ describe("PolygonLabelsExporter mapImageDataToVGG method", () => {
]
}
],
labelLines: [],
labelTags: [],
fileData: {} as File,
isVisitedByObjectDetector: true
isVisitedByObjectDetector: true,
isVisitedByPoseDetector: true
};

const givenLabelNames: LabelName[] = [
Expand Down Expand Up @@ -138,8 +144,11 @@ describe("PolygonLabelsExporter mapImageDataToVGG method", () => {
]
}
],
labelLines: [],
labelTags: [],
fileData: {} as File,
isVisitedByObjectDetector: true
isVisitedByObjectDetector: true,
isVisitedByPoseDetector: true
};

const givenLabelNames: LabelName[] = [
Expand Down
Loading

0 comments on commit 16b06c8

Please sign in to comment.