shepherd-plugin-nsfw
Advanced tools
Comparing version 0.1.15 to 0.2.0
@@ -56,3 +56,2 @@ "use strict"; | ||
} | ||
exports.NsfwTools = NsfwTools; | ||
_a = NsfwTools; | ||
@@ -77,3 +76,2 @@ NsfwTools._isLoading = false; | ||
}); | ||
let score = {}; | ||
for (const frame of framePredictions) { | ||
@@ -84,26 +82,7 @@ const class1 = frame[0].className; | ||
result.top_score_value = prob1; | ||
if (class1 === 'Hentai') { | ||
if (prob1 >= 0.9) { | ||
(0, logger_1.logger)(prefix, 'hentai gif detected', txid); | ||
result.flagged = true; | ||
break; | ||
} | ||
(0, logger_1.logger)(prefix, 'hentai < 0.9', txid); | ||
if (['Hentai', 'Porn', 'Sexy'].includes(class1) && prob1 >= 0.9) { | ||
(0, logger_1.logger)(prefix, `${class1} gif detected`, txid); | ||
result.flagged = true; | ||
break; | ||
} | ||
if (class1 === 'Porn') { | ||
if (prob1 >= 0.9) { | ||
(0, logger_1.logger)(prefix, 'porn gif detected', txid); | ||
result.flagged = true; | ||
break; | ||
} | ||
(0, logger_1.logger)(prefix, 'porn < 0.9', txid); | ||
} | ||
if (class1 === 'Sexy') { | ||
if (prob1 >= 0.9) { | ||
(0, logger_1.logger)(prefix, 'sexy gif detected', txid); | ||
result.flagged = true; | ||
break; | ||
} | ||
(0, logger_1.logger)(prefix, 'sexy < 0.9', txid); | ||
} | ||
} | ||
@@ -113,2 +92,6 @@ if (process.env.NODE_ENV === 'test' && !result.flagged) { | ||
} | ||
if (['Neutral', 'Drawing'].includes(result.top_score_name)) { | ||
result.top_score_name = undefined; | ||
result.top_score_value = undefined; | ||
} | ||
return result; | ||
@@ -148,16 +131,14 @@ } | ||
const predictions = await NsfwTools.checkSingleImage(pic); | ||
let scores = { 'Drawing': 0, 'Hentai': 0, 'Neutral': 0, 'Porn': 0, 'Sexy': 0 }; | ||
for (const prediction of predictions) { | ||
scores[prediction.className] = prediction.probability; | ||
} | ||
const topName = predictions[0].className; | ||
const flagged = (topName === 'Sexy' || topName === 'Porn' || topName === 'Hentai') && predictions[0].probability >= 0.9; | ||
const topValue = predictions[0].probability; | ||
const flagged = (['Sexy', 'Porn', 'Hentai'].includes(topName)) && topValue >= 0.9; | ||
if (flagged) { | ||
(0, logger_1.logger)(prefix, txid, flagged, JSON.stringify(scores)); | ||
(0, logger_1.logger)(prefix, JSON.stringify({ txid, flagged, topName, topValue })); | ||
} | ||
return { | ||
flagged, | ||
scores: JSON.stringify(scores), | ||
top_score_name: predictions[0].className, | ||
top_score_value: predictions[0].probability, | ||
...(['Porn', 'Sexy', 'Hentai'].includes(topName) && { | ||
top_score_name: topName, | ||
top_score_value: topValue, | ||
}) | ||
}; | ||
@@ -224,1 +205,2 @@ } | ||
}; | ||
exports.NsfwTools = NsfwTools; |
{ | ||
"name": "shepherd-plugin-nsfw", | ||
"version": "0.1.15", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -11,3 +11,3 @@ "main": "./build/index.js", | ||
"test:grep": "mocha -r ts-node/register **/*.spec.ts --grep", | ||
"test": "mocha -r ts-node/register **/*.spec.ts" | ||
"test": "npm run build && mocha -r ts-node/register **/*.spec.ts" | ||
}, | ||
@@ -32,9 +32,9 @@ "repository": { | ||
"@types/mocha": "^10.0.0", | ||
"@types/node": "^18.11.5", | ||
"@types/node": "^18.16.1", | ||
"@types/sinon": "^10.0.10", | ||
"chai": "^4.3.6", | ||
"mocha": "^10.1.0", | ||
"sinon": "^14.0.1", | ||
"sinon": "^15.0.1", | ||
"ts-node": "^10.2.1", | ||
"typescript": "^4.5.5" | ||
"typescript": "^5.0.4" | ||
}, | ||
@@ -44,3 +44,3 @@ "dependencies": { | ||
"ansi-colors": "^4.1.1", | ||
"nsfwjs": "^2.4.1", | ||
"nsfwjs": "^2.4.2", | ||
"shepherd-plugin-interfaces": "^0.3.0", | ||
@@ -47,0 +47,0 @@ "systeminformation": "^5.11.1" |
22588980
241
Updatednsfwjs@^2.4.2