Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -16,6 +16,7 @@ const app = express()
|
|
| 16 |
app.set('json spaces', 4)
|
| 17 |
app.use(morgan('dev'))
|
| 18 |
app.use(express.json())
|
|
|
|
| 19 |
|
| 20 |
app.all('/', (req, res) => {
|
| 21 |
const status = {}
|
|
@@ -215,7 +216,6 @@ app.post('/api/nsfw-check', async (req, res) => {
|
|
| 215 |
const PORT = process.env.PORT || 7860
|
| 216 |
app.listen(PORT, () => {
|
| 217 |
console.log('App running on port', PORT)
|
| 218 |
-
load_model()
|
| 219 |
})
|
| 220 |
|
| 221 |
function formatSize(num) {
|
|
@@ -340,7 +340,7 @@ async function waifu2x(image, formats) {
|
|
| 340 |
return images.data
|
| 341 |
}
|
| 342 |
async function check_nsfw(buffer) {
|
| 343 |
-
let _model
|
| 344 |
const convert = async (img) => {
|
| 345 |
// Decoded image in UInt8 Byte array
|
| 346 |
const image = await jpegjs.decode(img, { useTArray: true })
|
|
@@ -368,5 +368,5 @@ async function check_nsfw(buffer) {
|
|
| 368 |
return results
|
| 369 |
}
|
| 370 |
async function load_model() {
|
| 371 |
-
|
| 372 |
}
|
|
|
|
| 16 |
app.set('json spaces', 4)
|
| 17 |
app.use(morgan('dev'))
|
| 18 |
app.use(express.json())
|
| 19 |
+
app.use(load_model())
|
| 20 |
|
| 21 |
app.all('/', (req, res) => {
|
| 22 |
const status = {}
|
|
|
|
| 216 |
const PORT = process.env.PORT || 7860
|
| 217 |
app.listen(PORT, () => {
|
| 218 |
console.log('App running on port', PORT)
|
|
|
|
| 219 |
})
|
| 220 |
|
| 221 |
function formatSize(num) {
|
|
|
|
| 340 |
return images.data
|
| 341 |
}
|
| 342 |
async function check_nsfw(buffer) {
|
| 343 |
+
let _model = load_model()
|
| 344 |
const convert = async (img) => {
|
| 345 |
// Decoded image in UInt8 Byte array
|
| 346 |
const image = await jpegjs.decode(img, { useTArray: true })
|
|
|
|
| 368 |
return results
|
| 369 |
}
|
| 370 |
async function load_model() {
|
| 371 |
+
return await nsfwjs.load()
|
| 372 |
}
|