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
Implemented a fully local graffiti drawing and moderation demo.
- Replaced
src/App.tsxwith a responsive MS Paint-style canvas: brush, eraser, color selection, brush width, undo, clear, and pointer/touch drawing. - Added
src/lib/graffitiModeration.tswith pluggable APIs:moderateGraffitiCanvas(canvas)moderateGraffitiImageData(imageData)
- The local moderation engine downsamples to 96x96, normalizes the drawn pixels, tests rotated/mirrored extremist-symbol templates, and returns a game-ready result such as:
No forbidden content - a carForbidden content - swastika-like extremist symbol
- It never sends the drawing over the network and can be imported directly into the game flow.
- Added visual result states and reduced-motion-aware interaction animation in
src/index.css.
npm run buildcompleted successfully.Important limitation: template matching is intentionally high-recall but cannot guarantee detection of all offensive drawings or symbols. For production-grade coverage of broader inappropriate content, keep this as a fast local block-list layer and add a trained, on-device classifier with a reviewed labeled dataset.
- Replaced
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.