[INJIMOB-2125]: Bundle face model as asset of the app (#1651)

* [INJIMOB-2125]: bundle face model as asset to the app

Signed-off-by: adityankannan-tw <adityan410pm@gmail.com>

* [INJIMOB-2125]: bundle face model as asset to the app

Signed-off-by: adityankannan-tw <adityan410pm@gmail.com>

* [INJIMOB-2125]: bundle face model as asset to the app

Signed-off-by: adityankannan-tw <adityan410pm@gmail.com>

---------

Signed-off-by: adityankannan-tw <adityan410pm@gmail.com>
Co-authored-by: adityankannan-tw <adityan410pm@gmail.com>
This commit is contained in:
adityankannan-tw
2024-10-18 15:11:55 +05:30
committed by GitHub
parent 3b6e3c047e
commit aff5c169b2
7 changed files with 51 additions and 44 deletions

View File

@@ -282,49 +282,25 @@ export default async function getAllConfigurations(
return await CACHED_API.getAllProperties(isCachePreferred);
}
export async function downloadModel() {
try {
console.log('restart Face model init');
const injiProp = await getAllConfigurations();
const maxRetryStr = injiProp.modelDownloadMaxRetry;
const maxRetry = parseInt(maxRetryStr);
const resp: string = injiProp != null ? injiProp.faceSdkModelUrl : null;
if (resp != null) {
for (let counter = 0; counter < maxRetry; counter++) {
const config = faceMatchConfig(resp);
const result = await configure(config);
console.log('model download result is = ' + result);
if (result) {
sendImpressionEvent(
getImpressionEventData(
TelemetryConstants.FlowType.faceModelInit,
TelemetryConstants.Screens.home,
{status: TelemetryConstants.EndEventStatus.success},
),
);
break;
} else if (!result && counter === maxRetry - 1) {
sendErrorEvent(
getErrorEventData(
TelemetryConstants.FlowType.faceModelInit,
TelemetryConstants.ErrorId.failure,
TelemetryConstants.ErrorMessage.faceModelInitFailed,
),
);
}
}
}
} catch (error) {
export async function initializeFaceModel() {
const config = faceMatchConfig();
const result = await configure(config);
if (result) {
sendImpressionEvent(
getImpressionEventData(
TelemetryConstants.FlowType.faceModelInit,
TelemetryConstants.Screens.home,
{status: TelemetryConstants.EndEventStatus.success},
),
);
} else {
sendErrorEvent(
getErrorEventData(
TelemetryConstants.FlowType.faceModelInit,
TelemetryConstants.ErrorId.failure,
TelemetryConstants.ErrorMessage.faceModelInitFailed,
error,
),
);
console.error('Error while downloading face model - ', error);
}
}