Skip to content

Commit a9408f1

Browse files
authored
Fix script and update README for examples (#271)
1 parent c3dc0df commit a9408f1

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

examples/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
Jump right into experimenting with ml5.js — no local setup needed. Browse and run these example sketches directly in the p5.js Web Editor:
88

9+
### p5.js 1.0 Examples
10+
911
* [bodyPose-blazePose-keypoints](https://editor.p5js.org/ml5/sketches/OukJYAJAb)
1012
* [bodyPose-blazePose-skeleton](https://editor.p5js.org/ml5/sketches/KWgsAbgkk)
1113
* [bodyPose-keypoints](https://editor.p5js.org/ml5/sketches/c8sl_hGmN)
@@ -41,3 +43,41 @@ Jump right into experimenting with ml5.js — no local setup needed. Browse and
4143
* [sentiment](https://editor.p5js.org/ml5/sketches/hopIvsCGL)
4244
* [soundClassifier-speech-command](https://editor.p5js.org/ml5/sketches/HUm7NYMW3)
4345
* [soundClassifier-teachable-machine](https://editor.p5js.org/ml5/sketches/mXeiNXSTU)
46+
47+
### p5.js 2.0 Examples
48+
49+
* [bodyPose-blazePose-keypoints-p5-2.0](https://editor.p5js.org/ml5/sketches/sP85k-fKm)
50+
* [bodyPose-blazePose-skeleton-p5-2.0](https://editor.p5js.org/ml5/sketches/zsaF9ba79)
51+
* [bodyPose-keypoints-p5-2.0](https://editor.p5js.org/ml5/sketches/HNDZ0x9Cw)
52+
* [bodyPose-skeletal-connections-p5-2.0](https://editor.p5js.org/ml5/sketches/WwsTweT9b)
53+
* [bodySegmentation-mask-background-p5-2.0](https://editor.p5js.org/ml5/sketches/bnvFIh130)
54+
* [bodySegmentation-mask-body-parts-p5-2.0](https://editor.p5js.org/ml5/sketches/6XXIEgOIh)
55+
* [bodySegmentation-mask-person-p5-2.0](https://editor.p5js.org/ml5/sketches/rnVuKC28TE)
56+
* [bodySegmentation-select-body-parts-p5-2.0](https://editor.p5js.org/ml5/sketches/itiZfISJS)
57+
* [faceMesh-bounding-box-p5-2.0](https://editor.p5js.org/ml5/sketches/tA2Jv8Kul8)
58+
* [faceMesh-keypoints-from-parts-p5-2.0](https://editor.p5js.org/ml5/sketches/jLIgWoLmI)
59+
* [faceMesh-keypoints-p5-2.0](https://editor.p5js.org/ml5/sketches/9dSws-V0P-)
60+
* [faceMesh-parts-bounding-box-p5-2.0](https://editor.p5js.org/ml5/sketches/WoStCyRfx)
61+
* [faceMesh-parts-p5-2.0](https://editor.p5js.org/ml5/sketches/W40lqiNBU)
62+
* [faceMesh-shapes-from-parts-p5-2.0](https://editor.p5js.org/ml5/sketches/4wHQug7WA)
63+
* [faceMesh-single-image-p5-2.0](https://editor.p5js.org/ml5/sketches/4VixwHmTqZ)
64+
* [faceMesh-triangle-mesh-p5-2.0](https://editor.p5js.org/ml5/sketches/pefAwOB-te)
65+
* [faceMesh-uv-map-p5-2.0](https://editor.p5js.org/ml5/sketches/c2NG1BIeu7)
66+
* [handPose-detect-start-stop-p5-2.0](https://editor.p5js.org/ml5/sketches/0ZPVgZheGw)
67+
* [handPose-keypoints-p5-2.0](https://editor.p5js.org/ml5/sketches/6j1OirU5r2)
68+
* [handPose-parts-p5-2.0](https://editor.p5js.org/ml5/sketches/OwVzitG2F)
69+
* [handPose-single-image-p5-2.0](https://editor.p5js.org/ml5/sketches/uicBxArcu)
70+
* [handPose-skeletal-connections-p5-2.0](https://editor.p5js.org/ml5/sketches/prrYA10Vl)
71+
* [imageClassifier-single-image-p5-2.0](https://editor.p5js.org/ml5/sketches/MqHsXgwlO)
72+
* [imageClassifier-teachable-machine-p5-2.0](https://editor.p5js.org/ml5/sketches/opcgWuKcEt)
73+
* [imageClassifier-webcam-p5-2.0](https://editor.p5js.org/ml5/sketches/B359dux1dM)
74+
* [neuralNetwork-color-classifier-p5-2.0](https://editor.p5js.org/ml5/sketches/cdVSCdG-wh)
75+
* [neuralNetwork-load-model-p5-2.0](https://editor.p5js.org/ml5/sketches/EDDJt4EzI9)
76+
* [neuralNetwork-mouse-gesture-p5-2.0](https://editor.p5js.org/ml5/sketches/xKdqszmaH)
77+
* [neuralNetwork-train-and-save-p5-2.0](https://editor.p5js.org/ml5/sketches/jvB3w61n1a)
78+
* [neuroEvolution-flappy-bird-p5-2.0](https://editor.p5js.org/ml5/sketches/f-IjWYLFy)
79+
* [neuroEvolution-sensors-p5-2.0](https://editor.p5js.org/ml5/sketches/e7C57OOfJ)
80+
* [neuroEvolution-steering-p5-2.0](https://editor.p5js.org/ml5/sketches/VLuEO4I_T)
81+
* [sentiment-p5-2.0](https://editor.p5js.org/ml5/sketches/NbCoKPg48)
82+
* [soundClassifier-speech-command-p5-2.0](https://editor.p5js.org/ml5/sketches/_4V2kw3FN)
83+
* [soundClassifier-teachable-machine-p5-2.0](https://editor.p5js.org/ml5/sketches/gZayua1l0s)

scripts/uploadExamples.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,23 @@ deleteSketch = async (file) => {
137137
return res.status;
138138
};
139139

140+
/**
141+
* Get the directory paths of each directory in a given directory.
142+
*
143+
* @param {string} dir - The directory path.
144+
* @returns - An array of directory paths.
145+
*/
146+
function getDirectoryPaths(dir) {
147+
let directories = [];
148+
fs.readdirSync(dir).forEach((file) => {
149+
const path = `${dir}/${file}`;
150+
if (fs.lstatSync(path).isDirectory()) {
151+
directories.push(path);
152+
}
153+
});
154+
return directories;
155+
}
156+
140157
/**
141158
* Get the file path of each item in a given directory.
142159
*
@@ -146,10 +163,7 @@ deleteSketch = async (file) => {
146163
function getFilepaths(dir) {
147164
let files = [];
148165
fs.readdirSync(dir).forEach((file) => {
149-
const path = `${dir}/${file}`;
150-
if (fs.lstatSync(path).isDirectory()) {
151-
files.push(path);
152-
}
166+
files.push(`${dir}/${file}`);
153167
});
154168
return files;
155169
}
@@ -319,7 +333,7 @@ async function main() {
319333
process.exit(1);
320334
}
321335
const oldSketches = getSketchesRes.data;
322-
const sketchPaths = getFilepaths("examples");
336+
const sketchPaths = getDirectoryPaths("examples");
323337

324338
// Update existing sketches and upload new sketches
325339
console.log("Uploading sketches...");

0 commit comments

Comments
 (0)