Compare commits
2 commits
65c2e81202
...
d11aba0d9b
Author | SHA1 | Date | |
---|---|---|---|
d11aba0d9b | |||
271d623a78 |
3 changed files with 80 additions and 8 deletions
78
README.md
78
README.md
|
@ -2,13 +2,83 @@
|
|||
|
||||
> Predicting film genres from their posters with Tensorflow.js
|
||||
|
||||
## Dataset
|
||||
The dataset used with this demo can be found here:
|
||||
|
||||
To use:
|
||||
https://nextcloud.starbeamrainbowlabs.com/index.php/s/wmCdL4tX3HHGAFD
|
||||
|
||||
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
|
||||
node src/index.mjs train --input datasets/posters-256/ --output output/
|
||||
node src/index.mjs predict --input datasets/posters-256/validate/25410,Comedy,Family,Drama.jpg --ai-model output/checkpoints/49 2>/dev/null
|
||||
git clone https://git.starbeamrainbowlabs.com/Demos/film-poster-genres.git
|
||||
cd film-poster-genres
|
||||
```
|
||||
|
||||
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/
|
||||
```
|
||||
|
||||
|
||||
TODO: Fill out this README (and maybe move it to GitHub & make this repo a clone)
|
||||
## Predicting
|
||||
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,6 +4,8 @@ import path from 'path';
|
|||
import fs from 'fs';
|
||||
|
||||
import tf from '@tensorflow/tfjs-node';
|
||||
// import tf from '@tensorflow/tfjs-node-gpu';
|
||||
// import tf from '@tensorflow/tfjs';
|
||||
|
||||
import genres from './Genres.mjs';
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"use strict";
|
||||
|
||||
export default [
|
||||
"Action",
|
||||
"Adventure",
|
||||
"Animation",
|
||||
"Action", // 0
|
||||
"Adventure", // 1
|
||||
"Animation", // 2
|
||||
"Biography",
|
||||
"Comedy",
|
||||
"Crime",
|
||||
|
@ -23,5 +23,5 @@ export default [
|
|||
"Sport",
|
||||
"Thriller",
|
||||
"War",
|
||||
"Western"
|
||||
"Western" // 22
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue