face-api/src/tinyYolov2/TinyYolov2Options.ts

30 lines
913 B
TypeScript
Raw Normal View History

2020-08-18 13:54:53 +02:00
export interface ITinyYolov2Options {
inputSize?: number
scoreThreshold?: number
}
export class TinyYolov2Options {
protected _name: string = 'TinyYolov2Options'
private _inputSize: number
2020-12-23 17:26:55 +01:00
2020-08-18 13:54:53 +02:00
private _scoreThreshold: number
constructor({ inputSize, scoreThreshold }: ITinyYolov2Options = {}) {
2020-12-23 17:26:55 +01:00
this._inputSize = inputSize || 416;
this._scoreThreshold = scoreThreshold || 0.5;
2020-08-18 13:54:53 +02:00
if (typeof this._inputSize !== 'number' || this._inputSize % 32 !== 0) {
2020-12-23 17:26:55 +01:00
throw new Error(`${this._name} - expected inputSize to be a number divisible by 32`);
2020-08-18 13:54:53 +02:00
}
if (typeof this._scoreThreshold !== 'number' || this._scoreThreshold <= 0 || this._scoreThreshold >= 1) {
2020-12-23 17:26:55 +01:00
throw new Error(`${this._name} - expected scoreThreshold to be a number between 0 and 1`);
2020-08-18 13:54:53 +02:00
}
}
2020-12-23 17:26:55 +01:00
get inputSize(): number { return this._inputSize; }
get scoreThreshold(): number { return this._scoreThreshold; }
}