{"id":21373228,"url":"https://github.com/joeylemon/sketch-classifier","last_synced_at":"2026-05-05T17:31:49.755Z","repository":{"id":85081650,"uuid":"434792034","full_name":"joeylemon/sketch-classifier","owner":"joeylemon","description":"a tensorflow.js convolutional neural network for classifying sketches","archived":false,"fork":false,"pushed_at":"2021-12-08T15:18:31.000Z","size":2329,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-24T08:17:08.185Z","etag":null,"topics":["machine-learning","neural-network","nodejs","quickdraw-dataset","tensorflowjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joeylemon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-04T02:56:25.000Z","updated_at":"2021-12-24T16:57:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"3fe8ab66-6d20-40da-a4da-2a41280fd4f6","html_url":"https://github.com/joeylemon/sketch-classifier","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joeylemon/sketch-classifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeylemon%2Fsketch-classifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeylemon%2Fsketch-classifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeylemon%2Fsketch-classifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeylemon%2Fsketch-classifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joeylemon","download_url":"https://codeload.github.com/joeylemon/sketch-classifier/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeylemon%2Fsketch-classifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32660196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["machine-learning","neural-network","nodejs","quickdraw-dataset","tensorflowjs"],"created_at":"2024-11-22T08:26:34.703Z","updated_at":"2026-05-05T17:31:49.729Z","avatar_url":"https://github.com/joeylemon.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sketch Classifier\n\nA [Tensorflow.js](https://www.tensorflow.org/js) program to construct and train a convolutional neural network to classify sketches. This program is built to make use of Google's [\"Quick, Draw!\"](https://github.com/googlecreativelab/quickdraw-dataset) dataset. The model saved in this repository was trained on over 9 million drawings of 65 different types. To speed up the training process, this program uses the tfjs-node-gpu package to utilize Tensorflow's C binary and perform tensor operations on the GPU with CUDA.\n\n## Background\nGoogle's dataset is provided in the form of drawing strokes instead of images. Therefore, during the training of the model, these strokes are used to generate images on-the-fly to be fed into the network. Additionally, to provide the network with even more context on stroke patterns, each individual stroke is colored differently, as seen below. White is the first stroke, red is the second, blue is the third, etc.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://i.imgur.com/skoPqCw.jpg\" /\u003e\u003c/p\u003e\n\nEach image is scaled to 64x64 pixels before being fed into the network. Below is the summary of the simple network model used in this script.\n\n| Layer  | Output Shape | Num Params |\n| ------------- | ------------- | ------------- |\n| conv2d_Conv2D1 (Conv2D)  | [null,60,60,4]  | 304  |\n| max_pooling2d_MaxPooling2D1  | [null,30,30,4]  | 0  |\n| conv2d_Conv2D2 (Conv2D)   | [null,26,26,8]   | 808  |\n| max_pooling2d_MaxPooling2D2  | [null,13,13,8]  | 0  |\n| flatten_Flatten1 (Flatten)  | [null,1352]  | 0  |\n| dense_Dense1 (Dense)  | [null,19]  | 25707  |\n\n## Data\n\nBecause of the massive amount of data provided by the \"Quick, Draw!\" dataset, data must be ingested and prepared in certain ways to prevent memory overflows. Tensorflow provides the tf.data.Dataset class, which serves to represent any arbitrary data to be passed into other Tensorflow methods. This Dataset class can be constructed in a way to use an iterator to hide the implementation of data retrieval as well as allow for a theoretically infinite amount of data to be retrieved. To build this class in this program, we use a Javascript generator function to natively create an iterable function. An example of this can be in the code snippet seen below:\n\n```js\nasync * dataGenerator () {\n    while (this.sampleNum \u003c this.numSamples) {\n        const line = await this.it.next()\n        const obj = JSON.parse(line.value)\n        const val = { xs: tf.tensor3d(drawingToPixels(obj.drawing)), ys: tf.tensor1d(this.labelArray(getSketchLabelValue(obj.word))) }\n\n        if (this.sampleNum++ === this.numSamples) { return val }\n        yield val\n    }\n}\n\nload () {\n    return tf.data.generator(this.dataGenerator.bind(this))\n}\n```\n\n## Usage\n\nFirst, download the sketches you wish to use to train the model to a directory named `sketches/`. The data is in the form of `.ndjson` files and can be downloaded from [Google Cloud Storage](https://console.cloud.google.com/storage/browser/quickdraw_dataset/full/simplified;tab=objects?prefix=\u0026forceOnObjectsSortingFiltering=false).\n\nThen, you must prepare the drawings into a single dataset file. This can be done with the prepare.js script:\n```sh\n\u003e node prepare.js\n```\n\nThis will create `train_data.ndjson` containing shuffled records from every dataset in `sketches/`. Now, you may run the training script with:\n```sh\n\u003e node train.js\n```\n\nTensorflow will output the training progress throughout the execution of the script. When the model has reached a satisfactory accuracy, you may predict a single random image from the `sketches/` directory using the following command:\n```sh\n\u003e node predict.js\n```\n\nThis script will output the probability of each label and also save the random drawing to `image.png` so you may view it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeylemon%2Fsketch-classifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeylemon%2Fsketch-classifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeylemon%2Fsketch-classifier/lists"}