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.
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/.
| 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.
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.
| 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 |
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 8080Open:
http://127.0.0.1:8080
If your system exposes Python as python instead of
python3, use that command instead.
This is optional. Use it only when you want to reproduce selected people/animal showcase assets from a running API deployment.
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.
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.
Use the interactive helper:
./scripts/setup_runtime_env.shIt 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.shWhen you are finished:
rm -f /tmp/showcase-e2e.envThe 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.envIf 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.
The current people/animals workflow is intentionally scoped. It does not regenerate every visual on the page.
The runner:
- calls
POST /users/sign_inand extracts the JWT returned by the normal sign-in flow; - calls
POST /images/remove-backgroundfor transparent and neutral-background person outputs; - calls
POST /images/segmentfor person, dog, and horse point/box masks; - uses Pillow locally to create dog/horse selection-preview WebP images from the masks;
- copies the selected generated assets into
site/assets/; - 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.
| 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.
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 SHA256SUMSThe manifest is useful for detecting accidental asset changes and for binding the showcase page to the files that were reviewed.
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.
A typical content update should follow this sequence:
- choose a source asset with clear provenance and redistribution terms;
- record or update the source metadata in
assets/provenance.json; - generate the intended output through the real API when the example is meant to represent an API response;
- inspect the result visually;
- install the reviewed asset into
site/assets/; - refresh
site/SHA256SUMS; - preview
site/locally and verify all referenced assets; - keep English and Vietnamese public copy synchronized;
- avoid describing visual examples as model-quality benchmarks.
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.
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.