mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Add back eyes command
This commit is contained in:
@@ -4,6 +4,9 @@ const { Collection } = require('@discordjs/collection');
|
||||
const winston = require('winston');
|
||||
const fontFinder = require('font-finder');
|
||||
const nsfw = require('nsfwjs');
|
||||
const tfnode = require('@tensorflow/tfjs-node');
|
||||
const faceDetection = require('@tensorflow-models/face-detection');
|
||||
const model = faceDetection.SupportedModels.MediaPipeFaceDetector;
|
||||
const moment = require('moment-timezone');
|
||||
const fs = require('fs');
|
||||
const url = require('url');
|
||||
@@ -38,6 +41,7 @@ module.exports = class XiaoClient extends CommandClient {
|
||||
this.activities = activities;
|
||||
this.adultSiteList = null;
|
||||
this.nsfwModel = null;
|
||||
this.faceDetector = null;
|
||||
}
|
||||
|
||||
async loadParseDomain() {
|
||||
@@ -82,6 +86,22 @@ module.exports = class XiaoClient extends CommandClient {
|
||||
return this.nsfwModel;
|
||||
}
|
||||
|
||||
async loadFaceDetector() {
|
||||
this.faceDetector = await faceDetection.createDetector(model, { runtime: 'tfjs', maxFaces: 10 });
|
||||
return this.faceDetector;
|
||||
}
|
||||
|
||||
async detectFaces(imgData) {
|
||||
if (Buffer.byteLength(imgData) >= 4e+6) return 'size';
|
||||
tfnode.setBackend('tensorflow');
|
||||
const image = tfnode.node.decodeImage(imgData);
|
||||
tfnode.setBackend('cpu');
|
||||
const faces = await this.faceDetector.estimateFaces(image);
|
||||
tfnode.setBackend('tensorflow');
|
||||
if (!faces || !faces.length) return null;
|
||||
return faces;
|
||||
}
|
||||
|
||||
fetchReportChannel() {
|
||||
if (!REPORT_CHANNEL_ID) return null;
|
||||
return this.channels.fetch(REPORT_CHANNEL_ID);
|
||||
|
||||
Reference in New Issue
Block a user