mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
added is-nsfw
util
This commit is contained in:
parent
b3e712cab7
commit
578212882d
23
packages/server/src/utils/is-nsfw/index.js
Normal file
23
packages/server/src/utils/is-nsfw/index.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
const minumunPredictions = {
|
||||||
|
"Drawing": 0.8,
|
||||||
|
"Hentai": 0.8,
|
||||||
|
"Porn": 0.7,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (predictions) => {
|
||||||
|
if (!Array.isArray(predictions)) {
|
||||||
|
throw new Error("predictions must be an array")
|
||||||
|
}
|
||||||
|
|
||||||
|
let isNsfw = false
|
||||||
|
|
||||||
|
Object.keys(minumunPredictions).forEach((key) => {
|
||||||
|
const prediction = predictions.find((prediction) => prediction.className === key)
|
||||||
|
|
||||||
|
if (prediction && prediction.probability >= minumunPredictions[key]) {
|
||||||
|
isNsfw = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return isNsfw
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user