AdamCodd/media-random-generator

0

stars

60

commits

JavaScript

primary language

Aug 31, 2025

updated

README

Media random generator

This is a simple JS script that can efficiently retrieve a random image from Imgur (up to 500) or random Streamable videos (up to 5), using IndexedDB to avoid displaying duplicates. Later I added a ViT classifier model to test a NSFW filter in browser.
You can test it here: https://adamcodd.github.io/media-random-generator

[31/08] I’ve added a confidence cutoff. This will help you better understand the false positives and false negatives you might encounter at different cutoff values when working with real-world images.

WebGPU Support

I added a new experimental webGPU support (fallback to WASM if it's not supported). It's way faster than WASM, but might take a little while to load depending on your network.

As of December 2024, global WebGPU support is around 72% (according to caniuse.com), meaning some users may not be able to use the WebGPU API. You may need to enable it using a feature flag:

  • Firefox: with the dom.webgpu.enabled flag (see here).
  • Safari: with the WebGPU feature flag (see here).
  • Older Chromium browsers (on Windows, macOS, Linux): with the enable-unsafe-webgpu flag (see here).

Imgur generator

Click on the image to view the full size version.
Warning: Some images might be NSFW. All content displayed here belongs to its respective authors.

Image classification

Thanks to Transformer.js, using only vanilla JavaScript, I'm able to run my quantized ONNX image classification model directly in the browser. Although it's a bit slow, and there are some false positives/negatives due to the quantization, it works effectively.

You can select SFW/NSFW to display only those types of images from random Imgur selections. However, don't try more than 10 images at once or it'll take forever.

Because of the ES6 modules, if you want to run the script locally you'll need a server environment (npm/python HTTP server). The easiest way if you have python 3.x installed:

cd media-random-generator
python -m http.server 8000 --bind 127.0.0.1

Then open http://127.0.0.1:8000 in your browser.

Streamable generator

Once you click on "reload," wait for a moment until you receive a functional URL; it will open a streamable stream in an iframe.

Contributors

AdamCodd

60 commits

AdamCodd/media-random-generator

0

stars

60

commits

JavaScript

primary language

Aug 31, 2025

updated

README

Media random generator

This is a simple JS script that can efficiently retrieve a random image from Imgur (up to 500) or random Streamable videos (up to 5), using IndexedDB to avoid displaying duplicates. Later I added a ViT classifier model to test a NSFW filter in browser.
You can test it here: https://adamcodd.github.io/media-random-generator

[31/08] I’ve added a confidence cutoff. This will help you better understand the false positives and false negatives you might encounter at different cutoff values when working with real-world images.

WebGPU Support

I added a new experimental webGPU support (fallback to WASM if it's not supported). It's way faster than WASM, but might take a little while to load depending on your network.

As of December 2024, global WebGPU support is around 72% (according to caniuse.com), meaning some users may not be able to use the WebGPU API. You may need to enable it using a feature flag:

  • Firefox: with the dom.webgpu.enabled flag (see here).
  • Safari: with the WebGPU feature flag (see here).
  • Older Chromium browsers (on Windows, macOS, Linux): with the enable-unsafe-webgpu flag (see here).

Imgur generator

Click on the image to view the full size version.
Warning: Some images might be NSFW. All content displayed here belongs to its respective authors.

Image classification

Thanks to Transformer.js, using only vanilla JavaScript, I'm able to run my quantized ONNX image classification model directly in the browser. Although it's a bit slow, and there are some false positives/negatives due to the quantization, it works effectively.

You can select SFW/NSFW to display only those types of images from random Imgur selections. However, don't try more than 10 images at once or it'll take forever.

Because of the ES6 modules, if you want to run the script locally you'll need a server environment (npm/python HTTP server). The easiest way if you have python 3.x installed:

cd media-random-generator
python -m http.server 8000 --bind 127.0.0.1

Then open http://127.0.0.1:8000 in your browser.

Streamable generator

Once you click on "reload," wait for a moment until you receive a functional URL; it will open a streamable stream in an iframe.

Contributors

AdamCodd

60 commits

Languages

JavaScript

91.9%

HTML

4.2%

CSS

3.9%