28 lines
807 B
JavaScript
28 lines
807 B
JavaScript
"use strict";
|
|
|
|
import path from 'path';
|
|
import fs from 'fs';
|
|
|
|
import FilmPredictor from '../../lib/FilmPredictor.mjs';
|
|
import Categories from '../../lib/Categories.mjs';
|
|
|
|
export default async function(settings) {
|
|
if(!fs.existsSync(settings.input)) {
|
|
console.error(`Error: The input file '${settings.input}' doesn't exist (did you type it correctly?)`);
|
|
process.exit(1);
|
|
}
|
|
if(!fs.existsSync(settings.ai_model)) {
|
|
console.error(`Error: Failed to locate AI model directory at '${settings.ai_model}'.`);
|
|
process.exit(1);
|
|
}
|
|
|
|
let model = new FilmPredictor(
|
|
settings,
|
|
new Categories(path.join(settings.ai_model, "categories.txt"))
|
|
);
|
|
await model.init(settings.ai_model); // We're training a new model here
|
|
|
|
let result = await model.predict(settings.input);
|
|
console.log(result.join("\n"));
|
|
}
|