gender-classification
v1.0.3
Published
**JavaScript API for gender classification and prediction in the browser implemented on top of the tensorflow.js core API ([tensorflow/tfjs-core](https://github.com/tensorflow/tfjs-core))**
Downloads
3
Readme
Gender Classification
JavaScript API for gender classification and prediction in the browser implemented on top of the tensorflow.js core API (tensorflow/tfjs-core)
npm install gender-classification --save
Table of Contents:
Resources
Live Demo
Examples
Gender Classification
> genderClassification("John") > "Male"
> genderClassification("Sarah") > "Female"
Under the hood: The model is trained with a three-layer feed forward neural network using back propagation with the input layer using 10 neurons with the relu activation function, a hidden layer with 5 neurons again with the relu activation function, and an output layer using 2 neurons with the softmax activation function.
Usage
Loading the Model
To load the model, you have provide the corresponding manifest.json file as well as the model weight files (shards) as assets. Simply copy them to your public or assets folder. The manifest.json and shard files of a model have to be located in the same directory / accessible under the same route.
Assuming the models reside in public/models:
const tf = require('@tensorflow/tfjs')
const genderClassification = require('gender-classification')
let model = await genderClassification(tf).loadModel('./model/model.json')
model.classify(name).then(function(prediction) {
return prediction.gender
})