Skip to content

About

Bilingual visual showcase of real outputs from the Rails 8 AI Image Processing API: BiRefNet, MobileSAM, and libvips.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

Rails 8 AI Image Processing API — Visual Showcase

Release License Rails 8 API Static showcase Bilingual documentation

Language: English | Tiếng Việt

A static, bilingual visual companion for Rails-8-AI-Image-Processing-API.

This repository presents real API outputs in a human-friendly page: BiRefNet background removal, MobileSAM prompt-based segmentation, and deterministic libvips image processing. It is a visual demonstration of API behavior, not a model-quality benchmark and not the Rails API server itself.

What you can see

The showcase includes:

  • before/after background-removal comparisons;
  • transparent PNG cutouts and neutral-background composites;
  • BiRefNet examples for people and multiple object shapes;
  • MobileSAM point-prompt and box-prompt segmentation;
  • people, dog, cat, and horse selection examples;
  • deterministic resize, crop, contrast, saturation, tint, sharpening, and WebP examples;
  • code snippets with deployment URL and authentication-token placeholders;
  • English and Vietnamese UI;
  • source-image provenance and SHA-256 integrity metadata.

The public page lives in site/.

Project family

Repository Purpose
Rails-8-AI-Image-Processing-API Rails 8 application source, authentication, API endpoints, and AI/image-processing integration
This repository Human-friendly visual examples generated from real API responses
Community Acceptance Kit Reproducible black-box verification, reports, evidence, and integrity checks

Keeping these roles separate makes the project easier to understand: implementation in the API repository, visual explanation here, and formal public verification in the acceptance kit.

Deployment targets

This showcase is designed to be published as static HTML. The intended public hosting layout is:

  • Cloudflare Pages — canonical static deployment of the contents of site/.
  • Hugging Face Spaces (Static HTML) — static mirror of the same reviewed showcase.
  • GitHub Pages — not an active deployment target for this project.

A GitHub Pages deployment was tested earlier, but it conflicted with the account's existing custom-domain routing. The Pages branch was removed and the project moved forward with Cloudflare Pages plus a Hugging Face Static HTML mirror instead.

No permanent Cloudflare Pages or Hugging Face Space public URL is documented here until that deployment is actually created and verified.

Repository layout

Path Description
site/index.html Static bilingual showcase UI
site/assets/ Public assets used by the static page
site/SHA256SUMS SHA-256 manifest for the public site assets
assets/input/ Source and runtime-sized input images
assets/output/ Outputs produced from API calls or deterministic post-processing
assets/provenance.json Source URL, license, description, and hash bindings for documented inputs
scripts/setup_runtime_env.sh Secure interactive helper for creating the temporary runtime credential file
scripts/run_people_animals.sh Regenerates selected people/animal examples and installs them into the site
.env.example Placeholder-only reference for the runtime environment variables

Quick start: view the showcase locally

You do not need the Rails app, a GPU, BiRefNet, MobileSAM, or any model runtime just to view the repository.

Requirements:

  • Git
  • Python 3, only to serve the static files

Clone and serve the site:

git clone https://github.com/dangkhoa2016/Rails-8-AI-Image-Processing-API-Showcase.git
cd Rails-8-AI-Image-Processing-API-Showcase/site
python3 -m http.server 8080

Open:

http://127.0.0.1:8080

If your system exposes Python as python instead of python3, use that command instead.

Regenerating selected API outputs

This is optional. Use it only when you want to reproduce selected people/animal showcase assets from a running API deployment.

Requirements

You need:

  • a reachable deployment of Rails-8-AI-Image-Processing-API;
  • a valid test account for that deployment;
  • Ruby with the standard library used by the scripts;
  • Python 3;
  • Pillow for the local selection-preview post-processing.

The AI inference happens in the API deployment. The machine running this showcase helper does not need its own GPU if the remote deployment already provides the required AI runtime.

Runtime environment variables

The scripts expect exactly these values:

Variable Meaning
BASE_URL Base URL of the running Rails API deployment, without a required trailing slash
E2E_EMAIL Email address of the test account
E2E_PASSWORD Password of the test account

.env.example documents the schema with placeholders only.

Recommended credential setup

Use the interactive helper:

./scripts/setup_runtime_env.sh

It prompts for the deployment URL, test email, and password, then writes a shell-safe credential file to:

/tmp/showcase-e2e.env

The helper creates the file with mode 600. The password is entered silently.

Then run:

./scripts/run_people_animals.sh

When you are finished:

rm -f /tmp/showcase-e2e.env

Using .env.example manually

The example file is intentionally safe to commit. It contains no real credentials.

cp .env.example /tmp/showcase-e2e.env
chmod 600 /tmp/showcase-e2e.env
vi /tmp/showcase-e2e.env
SHOWCASE_ENV_FILE=/tmp/showcase-e2e.env ./scripts/run_people_animals.sh
rm -f /tmp/showcase-e2e.env

If you edit the file manually, keep it valid shell syntax. For passwords containing shell-special characters, the interactive setup helper is safer because it writes shell-escaped values automatically.

What the regeneration helper does

The current people/animals workflow is intentionally scoped. It does not regenerate every visual on the page.

The runner:

  1. calls POST /users/sign_in and extracts the JWT returned by the normal sign-in flow;
  2. calls POST /images/remove-background for transparent and neutral-background person outputs;
  3. calls POST /images/segment for person, dog, and horse point/box masks;
  4. uses Pillow locally to create dog/horse selection-preview WebP images from the masks;
  5. copies the selected generated assets into site/assets/;
  6. refreshes site/SHA256SUMS.

The static page also contains other curated examples, including object/background removal and deterministic image transforms, which are maintained separately from this focused helper.

API endpoints used by the helper

Endpoint Purpose
POST /users/sign_in Authenticate the test account and obtain a JWT
POST /images/remove-background Generate BiRefNet background-removal outputs
POST /images/segment Generate MobileSAM point/box segmentation masks

The page itself also contains copyable curl examples that use placeholders rather than embedded deployment credentials.

Provenance and integrity

Source-image provenance is recorded in assets/provenance.json. Publicly sourced images keep their documented license/provenance information; CC0 examples remain identified as CC0 rather than being relicensed by this repository.

The public site asset manifest is site/SHA256SUMS. From the site/ directory, verify the published assets with:

sha256sum -c SHA256SUMS

The manifest is useful for detecting accidental asset changes and for binding the showcase page to the files that were reviewed.

Security rules

Never commit or publish:

  • real deployment passwords;
  • JWTs or refresh tokens;
  • cookies or session material;
  • SMTP/API credentials;
  • GitHub tokens;
  • private deployment configuration.

The repository ignores local .env/.env.* files while explicitly allowing the placeholder-only .env.example.

For reproducible runs, prefer a short-lived credential file under /tmp, keep it mode 600, and delete it immediately after the run.

Updating the showcase safely

A typical content update should follow this sequence:

  1. choose a source asset with clear provenance and redistribution terms;
  2. record or update the source metadata in assets/provenance.json;
  3. generate the intended output through the real API when the example is meant to represent an API response;
  4. inspect the result visually;
  5. install the reviewed asset into site/assets/;
  6. refresh site/SHA256SUMS;
  7. preview site/ locally and verify all referenced assets;
  8. keep English and Vietnamese public copy synchronized;
  9. avoid describing visual examples as model-quality benchmarks.

Releases and main

The initial public release is v1.0.0.

Tagged releases are historical snapshots. The main branch may contain newer visual or documentation improvements after a release while the existing release tag remains unchanged.

License

Repository code and documentation are released under the MIT License.

Third-party, public-domain, and CC0 assets retain their own provenance and licensing as documented in assets/provenance.json.

About

Bilingual visual showcase of real outputs from the Rails 8 AI Image Processing API: BiRefNet, MobileSAM, and libvips.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages