I'm working on a fully local simple graffiti drawing offline game (basic MS Paint style…
- User
I'm working on a fully local simple graffiti drawing offline game (basic MS Paint style brush) and I need a way to prevent players from making offensive content (e.g., drawing swastikas and whatnot).
For that, re-create that simple graffiti drawing interface and then create a moderation script that inputs the canvas with the drawing from the interface (in a way that would make it simple to plug that moderations script into the game itself) and then simply shows what it detected (e.g. 'no forbidden content - a car' if it's some inoffensive drawing like a car or 'forbidden content - swastika' if it's something offensive like swastika or other inappropriate drawing), so later in my game I can match it with the block list.
List of JavaScript libraries you might utilize:
- TensorFlow.js The core engine. Runs models fully in-browser (WebGL/WASM/WebGPU), 100% offline. Everything below sits on top of it or is an alternative to it.
- ONNX Runtime Web Alternative runtime; run models exported to ONNX in-browser.
- Transformers.js (Hugging Face) Run modern vision/vision-language models locally in JS. Heavier, but future-proof if you want a smarter classifier.
- MediaPipe Tasks (JS) Google's on-device vision tasks, including an image classifier task you can load custom models into.
- brain.js Lightweight neural nets in JS; workable for very simple custom classification, less capable than TF.js.
- NSFWJS Popular TF.js model classifying images into porn/hentai/sexy/neutral/drawing. Runs fully offline. Good if you also want to block explicit drawings — but it will not detect swastikas.
- OpenCV.js Full OpenCV compiled to WASM. Could do template/shape matching or contour analysis. In practice, brittle for freely-drawn rotated symbols — treat as a secondary signal, not the main line of defense.
- Quick, Draw!/DoodleNet-style classifier
- Use an existing DoodleNet / Quick, Draw!-style model, and map suspicious guesses to flags: swastika → often guessed as "stairs" / "windmill", peengus → often guessed as "hot dog" / "mushroom" / "snake" / "carrot"
False positives are acceptable as long as it works. Apply whatever restrictions it takes to guarantee maximum accuracy as possible however (e.g., smaller image resolution like 100x100 - if it actually improves it).
- Assistant
Built a fully local graffiti drawing page and a plug-in moderation helper.
What changed:
src/App.tsxnow has an MS Paint-style canvas with brush color, brush size, eraser, clear, and analyze controls.src/lib/moderation.tsexportsmoderateCanvas(canvas)so you can drop it into your game later.- The moderator normalizes the canvas to a small square analysis image, checks for a swastika first with a hard template match, then classifies against a small set of sketch templates.
- The UI shows results in the exact style you asked for, such as:
no forbidden content - a carforbidden content - swastika
A couple of notes:
- I kept it fully local and build-safe, so it does not depend on downloading a model at runtime.
- The moderation entry point is isolated, so you can import
moderateCanvasdirectly into the game later and compare the returnedlabelagainst your block list.
Verified:
npm run buildpasses successfully.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.