Skip to content

PROJECT TEMPLATE: Multi-Modal Application

โฑ 1 min readยท๐Ÿ“… Last updated: 2026-10-08

Build applications with vision + language models.

Project Structure

multimodal-app/
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ uv.lock
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ models_config.yaml
โ”‚   โ””โ”€โ”€ app_config.yaml
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ clip.py          # CLIP model
โ”‚   โ”‚   โ”œโ”€โ”€ blip.py          # Image captioning
โ”‚   โ”‚   โ”œโ”€โ”€ llava.py         # LLaVA model
โ”‚   โ”‚   โ””โ”€โ”€ whisper.py       # Speech-to-text
โ”‚   โ”œโ”€โ”€ processors/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ image.py         # Image processing
โ”‚   โ”‚   โ”œโ”€โ”€ audio.py         # Audio processing
โ”‚   โ”‚   โ””โ”€โ”€ video.py         # Video processing
โ”‚   โ”œโ”€โ”€ embeddings/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ image_embedder.py
โ”‚   โ”‚   โ””โ”€โ”€ text_embedder.py
โ”‚   โ”œโ”€โ”€ retrieval/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ image_search.py
โ”‚   โ”œโ”€โ”€ generation/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ captioning.py
โ”‚   โ”‚   โ””โ”€โ”€ vqa.py           # Visual Q&A
โ”‚   โ””โ”€โ”€ api.py               # FastAPI endpoints
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ images/
โ”‚   โ”œโ”€โ”€ audio/
โ”‚   โ””โ”€โ”€ videos/
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ”œโ”€โ”€ app.js
โ”‚   โ””โ”€โ”€ styles.css
โ””โ”€โ”€ tests/
    โ””โ”€โ”€ test_multimodal.py

Features

  • Image-text retrieval
  • Image captioning
  • Visual question answering
  • Speech recognition
  • Cross-modal search

Quick Start

Image-Text Retrieval

from src.models.clip import CLIPModel
from src.retrieval.image_search import ImageSearch

model = CLIPModel("openai/clip-vit-base-patch32")
search = ImageSearch(model, image_database="data/images")

# Text to image
results = search.search("a dog playing in the park", top_k=5)

# Image to text
results = search.search_by_image("query_image.jpg", top_k=5)

Image Captioning

from src.models.blip import BLIPCaptioner

captioner = BLIPCaptioner("Salesforce/blip-image-captioning-base")
caption = captioner.generate("image.jpg")
print(f"Caption: {caption}")

Visual Q&A

from src.models.llava import LLaVAModel

vqa = LLaVAModel("llava-hf/llava-1.5-7b-hf")

answer = vqa.answer(
    image="image.jpg",
    question="What color is the cat?"
)
print(f"Answer: {answer}")

Speech Recognition

from src.models.whisper import WhisperModel

whisper = WhisperModel("openai/whisper-base")

text = whisper.transcribe("audio.wav")
print(f"Transcript: {text}")

API Endpoints

# Image captioning
curl -X POST "http://localhost:8000/caption" \
  -F "image=@image.jpg"

# Visual Q&A
curl -X POST "http://localhost:8000/vqa" \
  -F "image=@image.jpg" \
  -F "question=What is in this image?"

# Image search
curl -X POST "http://localhost:8000/search" \
  -H "Content-Type: application/json" \
  -d '{"query": "sunset on the beach"}'

Processing Pipeline

from src.processors.image import ImageProcessor
from src.processors.audio import AudioProcessor

# Image preprocessing
img_processor = ImageProcessor()
processed = img_processor.preprocess(
    "image.jpg",
    resize=(224, 224),
    normalize=True
)

# Audio preprocessing
audio_processor = AudioProcessor()
processed = audio_processor.preprocess(
    "audio.wav",
    sample_rate=16000,
    duration=30
)

Multi-Modal RAG

from src.generation.multimodal_rag import MultiModalRAG

rag = MultiModalRAG(
    image_encoder="clip",
    text_encoder="sentence-transformer",
    generator="llava"
)

response = rag.query(
    text_query="show me animals",
    image_database="data/animals/"
)

Difficulty: โญโญโญ Advanced

Estimated Time: 10-15 hours

Skills: Multi-modal models, Computer vision, Audio processing