Gathering detailed insights and metrics for @tensorflow-models/coco-ssd
Gathering detailed insights and metrics for @tensorflow-models/coco-ssd
Gathering detailed insights and metrics for @tensorflow-models/coco-ssd
Gathering detailed insights and metrics for @tensorflow-models/coco-ssd
Pretrained models for TensorFlow.js
npm install @tensorflow-models/coco-ssd
Typescript
Module System
Node Version
NPM Version
TypeScript (58.24%)
Jupyter Notebook (22.78%)
JavaScript (16.39%)
HTML (1.92%)
Shell (0.39%)
CSS (0.15%)
SCSS (0.14%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
14,555 Stars
932 Commits
4,396 Forks
277 Watchers
396 Branches
141 Contributors
Updated on Jul 10, 2025
Latest Version
2.2.3
Package Id
@tensorflow-models/coco-ssd@2.2.3
Unpacked Size
261.80 kB
Size
61.42 kB
File Count
22
NPM Version
9.8.0
Node Version
20.5.0
Published on
Aug 22, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
18
Object detection model that aims to localize and identify multiple objects in a single image.
This model is a TensorFlow.js port of the COCO-SSD model. For more information about Tensorflow object detection API, check out this readme in tensorflow/object_detection.
This model detects objects defined in the COCO dataset, which is a large-scale object detection, segmentation, and captioning dataset. You can find more information here. The model is capable of detecting 80 classes of objects. (SSD stands for Single Shot MultiBox Detection).
This TensorFlow.js model does not require you to know about machine learning.
It can take input as any browser-based image elements (<img>
, <video>
, <canvas>
elements, for example) and returns an array of bounding boxes with class name and confidence level.
There are two main ways to get this model in your JavaScript project: via script tags or by installing it from NPM and using a build tool like Parcel, WebPack, or Rollup.
1<!-- Load TensorFlow.js. This is required to use coco-ssd model. --> 2<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"> </script> 3<!-- Load the coco-ssd model. --> 4<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd"> </script> 5 6<!-- Replace this with your image. Make sure CORS settings allow reading the image! --> 7<img id="img" src="cat.jpg"/> 8 9<!-- Place your code in the script tag below. You can also use an external .js file --> 10<script> 11 // Notice there is no 'import' statement. 'cocoSsd' and 'tf' is 12 // available on the index-page because of the script tag above. 13 14 const img = document.getElementById('img'); 15 16 // Load the model. 17 cocoSsd.load().then(model => { 18 // detect objects in the image. 19 model.detect(img).then(predictions => { 20 console.log('Predictions: ', predictions); 21 }); 22 }); 23</script>
Note: The following shows how to use coco-ssd npm to transpile for web deployment, not an example on how to use coco-ssd in the node env.
1// Note: Require the cpu and webgl backend and add them to package.json as peer dependencies. 2require('@tensorflow/tfjs-backend-cpu'); 3require('@tensorflow/tfjs-backend-webgl'); 4const cocoSsd = require('@tensorflow-models/coco-ssd'); 5 6(async () => { 7 const img = document.getElementById('img'); 8 9 // Load the model. 10 const model = await cocoSsd.load(); 11 12 // Classify the image. 13 const predictions = await model.detect(img); 14 15 console.log('Predictions: '); 16 console.log(predictions); 17})();
You can also take a look at the demo app.
coco-ssd
is the module name, which is automatically included when you use the <script src>
method. When using ES6 imports, coco-ssd
is the module.
1export interface ModelConfig { 2 base?: ObjectDetectionBaseModel; 3 modelUrl?: string; 4} 5 6cocoSsd.load(config: ModelConfig = {});
Args: config Type of ModelConfig interface with following attributes:
base: Controls the base cnn model, can be 'mobilenet_v1', 'mobilenet_v2' or 'lite_mobilenet_v2'. Defaults to 'lite_mobilenet_v2'. lite_mobilenet_v2 is smallest in size, and fastest in inference speed. mobilenet_v2 has the highest classification accuracy.
modelUrl: An optional string that specifies custom url of the model. This is useful for area/countries that don't have access to the model hosted on GCP.
Returns a model
object.
You can detect objects with the model without needing to create a Tensor.
model.detect
takes an input image element and returns an array of bounding boxes with class name and confidence level.
This method exists on the model that is loaded from cocoSsd.load
.
1model.detect( 2 img: tf.Tensor3D | ImageData | HTMLImageElement | 3 HTMLCanvasElement | HTMLVideoElement, maxNumBoxes: number, minScore: number 4)
Args:
Returns an array of classes and probabilities that looks like:
1[{ 2 bbox: [x, y, width, height], 3 class: "person", 4 score: 0.8380282521247864 5}, { 6 bbox: [x, y, width, height], 7 class: "kite", 8 score: 0.74644153267145157 9}]
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:
Here is the converter command for removing the post process graph.
1tensorflowjs_converter --input_format=tf_frozen_model \ 2 --output_format=tfjs_graph_model \ 3 --output_node_names='Postprocessor/ExpandDims_1,Postprocessor/Slice' \ 4 ./frozen_inference_graph.pb \ 5 ./web_model
No vulnerabilities found.
Reason
all changesets reviewed
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 9
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
113 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More