Predicting film genres from their posters with Tensorflow.js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

34 lines
983 B

"use strict";
import fs from 'fs';
import DataPreprocessor from '../../lib/DataPreprocessor.mjs';
import FilmPredictor from '../../lib/FilmPredictor.mjs';
export default async function(settings) {
if(typeof settings.input !== "string") {
console.error("Error: No input directory specified");
process.exit(1);
}
if(typeof settings.output !== "string") {
console.error("Error: No output directory specified");
process.exit(1);
}
if(!fs.existsSync(settings.input)) {
console.error(`Error: The input directory '${settings.input}' doesn't exist (did you type it correctly?)`);
process.exit(1);
}
if(!fs.existsSync(settings.output))
await fs.promises.mkdir(settings.output, { recursive: true, mode: 0o755 });
let preprocessor = new DataPreprocessor(settings.input);
let model = new FilmPredictor(settings);
await model.init(); // We're training a new model here
await model.train(
preprocessor.dataset_train(),
preprocessor.dataset_validate()
);
}