How hanghuacs/finecaption works
Project type and purpose
• Type: Research-focused Vision-Language model with a web demo front-end.
• Purpose:
– Train and evaluate an image-mask-conditional captioning model (FINECAPTION).
– Expose interactive demos via a static website (serving CSS/JS/images) and dataset download.
File structure
Top-level:
• Data/CompositionCap.json.zip – Compressed dataset.
• README.md – Project description and setup instructions.
• static/ – All front-end assets:
– css/ (Bulma framework + custom index.css)
– js/ (bulma-carousel.js, bulma-slider.js, index.js)
No server code is visible here, which implies the web demo may be purely static or served by a simple Python/Flask/Node server elsewhere.
Extract key architectural insights from the README
• Core functionality: Compositional captioning with arbitrary input masks.
• Mask decoding utility in Python.
• Installation script (init.sh) sets up the modeling environment (likely PyTorch, Transformers, etc.).
• No explicit backend framework listed; assume a minimal REST/HTTP interface for demo inference.
Main components
a. Data Layer
– CompositionCap Dataset (Data/CompositionCap.json.zip)
– Preprocessing & Mask-Decoding Module
b. Model Training & Inference Layer
– FINECAPTION training scripts (environment from init.sh)
– Vision-Language model checkpoints (8B parameters)
– Inference API (e.g., Flask or FastAPI service)
c. Frontend Layer
– Static Web Server (e.g., Nginx or GitHub Pages)
– CSS (Bulma + index.css)
– JavaScript (index.js orchestrates carousel, sliders, fetches results)
– Images and videos (teasers, model.pdf)
d. External Services (optional but often present)
– CDN for serving static assets
– GPU Cluster for training/inference
– Logging/Monitoring (e.g., Prometheus/Grafana)
Relationships & interactions
• The Frontend issues HTTP requests to the Inference API, sending:
– High-resolution image
– Binary mask (decoded via the Python mask-decoding utility)
• The Inference API loads the fine-tuned model, runs inference, and returns caption text.
• Model Training Pipeline consumes the raw JSON dataset, preprocesses masks, and produces model checkpoints.
• Static assets (HTML/CSS/JS/images) are delivered by the Web Server or CDN directly to the user’s browser.
• Optionally, logs and metrics are pushed from the Inference API to a Monitoring service.
Architectural patterns & design principles
• Three-Tier Architecture:
– Presentation (Static Frontend)
– Application (Inference API)
– Data (Dataset + Model Weights)
• Separation of concerns:
– Frontend purely handles UI/UX and visual demos.
– Backend encapsulates all ML logic.
– Data layer isolated for reproducibility.
• Modular Mask Decoding: Utility function independent of core model logic.