set max bounding boxes of objects to be detected
This commit is contained in:
parent
952d00df45
commit
2dce1407b0
|
@ -97,6 +97,7 @@ export default function MLFileDebugView(props: MLFileDebugViewProps) {
|
|||
|
||||
const objectDetections = await ssdMobileNetV2Service.detectObjects(
|
||||
imageBitmap,
|
||||
DEFAULT_ML_SYNC_CONFIG.objectDetection.maxNumBoxes,
|
||||
DEFAULT_ML_SYNC_CONFIG.objectDetection.minScore
|
||||
);
|
||||
console.log('detectedObjects: ', objectDetections);
|
||||
|
|
|
@ -45,6 +45,7 @@ export const DEFAULT_ML_SYNC_CONFIG: MLSyncConfig = {
|
|||
},
|
||||
objectDetection: {
|
||||
method: 'SSDMobileNetV2',
|
||||
maxNumBoxes: 20,
|
||||
minScore: 0.2,
|
||||
},
|
||||
textDetection: {
|
||||
|
|
|
@ -42,6 +42,7 @@ class ObjectService {
|
|||
const objectDetections =
|
||||
await syncContext.objectDetectionService.detectObjects(
|
||||
imageBitmap,
|
||||
syncContext.config.objectDetection.maxNumBoxes,
|
||||
syncContext.config.objectDetection.minScore
|
||||
);
|
||||
// console.log('3 TF Memory stats: ', tf.memory());
|
||||
|
|
|
@ -42,13 +42,14 @@ class SSDMobileNetV2 implements ObjectDetectionService {
|
|||
|
||||
public async detectObjects(
|
||||
image: ImageBitmap,
|
||||
minScore?: number
|
||||
maxNumberBoxes: number,
|
||||
minScore: number
|
||||
): Promise<ObjectDetection[]> {
|
||||
const ssdMobileNetV2Model = await this.getSSDMobileNetV2Model();
|
||||
const tfImage = tf.browser.fromPixels(image);
|
||||
const detections = await ssdMobileNetV2Model.detect(
|
||||
tfImage,
|
||||
undefined,
|
||||
maxNumberBoxes,
|
||||
minScore
|
||||
);
|
||||
return detections;
|
||||
|
|
|
@ -246,6 +246,7 @@ export interface FaceDetectionConfig {
|
|||
|
||||
export interface ObjectDetectionConfig {
|
||||
method: ObjectDetectionMethod;
|
||||
maxNumBoxes: number;
|
||||
minScore: number;
|
||||
}
|
||||
|
||||
|
@ -386,7 +387,8 @@ export interface ObjectDetectionService {
|
|||
// init(): Promise<void>;
|
||||
detectObjects(
|
||||
image: ImageBitmap,
|
||||
minScore?: number
|
||||
maxNumBoxes: number,
|
||||
minScore: number
|
||||
): Promise<ObjectDetection[]>;
|
||||
dispose(): Promise<void>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue