update

This commit is contained in:
landaiqing
2024-10-03 02:08:19 +08:00
parent af1f57018b
commit c5b1207f89
11 changed files with 40 additions and 19 deletions

View File

@@ -35,9 +35,7 @@ const {onAuthRequired, onResponseRefreshToken} = createServerTokenAuthentication
} else {
message.error(i18n.global.t('error.loginExpired'));
localStorage.removeItem('user');
setTimeout(() => {
window.location.href = '/login';
}, 2000);
window.location.href = '/login';
}
}
}

View File

@@ -9,7 +9,10 @@ let isInit: boolean = false;
const initNSFWJs = async (): Promise<NSFWJS> => {
tf.enableProdMode();
if (!isInit) {
const initialLoad = await nsfwjs.load("/nsfw/model/mobilenet_v2_mid/model.json", {size: 224, type: "graph"});
const initialLoad: nsfwjs.NSFWJS = await nsfwjs.load("/nsfw/model/mobilenet_v2_mid/", {
size: 224,
type: "graph"
});
await initialLoad.model.save("indexeddb://nsfwjs-model");
isInit = true;
}
@@ -22,7 +25,6 @@ const initNSFWJs = async (): Promise<NSFWJS> => {
*/
const predictNSFW = async (model: NSFWJS, image: tf.Tensor3D | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement): Promise<boolean> => {
const predictions = await model.classify(image, 5);
console.log(predictions);
// 定义阈值与对应的类别
const thresholds = {
'Porn': 0.5,