-
-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from SkalskiP/develop
1.10.0-alpha relese
- Loading branch information
Showing
55 changed files
with
1,439 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
# INTELIIJ | ||
|
||
# ide | ||
.idea/ | ||
|
||
# CREATE REACT APP | ||
.vscode/ | ||
|
||
# dependencies | ||
/node_modules/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +0,0 @@ | ||
import '@tensorflow/tfjs-backend-cpu'; | ||
import * as cocoSsd from '@tensorflow-models/coco-ssd'; | ||
import {DetectedObject, ObjectDetection} from '@tensorflow-models/coco-ssd'; | ||
import {store} from '../index'; | ||
import {updateObjectDetectorStatus} from '../store/ai/actionCreators'; | ||
import {LabelType} from '../data/enums/LabelType'; | ||
import {LabelsSelector} from '../store/selectors/LabelsSelector'; | ||
import {AIObjectDetectionActions} from '../logic/actions/AIObjectDetectionActions'; | ||
import {updateActiveLabelType} from '../store/labels/actionCreators'; | ||
|
||
export class ObjectDetector { | ||
private static model: ObjectDetection; | ||
|
||
public static loadModel(callback?: () => unknown) { | ||
cocoSsd | ||
.load() | ||
.then((model: ObjectDetection) => { | ||
ObjectDetector.model = model; | ||
store.dispatch(updateObjectDetectorStatus(true)); | ||
store.dispatch(updateActiveLabelType(LabelType.RECT)); | ||
const activeLabelType: LabelType = LabelsSelector.getActiveLabelType(); | ||
if (activeLabelType === LabelType.RECT) { | ||
AIObjectDetectionActions.detectRectsForActiveImage(); | ||
} | ||
if (callback) { | ||
callback(); | ||
} | ||
}) | ||
.catch((error) => { | ||
// TODO | ||
throw new Error(error as string); | ||
}) | ||
} | ||
|
||
public static predict(image: HTMLImageElement, callback?: (predictions: DetectedObject[]) => unknown) { | ||
if (!ObjectDetector.model) return; | ||
|
||
ObjectDetector.model | ||
.detect(image) | ||
.then((predictions: DetectedObject[]) => { | ||
if (callback) { | ||
callback(predictions) | ||
} | ||
}) | ||
.catch((error) => { | ||
// TODO | ||
throw new Error(error as string); | ||
}) | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.