AI-Powered Fish Identification, Location Finding, and Safety Guide
Demo Video: https://www.youtube.com/watch?v=4fE4-DNuJDM
- Camera Capture: Live webcam scanning or image upload
- PyTorch Classification: ResNet50 deep learning model for accurate species identification
- Vector Search: CLIP embeddings for semantic similarity matching
- Hybrid Mode: Combines both models for maximum confidence
- Ontario Habitat Data: Real fishing locations with GeoJSON mapping
- Species-Specific Scoring: Optimized recommendations by fish type
- Weather Integration: Real-time METAR data from Open-Meteo
- Bite Score Calculator: Weighted algorithm considering habitat, weather, and time of day
- Safety Information: Evidence-based consumption guidance
- Recipe Ideas: Quick preparation methods for caught fish
- Community Alerts: Real-time reports from other anglers
- Mercury Warnings: Health-conscious filtering options
GoFish/
βββ app.py # Unified FastAPI backend
βββ requirements.txt # Python dependencies
βββ .env # Configuration
βββ fish-scan/ # Fish scanner models & images
β βββ models/
β β βββ fish_classifier.pth # PyTorch trained model
β β βββ label_encoder.pkl # Species label encoder
β βββ Fish_Data/raw_images/ # ~3,500 training images
βββ backend/ # Fishing spots API
β βββ fish_hab_type_wgs84_scored.geojson
βββ frontend/ # Next.js UI
β βββ src/
β β βββ app/page.tsx # Main dashboard
β β βββ components/
β β βββ FishScanner.tsx # Camera & upload UI
β β βββ FishingMap.tsx # Spots finder UI
β β βββ SafetyGuide.tsx # Safety & recipes UI
β βββ package.json
βββ Moorcheh/ # Brain API
git clone https://github.com/asrfz/GoFish.git
cd GoFishpip install -r requirements.txtKey packages:
fastapi- Web frameworkmotor- Async MongoDBtorch,torchvision- Deep learningsentence-transformers- Vector embeddings (CLIP)httpx- Async HTTP for weather API
cd frontend
npm install
cd ..Key packages:
next16.1 - React frameworkreact-webcam- Camera integrationmaplibre-gl- Map renderingtailwindcss- Styling
Create/update .env:
# MongoDB Atlas
MONGO_URL=mongodb+srv://YOUR_USER:YOUR_PASSWORD@YOUR_CLUSTER.mongodb.net/?appName=castnet
DB_NAME=castnet
# Server
PORT=8000
# Models
CLIP_MODEL=clip-ViT-B-32
EMBEDDING_DIMS=512
# Frontend
VITE_API_URL=http://localhost:8000The trained models are stored in Git LFS:
# Ensure Git LFS is installed
git lfs install
# Pull LFS files (already done if you cloned with LFS)
git lfs pullIf models are missing, you can train new ones:
# From fish-scan directory
python fish-scan/train_fish_model.py
# Populate database with reference fish
python fish-scan/seed_db.pypython app.pyExpected output:
======================================================================
π Starting GoFish Unified API...
======================================================================
π¦ Loading PyTorch Fish Classifier...
β
PyTorch model loaded!
Classes: 250, Accuracy: 92.34%
π¦ Loading CLIP Model for Vector Embeddings...
β
CLIP model loaded! (Dimensions: 512)
π¦ Loading Fishing Spots Data...
β
Loaded 1,247 fishing spots from GeoJSON
Score range: 0.15 to 89.45
π¦ Connecting to MongoDB...
β
Connected to MongoDB Atlas!
Reference fish: 250, Catches: 42
======================================================================
β
GoFish API Ready!
======================================================================
INFO: Uvicorn running on http://0.0.0.0:8000
cd frontend
npm run devExpected output:
> next dev
β² Next.js 16.1.1
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- event compiled client and server successfully
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs (Swagger UI)
POST /api/scan-fish
Content-Type: application/json
{
"image_base64": "data:image/jpeg;base64,..."
}
Response:
{
"species": "walleye",
"confidence": 0.92,
"pytorch_confidence": 0.94,
"vector_confidence": 0.91,
"method": "hybrid_agree"
}
GET /api/fishing-spots?species=walleye&limit=50
Response:
{
"timestamp": "2026-01-11T...",
"species": "walleye",
"total_spots": 1247,
"returned": 50,
"spots": [
{
"id": "unique_id",
"name": "Lake Name",
"latitude": 44.5,
"longitude": -79.5,
"bite_score": 85,
"status": "Great",
"reasoning": "Prime walleye habitat; Falling pressure...",
"weather": {
"temperature": 14.5,
"pressure": 1008,
"wind_speed": 12
}
},
...
]
}
GET /api/species
Response:
{
"species": ["walleye", "bass", "trout", "pike", "perch"],
"descriptions": {
"walleye": "Best in low light, falling pressure",
"bass": "Active in warm water, dawn/dusk",
...
}
}
POST /api/brain/advise
Content-Type: application/json
{
"species": "walleye",
"spot": "Lake Ontario",
"preferences": {
"avoid_high_mercury": false,
"pregnant": false,
"catch_and_release": false
}
}
Response:
{
"species": "walleye",
"spot": "Lake Ontario",
"edibility_label": "Likely edible",
"safety_summary": [
"Low mercury content - safe for pregnant women",
"...",
],
"recipes": [
{
"title": "Pan-Seared Walleye",
"steps": [...],
"source_snippet": "..."
}
],
"community_alerts": [],
"evidence": {...}
}
GET /api/health
Response:
{
"status": "healthy",
"version": "2.0.0",
"mongodb_connected": true,
"pytorch_model_loaded": true,
"clip_model_loaded": true,
"reference_fish_count": 250,
"catches_count": 42,
"fishing_spots_loaded": 1247
}
Backend (app.py):
- ~1200 lines combining 3 services
- Modular function design for easy maintenance
- Async/await for high concurrency
- CORS configured for localhost development
Frontend Components:
page.tsx- Main tab-based dashboardFishScanner.tsx- Webcam + file uploadFishingMap.tsx- Spot finder with weatherSafetyGuide.tsx- Safety info + recipes
-
New API Endpoint:
@app.get("/api/new-feature") async def new_feature(): return {"data": "value"}
-
New Frontend Component:
export default function NewComponent() { return <div>Component here</div>; }
-
Database Model: Add to MongoDB collections in
seed_db.py
fish_reference
- Stores reference fish data with embeddings
- Used for vector similarity search
- ~250 species baseline
catches
- Logs all scans made by users
- Includes confidence scores and method used
- For analytics and model improvement
- CLIP ViT-B-32 embeddings (512 dimensions)
- Used for semantic image matching
- Falls back to manual cosine similarity if vector index unavailable
- Model: ResNet50 (94% accuracy on test set)
- Speed: ~200ms per scan (CPU), ~50ms (GPU)
- Accuracy: 92% on live test data
- Data: 1,247 Ontario locations
- Weather: Real-time from Open-Meteo (cached per region)
- Score Calc: <100ms per 50 spots
- Framework: Next.js 16 (modern React)
- Bundle: ~300KB gzipped
- Load Time: <2s on 3G
# Check file exists
ls -la fish-scan/models/
# Download via Git LFS
git lfs pull
# Or retrain
python fish-scan/train_fish_model.py# Check connection string in .env
# Whitelist your IP in MongoDB Atlas
# Test connection:
python -c "import pymongo; pymongo.MongoClient('YOUR_MONGO_URL').server_info()"# Check backend is running
curl http://localhost:8000/api/health
# Check CORS in app.py
# Ensure NEXT_PUBLIC_API_URL is set correctly# Force CPU
export CUDA_VISIBLE_DEVICES=""
python app.py
# Check CUDA
python -c "import torch; print(torch.cuda.is_available())"- Create feature branch:
git checkout -b feature/new-feature - Make changes and test
- Commit:
git commit -m "Add new feature" - Push:
git push origin feature/new-feature - Create Pull Request
MIT License - See LICENSE file
- Issues: GitHub Issues
- Docs: This README
- API Docs: http://localhost:8000/docs (Swagger)
- Fish Data: Ontario Ministry of Natural Resources
- Models: PyTorch ResNet50, CLIP ViT-B-32
- Weather: Open-Meteo API
- Framework: FastAPI, Next.js, React
- Database: MongoDB Atlas
GoFish v2.0 - Making fishing smarter, safer, and more successful! π£