CoolFace
Apppublic

sanjay-genai/Tiles

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes
App README

TilesView AI - Room Upload Validation System

Production-grade hybrid AI backend for validating room uploads before Tilesview visualization.

Core Design

  • —Deep learning semantic understanding: CLIP ViT model for object/scene intent.
  • —Classical CV scoring: edge density, grid regularity, color consistency.
  • —Rule engine: Tilesview room-upload policy.
  • —Explainable output: deterministic reason + user message.

Active Business Policy

  • —Default mode is room_upload.
  • —Accept only real indoor room photos with visible wall or floor surfaces.
  • —Reject product close-ups, samples, screenshots, plans, drawings, and unrelated objects.
  • —Product design validation is a separate workflow and is not the default behavior in this app.

Strict 14-Step Pipeline

  1. 1.Input validation (blank/corrupted/too-small/low-information rejection).
  2. 2.Preprocessing (224x224 semantic path, 64x64 CV path).
  3. 3.Semantic understanding (tile, room, furniture, object, outdoor, invalid_scene).
  4. 4.Scene validation.
  5. 5.Tile relevance check.
  6. 6.Classical CV feature analysis.
  7. 7.Semantic confidence extraction.
  8. 8.Fusion score computation: model_score = 0.5*semantic + 0.2*edge + 0.2*grid + 0.1*color
  9. 9.Final classification mapping.
  10. 10.Multi-label tagging.
  11. 11.Verdict engine: Valid only if indoor/tile-applicable and model_score >= 0.5.
  12. 12.Reason generation.
  13. 13.Thumbnail class generation.
  14. 14.Mandatory user-facing message.

Strict JSON Contract

json
{
  "classification": "",
  "labels": [],
  "confidence": 0.0,
  "edge_score": 0.0,
  "grid_score": 0.0,
  "color_score": 0.0,
  "model_score": 0.0,
  "verdict": "Valid / Invalid",
  "reason": "",
  "thumbnail_class": "",
  "user_message": ""
}

confidence, edge_score, grid_score, color_score, and model_score are all in the range [0.0, 1.0].

Run Locally

Install dependencies:

bash
pip install -r requirements.txt

Run FastAPI backend:

bash
uvicorn api:app --host 0.0.0.0 --port 8000

Call API:

bash
curl -X POST "http://localhost:8000/analyze" \
  -H "accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -F "file=@/path/to/image.jpg"

Inspect the active backend policy:

bash
curl "http://localhost:8000/policy"

Run Gradio demo:

bash
python app.py

Run single-image CLI prediction:

bash
python predict.py "/path/to/image.jpg"

Hugging Face Deployment

For API deployment on Hugging Face:

  1. 1.Create a Docker Space.
  2. 2.Push this repository as-is (includes Dockerfile).
  3. 3.Space will serve FastAPI at port 7860.
  4. 4.Use POST /analyze with multipart image file input.

Or deploy directly from local machine:

bash
set HF_TOKEN=hf_xxx
python deploy_to_hf_space.py --username YOUR_HF_USERNAME --space-name tilesview-ai-validator

Evaluation

bash
python evaluation/evaluate.py --images-dir "../data set" --manifest data/dataset_manifest.json

Results are saved to evaluation/results/eval_results.json.