University of Dubai · AI Lab
Experiment sheet · Campus Parking Lab
Canonical files: huggingface.co/spaces/BuildingTHEITGUY/Campus-Vision-Lab
This Space is the protocol plus downloadable app.py. It does not run the GPU models in the browser.

0. How a run looks

Illustrative figures (not a live capture of a UD lot). Text burned into the pictures may be imperfect; read the captions here.

Figure 1. Local experiment window: lot, time window, stall capacity, photo, YOLO overlay, occupancy report.
Figure 1. Local Gradio window after you run app.py. Left: your lot photo. Right: vehicle boxes. Bottom: count, occupancy, quiet/mixed/peak/stress.
Figure 2. Example overhead lot with vehicle boxes and an occupancy strip.
Figure 2. Example result from a walkway view: boxes on cars, then a one-line readout (lot, time, vehicles / capacity, flag). Your photo will look like your campus, not this drawing.

1. Concept

Peak arrival and class-change windows fill University of Dubai lots. The measurement is: from one still photograph, how many vehicles are visible, and what fraction is that of the stall capacity you assign to that lot?

occupancy_pct = min(100, 100 * vehicle_count / stall_capacity)

vehicle_count is YOLO boxes whose COCO class is car, truck, bus, or motorcycle. stall_capacity is typed by the experimenter (whole lot or a counted subsection).

occupancy_pctflag
< 40Quiet
40–74Mixed
75–89Peak
≥ 90Stress (treat as full / send overflow)

Flags are lab heuristics, not facilities policy. Occlusion is part of the write-up. SmolVLM-500M adds two sentences on how full the lot looks. If caption and count disagree, record both.

2. What this experiment is not

3. Materials (download from Hugging Face first)

ItemGet it from
Experiment files (app.py, requirements.txt, this page) Space tree/main · app.py · requirements.txt
Python 3.11+ python.org or Microsoft Store Python 3.13
Git (for clone) git-scm.com/download/win
huggingface_hub / hf CLI HF Hub CLI
PyTorch CUDA 12.8 pytorch.org/get-started/locally · wheels cu128
YOLOv8 nano ultralytics · docs · yolov8n.pt auto-downloads
SmolVLM-500M-Instruct HuggingFaceTB/SmolVLM-500M-Instruct
Gradio / Transformers gradio.app · transformers
COCO classes Ultralytics COCO detect
Photos Your own UD lot stills or webcam. No gated third-party driving sets.

4. Procedure — files from Hugging Face, not a private disk path

Do not depend on a path on one lab PC. Clone or download this Space into any working directory, then run there.

  1. Confirm Python and GPU
    python --version
    nvidia-smi
    Need Python 3.11+ and an NVIDIA GPU. The reference machine is an RTX 5070 8 GB with CUDA 12.8 wheels.
  2. Get the experiment from Hugging Face (pick one)
    git clone https://huggingface.co/spaces/BuildingTHEITGUY/Campus-Vision-Lab
    cd Campus-Vision-Lab
    or, without git:
    python -m pip install -U huggingface_hub
    hf download BuildingTHEITGUY/Campus-Vision-Lab --repo-type space --local-dir Campus-Vision-Lab
    cd Campus-Vision-Lab
    Direct files: resolve/main/app.py, requirements.txt.
  3. Virtual environment (once, inside the downloaded folder)
    python -m venv .venv
    .venv\Scripts\python.exe -m pip install --upgrade pip
  4. Install GPU PyTorch, then requirements
    .venv\Scripts\python.exe -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128
    .venv\Scripts\python.exe -m pip install -r requirements.txt
    Plain pip install torch from PyPI may give a CPU wheel.
  5. Check CUDA
    .venv\Scripts\python.exe -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'cpu')"
    On the lab 5070 you should see True NVIDIA GeForce RTX 5070 Laptop GPU.
  6. Start the app
    .venv\Scripts\python.exe -u app.py
    Open the local URL printed in the terminal (usually http://127.0.0.1:7860). First click downloads yolov8n.pt and SmolVLM into the Hugging Face cache on that machine.
  7. Field capture. Choose lot and window first (morning 07:30–09:00, class change, lunch, evening, weekend). Photograph so stalls and empty bays are both visible. Write the capacity you will type.
  8. UI: lot, window, capacity → photo or webcam → Estimate occupancy.
  9. Notebook: datetime, lot, window, capacity, counts, occupancy_pct, flag, caption, occlusion note. Repeat the same lot at a second window.

5. Code you should understand

Measurement in app.py:

VEHICLE = {"car", "truck", "bus", "motorcycle"}

for b in result.boxes:
    name = result.names[int(b.cls.item())]
    if name in VEHICLE:
        counts[name] = counts.get(name, 0) + 1
total = sum(counts.values())
occupancy_pct = min(100.0, 100.0 * total / max(1, stall_capacity))

Detector without Gradio:

from ultralytics import YOLO
from PIL import Image

model = YOLO("yolov8n.pt")
im = Image.open("lot.jpg")
r = model.predict(im, verbose=False)[0]
VEHICLE = {"car", "truck", "bus", "motorcycle"}
n = sum(1 for b in r.boxes if r.names[int(b.cls)] in VEHICLE)
print("vehicles", n, "occupancy%", 100 * n / 40)

Optional caption:

from transformers import AutoProcessor, AutoModelForVision2Seq
import torch
from PIL import Image

mid = "HuggingFaceTB/SmolVLM-500M-Instruct"
proc = AutoProcessor.from_pretrained(mid)
model = AutoModelForVision2Seq.from_pretrained(mid, torch_dtype=torch.float16).cuda()
im = Image.open("lot.jpg")
messages = [{"role": "user", "content": [
    {"type": "image"},
    {"type": "text", "text": "In two sentences: empty, mixed, or packed? No plates. No faces."},
]}]
text = proc.apply_chat_template(messages, add_generation_prompt=True)
inp = proc(text=text, images=[im], return_tensors="pt")
inp = {k: v.cuda() if hasattr(v, "to") else v for k, v in inp.items()}
out = model.generate(**inp, max_new_tokens=80)
print(proc.batch_decode(out, skip_special_tokens=True)[0])

6. Files on this Space

Ethics. Use photos you took of UD lots. No plates. No person ID. Not an enforcement decision.

7. Report checklist

  1. Two photos, same lot, two windows.
  2. Capacity, and how you got it.
  3. Counts, occupancy_pct, flag, caption.
  4. One limitation (occlusion, night, cropped aisle, …).
  5. One follow-up change.

University of Dubai AI Lab · MIT for our app code · Ultralytics, SmolVLM, and PyTorch keep their own licenses.