Compare commits
No commits in common. "d11aba0d9b795a4f306f8ed51a808cf7c3c57e7e" and "65c2e81202083bc65d21b031d3d9b4fcf1c3cd88" have entirely different histories.
d11aba0d9b
...
65c2e81202
3 changed files with 8 additions and 80 deletions
78
README.md
78
README.md
|
@ -2,83 +2,13 @@
|
||||||
|
|
||||||
> Predicting film genres from their posters with Tensorflow.js
|
> Predicting film genres from their posters with Tensorflow.js
|
||||||
|
|
||||||
## Dataset
|
|
||||||
The dataset used with this demo can be found here:
|
|
||||||
|
|
||||||
https://nextcloud.starbeamrainbowlabs.com/index.php/s/wmCdL4tX3HHGAFD
|
To use:
|
||||||
|
|
||||||
The format is as follows:
|
|
||||||
|
|
||||||
```
|
|
||||||
+ dataset_dir/
|
|
||||||
+ train/
|
|
||||||
+ 1234,Comedy,Fantasy.jpg
|
|
||||||
+ 4321,Western,Short,Drama.jpg
|
|
||||||
+ .....
|
|
||||||
+ validate/
|
|
||||||
+ 6789,Drama,Mystery,Thriller.jpg
|
|
||||||
+ 9876,History,Documentary,Animation.jpg
|
|
||||||
+ .....
|
|
||||||
```
|
|
||||||
|
|
||||||
The filenames of the images take the following format: `ID,GENRE_1,GENRE_2,GENRE_N.jpg`.
|
|
||||||
|
|
||||||
## System / User Requirements
|
|
||||||
- [Node.js](https://nodejs.org/)
|
|
||||||
- [NPM](https://www.npmjs.com/) (installed by default with Node.js)
|
|
||||||
- A relatively decent CPU
|
|
||||||
- Basic knowledge of the command-line / terminal
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
First, clone this git repo:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://git.starbeamrainbowlabs.com/Demos/film-poster-genres.git
|
node src/index.mjs train --input datasets/posters-256/ --output output/
|
||||||
cd film-poster-genres
|
node src/index.mjs predict --input datasets/posters-256/validate/25410,Comedy,Family,Drama.jpg --ai-model output/checkpoints/49 2>/dev/null
|
||||||
```
|
|
||||||
|
|
||||||
Then, install the dependencies:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### Training
|
|
||||||
To train a new model:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
node src/index.mjs train --input path/to/dataset_dir --output path/to/output_dir
|
|
||||||
```
|
|
||||||
|
|
||||||
The output directory will look like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
+ output_dir/
|
|
||||||
+ metrics.stream.json
|
|
||||||
+ checkpoints/
|
|
||||||
+ 0/
|
|
||||||
+ 1/
|
|
||||||
+ 2/
|
|
||||||
+ 3/
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Predicting
|
TODO: Fill out this README (and maybe move it to GitHub & make this repo a clone)
|
||||||
To make a prediction using an existing model:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
node src/index.mjs predict --input path/to/image.jpg --ai-model path/to/checkpoint_dir/
|
|
||||||
```
|
|
||||||
|
|
||||||
The result will be written to the standard output. Extra debugging data is written to the standard error, but this can be ignored.
|
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
Contributions are very welcome! Git patches are preferred - I can move this repo to GitHub if that makes it easier. Please mention in your contribution that you release your work under the MPL-2.0 (see below).
|
|
||||||
|
|
||||||
|
|
||||||
## Licence
|
|
||||||
This code is released under the Mozilla Public License 2.0. The full license text is included in the `LICENSE` file in this repository. Tldr legal have a [great summary](https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)) of the license if you're interested.
|
|
||||||
|
|
|
@ -4,8 +4,6 @@ import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
import tf from '@tensorflow/tfjs-node';
|
import tf from '@tensorflow/tfjs-node';
|
||||||
// import tf from '@tensorflow/tfjs-node-gpu';
|
|
||||||
// import tf from '@tensorflow/tfjs';
|
|
||||||
|
|
||||||
import genres from './Genres.mjs';
|
import genres from './Genres.mjs';
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
"Action", // 0
|
"Action",
|
||||||
"Adventure", // 1
|
"Adventure",
|
||||||
"Animation", // 2
|
"Animation",
|
||||||
"Biography",
|
"Biography",
|
||||||
"Comedy",
|
"Comedy",
|
||||||
"Crime",
|
"Crime",
|
||||||
|
@ -23,5 +23,5 @@ export default [
|
||||||
"Sport",
|
"Sport",
|
||||||
"Thriller",
|
"Thriller",
|
||||||
"War",
|
"War",
|
||||||
"Western" // 22
|
"Western"
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue