Media organizer with Object detection model (coco-ssd) in TensorFlow.js
npm install deep-organizerThis is a nodejs package to organize files like images and videos in folders with respective classes detected by a Tensorflow object detect model (converted from python to js).
js
const DeepOrganizer = require('@nindoo/deep-organizer').DeepOrganizerconst modelConfig = {
modelUrl: 'file://path/for/your/web_model/model.json',
classes: {
1: {
name: 'CNH_F',
id: 1,
displayName: 'CNH_F'
},
2:{
name: 'CNH_Fv',
id: 2,
displayName: 'CNH_Fv'
}
}
}
const mediaPath = 'media/path/videos-or-images'
const organizer = new DeepOrganizer(modelConfig, mediaPath)
organizer.loadModel().then(async ()=>{
await organizer.organizeImagesTo(mediaPath)
await organizer.organizeVideosTo(mediaPath)
})
`modelConfig
` js
const modelConfig = {
modelUrl: 'It MUST start with file:// for local files or https:// for remote files',
classes: 'It repesent your label_map.pbtxt from your tensorflow model'
}
`$3
This model is based on the TensorFlow object detection API. You can download the original models from here. We applied the following optimizations to improve the performance for browser execution:
1. Install the TensorFlow.js pip package:
`pip install tensorflowjs`2. Run the converter script provided by the pip package:
The converter expects a TensorFlow SavedModel, TensorFlow Hub module, TensorFlow.js JSON format, Keras HDF5 model, or tf.keras SavedModel for input.
TensorFlow SavedModel example:
`
tensorflowjs_converter \
--input_format=tf_saved_model \
--output_format=tfjs_graph_model \
--signature_name=serving_default \
--saved_model_tags=serve \
/mobilenet/saved_model \
/mobilenet/web_model
`Tensorflow Hub module example:
`
tensorflowjs_converter \
--input_format=tf_hub \
'https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/1' \
/mobilenet/web_model
`Keras HDF5 model example:
`
tensorflowjs_converter \
--input_format=keras \
/tmp/my_keras_model.h5 \
/tmp/my_tfjs_model
`tf.keras SavedModel example:
`
tensorflowjs_converter \
--input_format=keras_saved_model \
/tmp/my_tf_keras_saved_model/1542211770 \
/tmp/my_tfjs_model
``