add breath time in object detection
This commit is contained in:
parent
583f35a32f
commit
57200cc0c8
|
@ -7,6 +7,7 @@ import {
|
|||
Versioned,
|
||||
} from 'types/machineLearning';
|
||||
import { SCENE_DETECTION_IMAGE_SIZE } from 'constants/machineLearning/config';
|
||||
import { sleep } from 'utils/common';
|
||||
|
||||
class ImageScene implements SceneDetectionService {
|
||||
method: Versioned<SceneDetectionMethod>;
|
||||
|
@ -53,6 +54,7 @@ class ImageScene implements SceneDetectionService {
|
|||
}
|
||||
|
||||
async detectScenes(image: ImageBitmap, minScore: number) {
|
||||
await sleep(500);
|
||||
await tf.ready();
|
||||
|
||||
const model = await this.getImageSceneModel();
|
||||
|
@ -71,7 +73,6 @@ class ImageScene implements SceneDetectionService {
|
|||
resizedTensor = tf.cast(resizedTensor, 'float32');
|
||||
|
||||
const output = model.predict(resizedTensor) as tf.Tensor;
|
||||
|
||||
return output;
|
||||
});
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import {
|
|||
} from 'types/machineLearning';
|
||||
|
||||
import * as SSDMobileNet from '@tensorflow-models/coco-ssd';
|
||||
import { sleep } from 'utils/common';
|
||||
|
||||
class SSDMobileNetV2 implements ObjectDetectionService {
|
||||
private ssdMobileNetV2Model: SSDMobileNet.ObjectDetection;
|
||||
|
@ -41,6 +42,7 @@ class SSDMobileNetV2 implements ObjectDetectionService {
|
|||
maxNumberBoxes: number,
|
||||
minScore: number
|
||||
): Promise<ObjectDetection[]> {
|
||||
await sleep(500);
|
||||
const ssdMobileNetV2Model = await this.getSSDMobileNetV2Model();
|
||||
const tfImage = tf.browser.fromPixels(image);
|
||||
const detections = await ssdMobileNetV2Model.detect(
|
||||
|
|
Loading…
Reference in a new issue