Public
Edited
Dec 14, 2022
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fullData
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
colorMap = {
const colors = {},
names = new Array(...new Set(fullData.map((d) => d.name)));

names.map((name, i) => {
colors[name] = d3.schemeCategory10[i % 10] + "a0";
});

return colors;
}
Insert cell
d3.schemeCategory10
Insert cell
fullData = {
const data = [],
n = topValues.length;

for (let i = 0; i < n; ++i) {
data.push({
value: topValues[i],
indice: topIndices[i],
name: cocoClasses[topIndices[i]],
box: boxes[i]
});
}

return [...data].sort((a, b) => b.value - a.value); // data;
}
Insert cell
topValues = detectionsTopClass.values.data()
Insert cell
topIndices = detectionsTopClass.indices.data()
Insert cell
detectionsTopClass = detections[0].topk()
Insert cell
boxes = detections[1].squeeze().array()
Insert cell
detections = ssdMobileNet.executeAsync(imageTensor.expandDims())
Insert cell
// net1.executeAsync(imageTensor.expandDims())
Insert cell
// ssdMobileNet.predict(imageTensor.expandDims()) // Oops!
Insert cell
ssdMobileNet = {
const ssdMobileNetPath =
"https://tfhub.dev/tensorflow/tfjs-model/ssd_mobilenet_v2/1/default/1";
return tf.loadGraphModel(ssdMobileNetPath, { fromTFHub: true });
}
Insert cell
// net1 = {
// const path =
// "https://tfhub.dev/rishit-dagli/tfjs-model/yolo-cppe5-tfjs/default/1";
// return tf.loadGraphModel(path, { fromTFHub: true });
// }
Insert cell
imageTensor = tf.browser.fromPixels(img)
Insert cell
tf = require("@tensorflow/tfjs@4.0.0/dist/tf.min.js")
Insert cell
Insert cell
d3 = require("d3")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more