-
Notifications
You must be signed in to change notification settings - Fork 1
Installation
This guide provides step-by-step instructions for installing and running the Whales Identification project.
| Software | Version | Purpose |
|---|---|---|
| Python | 3.11.6 | Backend runtime |
| Node.js | ≥16.0 | Frontend build |
| Docker | ≥20.10 | Containerization |
| Docker Compose | ≥2.0 | Multi-container orchestration |
| Git | Any | Version control |
| Poetry | ≥1.5 | Python package manager |
- RAM: Minimum 8GB (16GB recommended for training)
- Storage: ~5GB for models + dependencies
- GPU: Optional (CUDA-compatible for faster inference)
This method provides a complete stack (Frontend + Backend + API Docs) with minimal setup.
git clone https://github.com/0x0000dead/whales-identification.git
cd whales-identificationpip install huggingface_hub# Make script executable (if needed)
chmod +x scripts/download_models.sh
# Download models from Hugging Face
./scripts/download_models.shExpected output:
Downloading model-e15.pt...
✓ Downloaded to models/model-e15.pt (2.1 GB)
Alternative (manual download):
Place models in models/ directory.
docker compose up --buildFirst build may take 10-15 minutes (downloads dependencies, builds images).
Open in browser:
- Backend API: http://localhost:8000/docs (Swagger UI)
- Frontend UI: http://localhost:8080
- Health Check: http://localhost:8000/docs
Expected:
- Swagger UI shows 2 endpoints:
/predict-single,/predict-batch - Frontend displays file upload interface
For development with hot-reload and debugging.
# Navigate to backend directory
cd whales_be_service
# Install Poetry (if not installed)
pip install poetry
# Install dependencies
poetry install
# Install pre-commit hooks
poetry run pre-commit install
# Install OpenCV system dependencies (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install -y libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender-dev libgomp1
# macOS
brew install opencv # Usually not required on macOS
# Download models (from project root)
cd ..
./scripts/download_models.sh
# Start backend (from whales_be_service)
cd whales_be_service
poetry run python -m uvicorn whales_be_service.main:app \
--host 0.0.0.0 --port 8000 --reloadBackend will be available at:
- API: http://localhost:8000
- Docs: http://localhost:8000/docs
# Navigate to frontend directory (from project root)
cd frontend
# Install dependencies
npm install
# Start development server
npm run devFrontend will be available at:
- Dev Server: http://localhost:5173
Production build:
npm run build # Build to frontend/dist
npm run preview # Preview production buildFor quick demonstration without full API setup.
cd research/demo-ui# Install Poetry (if not installed)
pip install poetry
# Install dependencies
poetry install# From project root
cd ../..
./scripts/download_models.sh
cd research/demo-uipoetry run streamlit run streamlit_app.py --server.port=8501 --server.address=0.0.0.0App will be available at:
Alternative demo (with masking):
cd ../demo-ui-mask
poetry install
poetry run streamlit run streamlit_app.py --server.port=8502# From project root
./scripts/download_models.shWhat it does:
- Creates
models/directory - Uses
huggingface-clito downloadmodel-e15.pt(~2.1 GB) - Verifies download integrity
Requirements:
-
huggingface_hubinstalled:pip install huggingface_hub
- Visit baltsat/Whales-Identification
- Download
model-e15.pt(2.1 GB) - Place in
models/directory
- Visit Yandex Disk link
- Download all models
- Place in
models/directory
Directory structure:
whales-identification/
├── models/
│ └── model-e15.pt (2.1 GB)
├── whales_be_service/
├── frontend/
└── research/
# Health check
curl http://localhost:8000/docs
# Single image prediction
curl -X POST "http://localhost:8000/predict-single" \
-H "Content-Type: multipart/form-data" \
-F "file=@path/to/whale_image.jpg"import requests
# Single image
with open("whale_image.jpg", "rb") as f:
response = requests.post(
"http://localhost:8000/predict-single",
files={"file": f}
)
print(response.json())Expected response:
{
"image_ind": "whale_image.jpg",
"bbox": [100, 150, 300, 250],
"class_animal": "a1b2c3d4",
"id_animal": "Humpback Whale",
"probability": 0.95,
"mask": "iVBORw0KGgoAAAANS..."
}- Open http://localhost:8080
- Click "Upload Image"
- Select a whale image
- Verify results display correctly
# From whales_be_service directory
cd whales_be_service
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov=src --cov-report=term --cov-report=html
# View coverage report
open htmlcov/index.html # macOS
xdg-open htmlcov/index.html # LinuxExpected output:
tests/api/test_post_endpoints.py::test_predict_single_success PASSED
tests/api/test_post_endpoints.py::test_predict_batch_success PASSED
...
Coverage: 85%
Cause: Missing OpenCV system dependencies
Solution (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install -y libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender-dev libgomp1Solution (macOS):
brew install opencv # Usually not requiredCause: Hugging Face CLI not installed
Solution:
pip install huggingface_hubVerify:
huggingface-cli --versionCause: Running command from wrong directory
Solution:
# Backend commands must run from whales_be_service/
cd whales_be_service
poetry install
# Frontend commands must run from frontend/
cd ../frontend
npm installCause: Docker images not built
Solution:
# Build images
docker compose build
# Force rebuild (if needed)
docker compose build --no-cacheCause: Models not downloaded to models/ directory
Solution:
# Check models directory
ls -lh models/
# If empty, download models
./scripts/download_models.sh
# Verify model exists
ls -lh models/model-e15.ptCause: Another service using port 8000 or 8080
Solution (macOS/Linux):
# Find process using port
lsof -i :8000
# Kill process
kill -9 <PID>Solution (Windows):
netstat -ano | findstr :8000
taskkill /PID <PID> /FCause: User not in docker group
Solution:
sudo usermod -aG docker $USER
newgrp docker
# Verify
docker psCause: Code doesn't meet quality standards
Solution:
# Auto-fix formatting
poetry run black .
poetry run isort .
# Check linting
poetry run flake8 .
# Run all hooks manually
poetry run pre-commit run --all-files- Usage Guide - Learn how to use the API and frontend
- API Reference - Detailed API documentation
- Contributing - Set up development environment
- FAQ - More troubleshooting tips
Need help? Open an issue or start a discussion.