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

Import region metadata from TFRecords #566

Merged
merged 135 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
6da5d99
WIP: Started refactoring canvas based assets
wbreza Feb 4, 2019
758e5f0
Wired up editor page for basic experience
wbreza Feb 5, 2019
7c5fe2c
WIP: Updated canvas to support single child element
wbreza Feb 6, 2019
ae60e84
Making progress
wbreza Feb 6, 2019
fe0112e
Got per frame tagging to work
wbreza Feb 7, 2019
0646987
Load and set child assets
wbreza Feb 7, 2019
e4f32c8
Updated to filter out child assets from displaying in side bar
wbreza Feb 7, 2019
8e38b91
Fixed issue with image regions now redrawing
wbreza Feb 7, 2019
4425c1e
Integrated next/previous tagged frame buttons
wbreza Feb 8, 2019
9f39294
Wabrez/video test coverage (#549)
wbreza Feb 8, 2019
2d663de
Canvas / Editor Page Test Coverage (#552)
wbreza Feb 9, 2019
cd6086e
Fixed issue instantiating canvas tools editor
wbreza Feb 9, 2019
98e260d
Wired up editor page for basic experience
wbreza Feb 5, 2019
29eaa00
WIP: Updated canvas to support single child element
wbreza Feb 6, 2019
752ebb0
Making progress
wbreza Feb 6, 2019
1ef80af
Wabrez/video test coverage (#549)
wbreza Feb 8, 2019
618e9d5
Load and set child assets
wbreza Feb 7, 2019
f2916b5
Update TFRecords functions
JacopoMangiavacchi Feb 6, 2019
c6ae7f2
WIP: Adding TFRecord Asset Preview
JacopoMangiavacchi Feb 6, 2019
059a20e
Loading Image from TFRecord file
JacopoMangiavacchi Feb 6, 2019
1489a10
Adding State to TFRecord asset component
JacopoMangiavacchi Feb 6, 2019
9ec1d23
Fix async read tfrecords attributes
JacopoMangiavacchi Feb 7, 2019
b598cff
Removed image ref on TFRecord asset
JacopoMangiavacchi Feb 7, 2019
2ab3c12
Ripristinated image ref in tfrecord asset
JacopoMangiavacchi Feb 7, 2019
af5c9db
Fix issues on render called before componentWillMount
JacopoMangiavacchi Feb 7, 2019
f92731c
Update state only if asset changes
JacopoMangiavacchi Feb 7, 2019
ebb1112
Moved tfrecordAsset to new folder
JacopoMangiavacchi Feb 8, 2019
3fa009f
WIP: Adding tfrecordAsset unit test
JacopoMangiavacchi Feb 9, 2019
b5cb9cc
Updated tfrecordAsset to last refactor changes
JacopoMangiavacchi Feb 9, 2019
c35bafe
Updated path
JacopoMangiavacchi Feb 9, 2019
83ed23d
Refactored based on last changes and removed duplicates
JacopoMangiavacchi Feb 9, 2019
3fa5e8e
added docs
JacopoMangiavacchi Feb 9, 2019
60e25e3
init state with property and removed constructor
JacopoMangiavacchi Feb 11, 2019
64f498c
Fixed unit test
JacopoMangiavacchi Feb 11, 2019
f627877
Added comments and localization
JacopoMangiavacchi Feb 12, 2019
c0de287
WIP: Started refactoring canvas based assets
wbreza Feb 4, 2019
fc12cbc
Wired up editor page for basic experience
wbreza Feb 5, 2019
967c3c1
WIP: Updated canvas to support single child element
wbreza Feb 6, 2019
7050bdd
Making progress
wbreza Feb 6, 2019
b987561
Got per frame tagging to work
wbreza Feb 7, 2019
6c8c433
Load and set child assets
wbreza Feb 7, 2019
b9495aa
Updated to filter out child assets from displaying in side bar
wbreza Feb 7, 2019
2ef3af3
Fixed issue with image regions now redrawing
wbreza Feb 7, 2019
f1b8d1c
Integrated next/previous tagged frame buttons
wbreza Feb 8, 2019
3de098b
Wabrez/video test coverage (#549)
wbreza Feb 8, 2019
00b01a6
Canvas / Editor Page Test Coverage (#552)
wbreza Feb 9, 2019
632d7dc
Fixed issue instantiating canvas tools editor
wbreza Feb 9, 2019
3d2f2c4
Making progress
wbreza Feb 6, 2019
59b7f6d
WIP: Adding TFRecord Asset Preview
JacopoMangiavacchi Feb 6, 2019
7045580
Wired up editor page for basic experience
wbreza Feb 5, 2019
59b7fc8
WIP: Updated canvas to support single child element
wbreza Feb 6, 2019
76da86c
WIP: Reading Region metadata from TFRecord
JacopoMangiavacchi Feb 8, 2019
70e94b9
Added Features Array capability to TFRecords Reader
JacopoMangiavacchi Feb 8, 2019
0562d60
Creating IRegion array
JacopoMangiavacchi Feb 8, 2019
1670d35
Adding Interface for TFRecord Object arrays
JacopoMangiavacchi Feb 8, 2019
7fad6f4
Fix TFRecord Object Array Interface
JacopoMangiavacchi Feb 9, 2019
5be23e7
Separated function for converting Region from TFRecord
JacopoMangiavacchi Feb 9, 2019
c5c0777
Replaced setTimeout() with setImmediate() in TFRecord asset test
JacopoMangiavacchi Feb 11, 2019
81eff56
Removed HEAD file created in rebase
JacopoMangiavacchi Feb 11, 2019
9b4b18c
Imported Tag name and color
JacopoMangiavacchi Feb 11, 2019
e4d218c
Test import metadata from tfrecord file
JacopoMangiavacchi Feb 11, 2019
ecc1474
Test region transformation
JacopoMangiavacchi Feb 12, 2019
c7d21e7
Fixed region bounding box calculus
JacopoMangiavacchi Feb 12, 2019
84eeb1c
Fixed TFRecords region width/height export
JacopoMangiavacchi Feb 12, 2019
eca3d17
Fixed code duplication in test
JacopoMangiavacchi Feb 12, 2019
305b6fb
Removed duplicated mock
JacopoMangiavacchi Feb 12, 2019
d8ecb2b
Fixed test error
JacopoMangiavacchi Feb 13, 2019
e689bcc
WIP: Started refactoring canvas based assets
wbreza Feb 4, 2019
23a8116
Wired up editor page for basic experience
wbreza Feb 5, 2019
df8449d
WIP: Updated canvas to support single child element
wbreza Feb 6, 2019
96115d3
Making progress
wbreza Feb 6, 2019
bb3c90d
Got per frame tagging to work
wbreza Feb 7, 2019
b351c5c
Load and set child assets
wbreza Feb 7, 2019
f21cd59
Updated to filter out child assets from displaying in side bar
wbreza Feb 7, 2019
f340047
Fixed issue with image regions now redrawing
wbreza Feb 7, 2019
65a178a
Integrated next/previous tagged frame buttons
wbreza Feb 8, 2019
94ca075
Wabrez/video test coverage (#549)
wbreza Feb 8, 2019
a3f4d77
Canvas / Editor Page Test Coverage (#552)
wbreza Feb 9, 2019
9b0cc73
Fixed issue instantiating canvas tools editor
wbreza Feb 9, 2019
f42e442
Wired up editor page for basic experience
wbreza Feb 5, 2019
a2cdc05
WIP: Updated canvas to support single child element
wbreza Feb 6, 2019
782cba6
Making progress
wbreza Feb 6, 2019
936937d
Wabrez/video test coverage (#549)
wbreza Feb 8, 2019
16b92b8
Load and set child assets
wbreza Feb 7, 2019
aca9245
Update TFRecords functions
JacopoMangiavacchi Feb 6, 2019
f260711
Add TFRecord new asset type changes
JacopoMangiavacchi Feb 6, 2019
c2a4228
WIP: Adding TFRecord Asset Preview
JacopoMangiavacchi Feb 6, 2019
c9f852d
Loading Image from TFRecord file
JacopoMangiavacchi Feb 6, 2019
582af88
Adding State to TFRecord asset component
JacopoMangiavacchi Feb 6, 2019
5ccf072
Fix async read tfrecords attributes
JacopoMangiavacchi Feb 7, 2019
ef6d616
Removed image ref on TFRecord asset
JacopoMangiavacchi Feb 7, 2019
46ad910
Ripristinated image ref in tfrecord asset
JacopoMangiavacchi Feb 7, 2019
93688ac
Fix issues on render called before componentWillMount
JacopoMangiavacchi Feb 7, 2019
3746999
Update state only if asset changes
JacopoMangiavacchi Feb 7, 2019
52b609b
Moved tfrecordAsset to new folder
JacopoMangiavacchi Feb 8, 2019
c8b36c0
WIP: Adding tfrecordAsset unit test
JacopoMangiavacchi Feb 9, 2019
ea12c9a
Updated tfrecordAsset to last refactor changes
JacopoMangiavacchi Feb 9, 2019
ec3d7db
Updated path
JacopoMangiavacchi Feb 9, 2019
f6cd9ed
Refactored based on last changes and removed duplicates
JacopoMangiavacchi Feb 9, 2019
d250cc6
added docs
JacopoMangiavacchi Feb 9, 2019
1f621a5
init state with property and removed constructor
JacopoMangiavacchi Feb 11, 2019
b81ee74
Fixed unit test
JacopoMangiavacchi Feb 11, 2019
0352d3e
Removed ~HEAD files created by rebase
JacopoMangiavacchi Feb 11, 2019
7cd3db7
Added comments and localization
JacopoMangiavacchi Feb 12, 2019
8e9dc3e
WIP: Started refactoring canvas based assets
wbreza Feb 4, 2019
fc210c6
Wired up editor page for basic experience
wbreza Feb 5, 2019
fbf8350
WIP: Updated canvas to support single child element
wbreza Feb 6, 2019
ae31eb0
Making progress
wbreza Feb 6, 2019
e8b707d
Got per frame tagging to work
wbreza Feb 7, 2019
27f5510
Load and set child assets
wbreza Feb 7, 2019
3dac0bc
Updated to filter out child assets from displaying in side bar
wbreza Feb 7, 2019
d835351
Fixed issue with image regions now redrawing
wbreza Feb 7, 2019
c5b53df
Integrated next/previous tagged frame buttons
wbreza Feb 8, 2019
0508935
Wabrez/video test coverage (#549)
wbreza Feb 8, 2019
e4bea0d
Canvas / Editor Page Test Coverage (#552)
wbreza Feb 9, 2019
a17156e
Fixed issue instantiating canvas tools editor
wbreza Feb 9, 2019
e719373
Making progress
wbreza Feb 6, 2019
287a40a
WIP: Adding TFRecord Asset Preview
JacopoMangiavacchi Feb 6, 2019
6b41557
Wired up editor page for basic experience
wbreza Feb 5, 2019
75f1235
WIP: Updated canvas to support single child element
wbreza Feb 6, 2019
160b1bf
WIP: Reading Region metadata from TFRecord
JacopoMangiavacchi Feb 8, 2019
533f54a
Creating IRegion array
JacopoMangiavacchi Feb 8, 2019
60a9fb6
Fix TFRecord Object Array Interface
JacopoMangiavacchi Feb 9, 2019
6b0360a
Replaced setTimeout() with setImmediate() in TFRecord asset test
JacopoMangiavacchi Feb 11, 2019
c3a38e1
Removed HEAD file created in rebase
JacopoMangiavacchi Feb 11, 2019
16c3c0a
Fixed code duplication in test
JacopoMangiavacchi Feb 12, 2019
1887dd5
Resolved some PR feedback
JacopoMangiavacchi Feb 13, 2019
a1f1910
Fixed import regions test
JacopoMangiavacchi Feb 13, 2019
e859c1f
temporary comment some code
JacopoMangiavacchi Feb 13, 2019
ca74465
Removed comments from previous commit
JacopoMangiavacchi Feb 13, 2019
22f26b7
Moved ITFRecordMetadata interface to applicationState
JacopoMangiavacchi Feb 13, 2019
6e8ae57
Fixed SonarCloud issue
JacopoMangiavacchi Feb 13, 2019
ea0fe3c
Removed duplicated test
JacopoMangiavacchi Feb 13, 2019
66b79a9
Removed empty prop interfaces
JacopoMangiavacchi Feb 13, 2019
0ea43d0
Addressed feedback from PR
JacopoMangiavacchi Feb 14, 2019
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
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 40 additions & 17 deletions src/common/htmlFileReader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ describe("Html File Reader", () => {
});

describe("Download asset binaries array", () => {
it("Downloads a byte array from the asset path", async () => {
const asset = AssetService.createAssetFromFilePath("https://server.com/image.jpg");
beforeEach(() => {
axios.get = jest.fn((url, config) => {
return Promise.resolve<AxiosResponse>({
config,
Expand All @@ -122,35 +121,59 @@ describe("Html File Reader", () => {
data: [1, 2, 3],
});
});
});

it("Downloads a byte array from the asset path", async () => {
const asset = AssetService.createAssetFromFilePath("https://server.com/image.jpg");
const result = await HtmlFileReader.getAssetArray(asset);
expect(result).not.toBeNull();
expect(result).toBeInstanceOf(Uint8Array);
expect(axios.get).toBeCalledWith(asset.path, { responseType: "blob" });
});

it("Test non valid asset type", async () => {
const imageAsset = AssetService.createAssetFromFilePath("https://server.com/image.notsupported");
try {
const result = await HtmlFileReader.readAssetAttributes(imageAsset);
} catch (error) {
expect(error).toEqual(new Error("Asset not supported"));
}
});
});

it("Test non valid asset type", async () => {
axios.get = jest.fn((url, config) => {
return Promise.resolve<AxiosResponse>({
config,
headers: null,
status: 200,
statusText: "OK",
data: [1, 2, 3],
describe("Test TFRecords", () => {
it("Loads attributes for a tfrecord asset", async () => {
const expected = {
width: 1920,
height: 1080,
};

axios.get = jest.fn((url, config) => {
const builder = new TFRecordsBuilder();
builder.addFeature("image/height", FeatureType.Int64, expected.height);
builder.addFeature("image/width", FeatureType.Int64, expected.width);
const buffer = builder.build();
const tfrecords = TFRecordsBuilder.buildTFRecords([buffer]);

return Promise.resolve<AxiosResponse>({
config,
headers: null,
status: 200,
statusText: "OK",
data: tfrecords,
});
});
});

const imageAsset = AssetService.createAssetFromFilePath("https://server.com/image.notsupported");
try {
const imageAsset = AssetService.createAssetFromFilePath("https://server.com/image.tfrecord");
const result = await HtmlFileReader.readAssetAttributes(imageAsset);
} catch (error) {
expect(error).toEqual(new Error("Asset not supported"));
}

expect(result.width).toEqual(expected.width);
expect(result.height).toEqual(expected.height);
});
});

describe("Test TFRecords", () => {
it("Loads attributes for a tfrecord asset", async () => {
it("Loads attributes for an tfrecord asset", async () => {
const expected = {
width: 1920,
height: 1080,
Expand Down
7 changes: 5 additions & 2 deletions src/common/mockFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,21 @@ export default class MockFactory {
* Creates fake IAsset
* @param name Name of asset
* @param assetState State of asset
* @param path Path of asset
* @param assetType Type of asset
*/
public static createTestAsset(
name: string,
assetState: AssetState = AssetState.NotVisited,
path: string = `C:\\Desktop\\asset${name}.jpg`): IAsset {
path: string = `C:\\Desktop\\asset${name}.jpg`,
assetType: AssetType = AssetType.Image): IAsset {
return {
id: `asset-${name}`,
format: "jpg",
name: `Asset ${name}.jpg`,
path: `${path}`,
state: assetState,
type: AssetType.Image,
type: assetType,
size: {
width: 800,
height: 600,
Expand Down
10 changes: 10 additions & 0 deletions src/models/applicationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,13 @@ export interface ISecurityToken {
name: string;
key: string;
}

export interface ITFRecordMetadata {
width: number;
height: number;
xminArray: number[];
yminArray: number[];
xmaxArray: number[];
ymaxArray: number[];
textArray: string[];
}
10 changes: 6 additions & 4 deletions src/providers/export/tensorFlowRecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ export class TFRecordsJsonExportProvider extends ExportProvider<ITFRecordsJsonEx

imageInfo.text.push(tag.name);
imageInfo.label.push(index);
imageInfo.xmin.push(region.boundingBox.left);
imageInfo.ymin.push(region.boundingBox.top);
imageInfo.xmax.push(region.boundingBox.left + region.boundingBox.width);
imageInfo.ymax.push(region.boundingBox.top + region.boundingBox.height);
imageInfo.xmin.push(region.boundingBox.left / imageInfo.width);
imageInfo.ymin.push(region.boundingBox.top / imageInfo.height);
imageInfo.xmax.push((region.boundingBox.left + region.boundingBox.width)
/ imageInfo.width);
imageInfo.ymax.push((region.boundingBox.top + region.boundingBox.height)
/ imageInfo.height);
imageInfo.difficult.push(0);
imageInfo.truncated.push(0);
imageInfo.view.push("Unspecified");
Expand Down
30 changes: 30 additions & 0 deletions src/providers/export/tensorFlowRecords/tensorFlowReader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,35 @@ describe("TFRecords Reader/Builder Integration test", () => {
expect(floatValue).toEqual(12345.0);
expect(binaryValue).toEqual(new Uint8Array([1, 2, 3, 4, 5]));
});

it("Check feature array value on a single TFRecord", async () => {
builder.addArrayFeature("feature/1", FeatureType.Int64, [1, 2]);
builder.addArrayFeature("feature/2", FeatureType.Float, [1.0, 2.0]);
builder.addArrayFeature("feature/3", FeatureType.String, ["1", "2"]);
builder.addArrayFeature("feature/4", FeatureType.Binary, [new Uint8Array([1]), new Uint8Array([2])]);

const buffer = builder.build();
const tfrecords = TFRecordsBuilder.buildTFRecords([buffer]);

const reader = new TFRecordsReader(tfrecords);
const intValueArray = reader.getArrayFeature(0, "feature/1", FeatureType.Int64) as number[];
const floatValueArray = reader.getArrayFeature(0, "feature/2", FeatureType.Float) as number[];
const stringValueArray = reader.getArrayFeature(0, "feature/3", FeatureType.String) as string[];
const binaryValueArray = reader.getArrayFeature(0, "feature/4", FeatureType.Binary) as Uint8Array[];

expect(intValueArray.length).toEqual(2);
expect(stringValueArray.length).toEqual(2);
expect(floatValueArray.length).toEqual(2);
expect(binaryValueArray.length).toEqual(2);

expect(intValueArray[0]).toEqual(1);
expect(intValueArray[1]).toEqual(2);
expect(floatValueArray[0]).toEqual(1.0);
expect(floatValueArray[1]).toEqual(2.0);
expect(stringValueArray[0]).toEqual("1");
expect(stringValueArray[1]).toEqual("2");
expect(binaryValueArray[0]).toEqual(new Uint8Array([1]));
expect(binaryValueArray[1]).toEqual(new Uint8Array([2]));
});
});
});
24 changes: 23 additions & 1 deletion src/providers/export/tensorFlowRecords/tensorFlowReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class TFRecordsReader {
/**
* @recordPos - Record Position
* @key - Feature Key
* @type - Feature Typeq
* @type - Feature Type
* @description - Get a Int64 | Float | String | Binary value
*/
public getFeature(recordPos: number, key: string, type: FeatureType): string | number | Uint8Array {
Expand All @@ -85,4 +85,26 @@ export class TFRecordsReader {
return feature.getFloatList().array[0][0];
}
}

/**
* @recordPos - Record Position
* @key - Feature Key
* @type - Feature Type
* @description - Get an array of Int64 | Float | String | Binary value
*/
public getArrayFeature(recordPos: number, key: string, type: FeatureType): string[] | number[] | Uint8Array[] {
const message = this.imageMessages[recordPos];
const feature = message.getContext().getFeatureMap().get(key);

switch (type) {
case FeatureType.String:
return feature.getBytesList().array[0].map((buffer) => textDecode(buffer));
case FeatureType.Binary:
return feature.getBytesList().array[0];
case FeatureType.Int64:
return feature.getInt64List().array[0];
case FeatureType.Float:
return feature.getFloatList().array[0];
}
}
}
8 changes: 1 addition & 7 deletions src/react/components/common/assetPreview/imageAsset.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import React from "react";
import { IAssetProps } from "./assetPreview";

/**
* ImageAsset component properites
*/
export interface IImageProps extends IAssetProps, React.ClassAttributes<ImageAsset> {
}

/**
* ImageAsset component used to render all image assets
*/
export class ImageAsset extends React.Component<IImageProps> {
export class ImageAsset extends React.Component<IAssetProps> {
private image: React.RefObject<HTMLImageElement> = React.createRef();

public render() {
Expand Down
Loading