gender-classification

1.0.3 • Public • Published

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

Check out the 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.

Neural Network

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
})

/gender-classification/

    Package Sidebar

    Install

    npm i gender-classification

    Weekly Downloads

    1

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    995 kB

    Total Files

    10

    Last publish

    Collaborators

    • gregfrench