Files
at-mintel/packages/image-processor/scripts/download-models.ts
Marc Mintel b3d089ac6d
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 2s
Monorepo Pipeline / 🏗️ Build (push) Has been cancelled
Monorepo Pipeline / 🚀 Release (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been cancelled
Monorepo Pipeline / 🧹 Lint (push) Has been cancelled
Monorepo Pipeline / 🧪 Test (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been cancelled
feat(content-engine): enhance content pruning rule in orchestrator
2026-02-22 18:53:17 +01:00

49 lines
1.3 KiB
TypeScript

import * as fs from 'node:fs';
import * as path from 'node:path';
import * as https from 'node:https';
const MODELS_DIR = path.join(process.cwd(), 'models');
const BASE_URL = 'https://raw.githubusercontent.com/vladmandic/face-api/master/model/';
const models = [
'tiny_face_detector_model-weights_manifest.json',
'tiny_face_detector_model-shard1'
];
async function downloadModel(filename: string) {
const destPath = path.join(MODELS_DIR, filename);
if (fs.existsSync(destPath)) {
console.log(`Model ${filename} already exists.`);
return;
}
return new Promise((resolve, reject) => {
console.log(`Downloading ${filename}...`);
const file = fs.createWriteStream(destPath);
https.get(BASE_URL + filename, (response) => {
response.pipe(file);
file.on('finish', () => {
file.close();
resolve(true);
});
}).on('error', (err) => {
fs.unlinkSync(destPath);
reject(err);
});
});
}
async function main() {
if (!fs.existsSync(MODELS_DIR)) {
fs.mkdirSync(MODELS_DIR, { recursive: true });
}
for (const model of models) {
await downloadModel(model);
}
console.log('All models downloaded successfully!');
}
main().catch(console.error);