Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

fix: Correctly save the ymax value on PascalVOC exporter and remove Tensorflow name #763

Merged
merged 1 commit into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/common/localization/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ export const english: IAppStrings = {
tfRecords: {
displayName: "Tensorflow Records",
},
tfPascalVoc: {
displayName: "Tensorflow Pascal VOC",
pascalVoc: {
displayName: "Pascal VOC",
testTrainSplit: {
title: "Test / Train Split",
description: "The test train split to use for exported data",
Expand Down
4 changes: 2 additions & 2 deletions src/common/localization/es-cl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ export const spanish: IAppStrings = {
tfRecords: {
displayName: "Registros de Tensorflow",
},
tfPascalVoc: {
displayName: "Tensorflow Pascal VOC",
pascalVoc: {
displayName: "Pascal VOC",
testTrainSplit: {
title: "Prueba/tren Split",
description: "La división del tren de prueba que se utilizará para los datos exportados",
Expand Down
4 changes: 2 additions & 2 deletions src/common/mockFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,12 @@ export default class MockFactory {

/**
* Creates array of IExportProviderRegistrationOptions for the different providers
* vottJson, tensorFlowPascalVOC, azureCustomVision
* vottJson, pascalVOC, azureCustomVision
*/
public static createExportProviderRegistrations(): IExportProviderRegistrationOptions[] {
const registrations: IExportProviderRegistrationOptions[] = [];
registrations.push(MockFactory.createExportProviderRegistration("vottJson"));
registrations.push(MockFactory.createExportProviderRegistration("tensorFlowPascalVOC"));
registrations.push(MockFactory.createExportProviderRegistration("pascalVOC"));
registrations.push(MockFactory.createExportProviderRegistration("azureCustomVision"));

return registrations;
Expand Down
2 changes: 1 addition & 1 deletion src/common/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export interface IAppStrings {
tfRecords: {
displayName: string,
},
tfPascalVoc: {
pascalVoc: {
displayName: string,
testTrainSplit: {
title: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "object",
"title": "${strings.export.providers.tfPascalVoc.displayName}",
"title": "${strings.export.providers.pascalVoc.displayName}",
"properties": {
"assetState": {
"type": "string",
Expand All @@ -19,14 +19,14 @@
]
},
"testTrainSplit": {
"title": "${strings.export.providers.tfPascalVoc.testTrainSplit.title}",
"description": "${strings.export.providers.tfPascalVoc.testTrainSplit.description}",
"title": "${strings.export.providers.pascalVoc.testTrainSplit.title}",
"description": "${strings.export.providers.pascalVoc.testTrainSplit.description}",
"type": "number",
"default": 80
},
"exportUnassigned": {
"title": "${strings.export.providers.tfPascalVoc.exportUnassigned.title}",
"description": "${strings.export.providers.tfPascalVoc.exportUnassigned.description}",
"title": "${strings.export.providers.pascalVoc.exportUnassigned.title}",
"description": "${strings.export.providers.pascalVoc.exportUnassigned.description}",
"type": "boolean",
"default": true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from "lodash";
import { TFPascalVOCExportProvider, ITFPascalVOCExportProviderOptions } from "./tensorFlowPascalVOC";
import { PascalVOCExportProvider, IPascalVOCExportProviderOptions } from "./pascalVOC";
import { ExportAssetState } from "./exportProvider";
import registerProviders from "../../registerProviders";
import { ExportProviderFactory } from "./exportProviderFactory";
Expand All @@ -21,7 +21,7 @@ import { AssetProviderFactory } from "../storage/assetProviderFactory";

registerMixins();

describe("TFPascalVOC Json Export Provider", () => {
describe("PascalVOC Json Export Provider", () => {
const testAssets = MockFactory.createTestAssets(10, 1);
const baseTestProject = MockFactory.createTestProject("Test Project");
baseTestProject.assets = {
Expand Down Expand Up @@ -51,18 +51,18 @@ describe("TFPascalVOC Json Export Provider", () => {
});

it("Is defined", () => {
expect(TFPascalVOCExportProvider).toBeDefined();
expect(PascalVOCExportProvider).toBeDefined();
});

it("Can be instantiated through the factory", () => {
const options: ITFPascalVOCExportProviderOptions = {
const options: IPascalVOCExportProviderOptions = {
assetState: ExportAssetState.All,
exportUnassigned: true,
testTrainSplit: 80,
};
const exportProvider = ExportProviderFactory.create("tensorFlowPascalVOC", baseTestProject, options);
const exportProvider = ExportProviderFactory.create("pascalVOC", baseTestProject, options);
expect(exportProvider).not.toBeNull();
expect(exportProvider).toBeInstanceOf(TFPascalVOCExportProvider);
expect(exportProvider).toBeInstanceOf(PascalVOCExportProvider);
});

describe("Export variations", () => {
Expand All @@ -87,7 +87,7 @@ describe("TFPascalVOC Json Export Provider", () => {
});

it("Exports all assets", async () => {
const options: ITFPascalVOCExportProviderOptions = {
const options: IPascalVOCExportProviderOptions = {
assetState: ExportAssetState.All,
exportUnassigned: true,
testTrainSplit: 80,
Expand All @@ -96,7 +96,7 @@ describe("TFPascalVOC Json Export Provider", () => {
const testProject = { ...baseTestProject };
testProject.tags = MockFactory.createTestTags(3);

const exportProvider = new TFPascalVOCExportProvider(testProject, options);
const exportProvider = new PascalVOCExportProvider(testProject, options);
await exportProvider.export();

const storageProviderMock = LocalFileSystemProxy as any;
Expand Down Expand Up @@ -145,7 +145,7 @@ describe("TFPascalVOC Json Export Provider", () => {
});

it("Exports only visited assets (includes tagged)", async () => {
const options: ITFPascalVOCExportProviderOptions = {
const options: IPascalVOCExportProviderOptions = {
assetState: ExportAssetState.Visited,
exportUnassigned: true,
testTrainSplit: 80,
Expand All @@ -154,7 +154,7 @@ describe("TFPascalVOC Json Export Provider", () => {
const testProject = { ...baseTestProject };
testProject.tags = MockFactory.createTestTags(1);

const exportProvider = new TFPascalVOCExportProvider(testProject, options);
const exportProvider = new PascalVOCExportProvider(testProject, options);
await exportProvider.export();

const storageProviderMock = LocalFileSystemProxy as any;
Expand Down Expand Up @@ -191,7 +191,7 @@ describe("TFPascalVOC Json Export Provider", () => {
});

it("Exports only tagged assets", async () => {
const options: ITFPascalVOCExportProviderOptions = {
const options: IPascalVOCExportProviderOptions = {
assetState: ExportAssetState.Tagged,
exportUnassigned: true,
testTrainSplit: 80,
Expand All @@ -200,7 +200,7 @@ describe("TFPascalVOC Json Export Provider", () => {
const testProject = { ...baseTestProject };
testProject.tags = MockFactory.createTestTags(3);

const exportProvider = new TFPascalVOCExportProvider(testProject, options);
const exportProvider = new PascalVOCExportProvider(testProject, options);
await exportProvider.export();

const storageProviderMock = LocalFileSystemProxy as any;
Expand Down Expand Up @@ -242,7 +242,7 @@ describe("TFPascalVOC Json Export Provider", () => {
});

it("Export includes unassigned tags", async () => {
const options: ITFPascalVOCExportProviderOptions = {
const options: IPascalVOCExportProviderOptions = {
assetState: ExportAssetState.Tagged,
exportUnassigned: true,
testTrainSplit: 80,
Expand All @@ -254,7 +254,7 @@ describe("TFPascalVOC Json Export Provider", () => {
testProject.assets = _.keyBy(testAssets, (asset) => asset.id);
testProject.tags = MockFactory.createTestTags(3);

const exportProvider = new TFPascalVOCExportProvider(testProject, options);
const exportProvider = new PascalVOCExportProvider(testProject, options);
await exportProvider.export();

const storageProviderMock = LocalFileSystemProxy as any;
Expand All @@ -275,7 +275,7 @@ describe("TFPascalVOC Json Export Provider", () => {
});

it("Export does not include unassigned tags", async () => {
const options: ITFPascalVOCExportProviderOptions = {
const options: IPascalVOCExportProviderOptions = {
assetState: ExportAssetState.Tagged,
exportUnassigned: false,
testTrainSplit: 80,
Expand All @@ -287,7 +287,7 @@ describe("TFPascalVOC Json Export Provider", () => {
testProject.assets = _.keyBy(testAssets, (asset) => asset.id);
testProject.tags = MockFactory.createTestTags(3);

const exportProvider = new TFPascalVOCExportProvider(testProject, options);
const exportProvider = new PascalVOCExportProvider(testProject, options);
await exportProvider.export();

const storageProviderMock = LocalFileSystemProxy as any;
Expand All @@ -309,7 +309,7 @@ describe("TFPascalVOC Json Export Provider", () => {

describe("Annotations", () => {
it("contains expected XML", async () => {
const options: ITFPascalVOCExportProviderOptions = {
const options: IPascalVOCExportProviderOptions = {
assetState: ExportAssetState.Tagged,
exportUnassigned: false,
testTrainSplit: 80,
Expand All @@ -321,7 +321,7 @@ describe("TFPascalVOC Json Export Provider", () => {
testProject.assets = _.keyBy(testAssets, (asset) => asset.id);
testProject.tags = [MockFactory.createTestTag("1")];

const exportProvider = new TFPascalVOCExportProvider(testProject, options);
const exportProvider = new PascalVOCExportProvider(testProject, options);
await exportProvider.export();

const storageProviderMock = LocalFileSystemProxy as any;
Expand All @@ -345,7 +345,7 @@ describe("TFPascalVOC Json Export Provider", () => {

describe("Test Train Splits", () => {
async function testTestTrainSplit(testTrainSplit: number): Promise<void> {
const options: ITFPascalVOCExportProviderOptions = {
const options: IPascalVOCExportProviderOptions = {
assetState: ExportAssetState.Tagged,
exportUnassigned: true,
testTrainSplit,
Expand All @@ -357,7 +357,7 @@ describe("TFPascalVOC Json Export Provider", () => {
testProject.assets = _.keyBy(testAssets, (asset) => asset.id);
testProject.tags = [MockFactory.createTestTag("1")];

const exportProvider = new TFPascalVOCExportProvider(testProject, options);
const exportProvider = new PascalVOCExportProvider(testProject, options);
await exportProvider.export();

const storageProviderMock = LocalFileSystemProxy as any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ExportProvider } from "./exportProvider";
import { IProject, IAssetMetadata, RegionType, ITag, IExportProviderOptions } from "../../models/applicationState";
import Guard from "../../common/guard";
import HtmlFileReader from "../../common/htmlFileReader";
import { itemTemplate, annotationTemplate, objectTemplate } from "./tensorFlowPascalVOC/tensorFlowPascalVOCTemplates";
import { itemTemplate, annotationTemplate, objectTemplate } from "./pascalVOC/pascalVOCTemplates";
import { interpolate } from "../../common/strings";
import { PlatformType } from "../../common/hostProcess";
import os from "os";
Expand All @@ -23,37 +23,37 @@ interface IImageInfo {
}

/**
* Export options for TensorFlow Pascal VOC Export Provider
* Export options for Pascal VOC Export Provider
*/
export interface ITFPascalVOCExportProviderOptions extends IExportProviderOptions {
export interface IPascalVOCExportProviderOptions extends IExportProviderOptions {
/** The test / train split ratio for exporting data */
testTrainSplit?: number;
/** Whether or not to include unassigned tags in exported data */
exportUnassigned?: boolean;
}

/**
* @name - TFPascalVOC Json Export Provider
* @description - Exports a project into a single JSON file that include all configured assets
* @name - PascalVOC Export Provider
* @description - Exports a project into a Pascal VOC
*/
export class TFPascalVOCExportProvider extends ExportProvider<ITFPascalVOCExportProviderOptions> {
export class PascalVOCExportProvider extends ExportProvider<IPascalVOCExportProviderOptions> {
private imagesInfo = new Map<string, IImageInfo>();

constructor(project: IProject, options: ITFPascalVOCExportProviderOptions) {
constructor(project: IProject, options: IPascalVOCExportProviderOptions) {
super(project, options);
Guard.null(options);
}

/**
* Export project to TensorFlow PascalVOC
* Export project to PascalVOC
*/
public async export(): Promise<void> {
const allAssets = await this.getAssetsForExport();
const exportObject: any = { ...this.project };
exportObject.assets = _.keyBy(allAssets, (assetMetadata) => assetMetadata.asset.id);

// Create Export Folder
const exportFolderName = `${this.project.name.replace(" ", "-")}-TFPascalVOC-export`;
const exportFolderName = `${this.project.name.replace(" ", "-")}-PascalVOC-export`;
await this.storageProvider.createContainer(exportFolderName);

await this.exportImages(exportFolderName, allAssets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export const objectTemplate = "\
<xmin>${xmin}</xmin>\n\
<ymin>${ymin}</ymin>\n\
<xmax>${xmax}</xmax>\n\
<ymax>${xmin}</ymax>\n\
<ymax>${ymax}</ymax>\n\
</bndbox>\n\
</object>";
2 changes: 1 addition & 1 deletion src/providers/export/tensorFlowRecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ExportProvider } from "./exportProvider";
import { IProject, IAssetMetadata, IExportProviderOptions } from "../../models/applicationState";
import Guard from "../../common/guard";
import HtmlFileReader from "../../common/htmlFileReader";
import { itemTemplate } from "./tensorFlowPascalVOC/tensorFlowPascalVOCTemplates";
import { itemTemplate } from "./pascalVOC/pascalVOCTemplates";
import { interpolate } from "../../common/strings";
import { TFRecordsBuilder, FeatureType } from "./tensorFlowRecords/tensorFlowBuilder";

Expand Down
8 changes: 4 additions & 4 deletions src/registerProviders.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ExportProviderFactory } from "./providers/export/exportProviderFactory";
import { TFPascalVOCExportProvider } from "./providers/export/tensorFlowPascalVOC";
import { PascalVOCExportProvider } from "./providers/export/pascalVOC";
import { TFRecordsExportProvider } from "./providers/export/tensorFlowRecords";
import { VottJsonExportProvider } from "./providers/export/vottJson";
import { AssetProviderFactory } from "./providers/storage/assetProviderFactory";
Expand Down Expand Up @@ -54,9 +54,9 @@ export default function registerProviders() {
factory: (project, options) => new VottJsonExportProvider(project, options),
});
ExportProviderFactory.register({
name: "tensorFlowPascalVOC",
displayName: strings.export.providers.tfPascalVoc.displayName,
factory: (project, options) => new TFPascalVOCExportProvider(project, options),
name: "pascalVOC",
displayName: strings.export.providers.pascalVoc.displayName,
factory: (project, options) => new PascalVOCExportProvider(project, options),
});
ExportProviderFactory.register({
name: "tensorFlowRecords",
Expand Down