@xuda.io/account_module 1.2.305 → 1.2.306
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/download_model.js +0 -56
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xuda.io/account_module",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.306",
|
|
4
4
|
"description": "Xuda Account Server Module",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@imgly/background-removal-node": "^1.4.5",
|
|
8
7
|
"lodash": "^4.17.21",
|
|
9
8
|
"validator": "^13.1.1"
|
|
10
9
|
},
|
package/download_model.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// download-models.js
|
|
2
|
-
const https = require('https');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
const models = ['u2net.onnx', 'u2net.onnx.bin', 'u2net.onnx.wasm'];
|
|
7
|
-
|
|
8
|
-
const baseUrl = 'https://static.imgly.com/background-removal/models/medium/';
|
|
9
|
-
const outputDir = '/var/xuda/assets/imgly-bg';
|
|
10
|
-
|
|
11
|
-
// Create directory if it doesn't exist
|
|
12
|
-
if (!fs.existsSync(outputDir)) {
|
|
13
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function downloadFile(url, filepath) {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
const file = fs.createWriteStream(filepath);
|
|
19
|
-
https
|
|
20
|
-
.get(url, (response) => {
|
|
21
|
-
if (response.statusCode === 200) {
|
|
22
|
-
response.pipe(file);
|
|
23
|
-
file.on('finish', () => {
|
|
24
|
-
file.close();
|
|
25
|
-
console.log(`Downloaded: ${path.basename(filepath)}`);
|
|
26
|
-
resolve();
|
|
27
|
-
});
|
|
28
|
-
} else {
|
|
29
|
-
reject(new Error(`HTTP ${response.statusCode}: ${url}`));
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
.on('error', (err) => {
|
|
33
|
-
fs.unlink(filepath, () => {}); // Delete partial file
|
|
34
|
-
reject(err);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function downloadAll() {
|
|
40
|
-
console.log('Downloading models to:', outputDir);
|
|
41
|
-
|
|
42
|
-
for (const model of models) {
|
|
43
|
-
const url = baseUrl + model;
|
|
44
|
-
const filepath = path.join(outputDir, model);
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
await downloadFile(url, filepath);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.error(`Failed to download ${model}:`, error.message);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
console.log('Download complete!');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
downloadAll();
|