atoopub commited on
Commit
3709eff
·
verified ·
1 Parent(s): b77946e

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +5 -5
index.js CHANGED
@@ -25,7 +25,7 @@ app.use(async (ctx) => {
25
  .ensureAlpha()
26
  .raw()
27
  .toBuffer({ resolveWithObject: true })
28
- const image_phash = await phash(image_buffer)
29
  const colors = await extractColors(
30
  { data: image_raw, width: info.width, height: info.height },
31
  {
@@ -52,10 +52,10 @@ app.use(async (ctx) => {
52
  })
53
  .gif({ dither: 0 })
54
  .toBuffer()
55
- // const model = await nsfw.load(`https://raw.githubusercontent.com/infinitered/nsfwjs/refs/heads/master/models/mobilenet_v2_mid/model.json`, { type: 'graph' })
56
  // // const model = await nsfw.load(`https://raw.githubusercontent.com/infinitered/nsfwjs/refs/heads/master/models/mobilenet_v2/model.json`)
57
  // // const model = await nsfw.load(`https://s3.amazonaws.com/ir_public/nsfwjscdn/TFJS_nsfw_mobilenet/tfjs_quant_nsfw_mobilenet/model.json`)
58
- // const model = await nsfw.load(`https://raw.githubusercontent.com/infinitered/nsfwjs/refs/heads/master/models/inception_v3/model.json`, { size: 299 })
59
  const predictions = await model.classifyGif(image_resize, { fps: 1 })
60
  const detail = new Map()
61
  predictions
@@ -67,11 +67,11 @@ app.use(async (ctx) => {
67
  Math.floor(i.probability * 100),
68
  )
69
  })
70
- const fail = ['hentai', 'porn', 'sexy']
71
  const result = [...detail]
72
  .filter((i) => i.pop() > 7)
73
  .some((i) => fail.includes(i.pop()))
74
- tf.dispose()
75
  model.model.dispose()
76
  ctx.body = {
77
  nsfw: Object.assign({ result }, Object.fromEntries(detail)),
 
25
  .ensureAlpha()
26
  .raw()
27
  .toBuffer({ resolveWithObject: true })
28
+ const image_phash = await phash(image_buffer)
29
  const colors = await extractColors(
30
  { data: image_raw, width: info.width, height: info.height },
31
  {
 
52
  })
53
  .gif({ dither: 0 })
54
  .toBuffer()
55
+ // const model = await nsfw.load(`https://raw.githubusercontent.com/infinitered/nsfwjs/refs/heads/master/models/mobilenet_v2_mid/model.json`, { type: 'graph' })
56
  // // const model = await nsfw.load(`https://raw.githubusercontent.com/infinitered/nsfwjs/refs/heads/master/models/mobilenet_v2/model.json`)
57
  // // const model = await nsfw.load(`https://s3.amazonaws.com/ir_public/nsfwjscdn/TFJS_nsfw_mobilenet/tfjs_quant_nsfw_mobilenet/model.json`)
58
+ const model = await nsfw.load(`https://raw.githubusercontent.com/infinitered/nsfwjs/refs/heads/master/models/inception_v3/model.json`, { size: 299 })
59
  const predictions = await model.classifyGif(image_resize, { fps: 1 })
60
  const detail = new Map()
61
  predictions
 
67
  Math.floor(i.probability * 100),
68
  )
69
  })
70
+ const fail = ['hentai', 'porn', 'sexy']
71
  const result = [...detail]
72
  .filter((i) => i.pop() > 7)
73
  .some((i) => fail.includes(i.pop()))
74
+ tf.dispose()
75
  model.model.dispose()
76
  ctx.body = {
77
  nsfw: Object.assign({ result }, Object.fromEntries(detail)),