Skip to content

asrfz/GoFish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GoFish v2.0 - Unified Fishing Application

AI-Powered Fish Identification, Location Finding, and Safety Guide

Demo Video: https://www.youtube.com/watch?v=4fE4-DNuJDM

Features

πŸŽ₯ Fish Scanner

  • 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

πŸ—ΊοΈ Fishing Spots Finder

  • 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 & Recipes

  • 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

Architecture

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

Installation

1. Clone Repository

git clone https://github.com/asrfz/GoFish.git
cd GoFish

2. Install Python Dependencies

pip install -r requirements.txt

Key packages:

  • fastapi - Web framework
  • motor - Async MongoDB
  • torch, torchvision - Deep learning
  • sentence-transformers - Vector embeddings (CLIP)
  • httpx - Async HTTP for weather API

3. Install Frontend Dependencies

cd frontend
npm install
cd ..

Key packages:

  • next 16.1 - React framework
  • react-webcam - Camera integration
  • maplibre-gl - Map rendering
  • tailwindcss - Styling

4. Configure Environment

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:8000

5. Download Models

The 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 pull

If 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.py

Running the Application

Start Backend (Terminal 1)

python app.py

Expected 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

Start Frontend (Terminal 2)

cd frontend
npm run dev

Expected 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

Access Application

API Endpoints

Fish Scanner

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"
}

Fishing Spots

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
      }
    },
    ...
  ]
}

Species List

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",
    ...
  }
}

Safety & Recipes

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": {...}
}

Health Check

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
}

Development

Project Structure Details

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 dashboard
  • FishScanner.tsx - Webcam + file upload
  • FishingMap.tsx - Spot finder with weather
  • SafetyGuide.tsx - Safety info + recipes

Adding New Features

  1. New API Endpoint:

    @app.get("/api/new-feature")
    async def new_feature():
        return {"data": "value"}
  2. New Frontend Component:

    export default function NewComponent() {
        return <div>Component here</div>;
    }
  3. Database Model: Add to MongoDB collections in seed_db.py

Database

MongoDB Collections

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

Vector Search

  • CLIP ViT-B-32 embeddings (512 dimensions)
  • Used for semantic image matching
  • Falls back to manual cosine similarity if vector index unavailable

Performance

Fish Scanner

  • Model: ResNet50 (94% accuracy on test set)
  • Speed: ~200ms per scan (CPU), ~50ms (GPU)
  • Accuracy: 92% on live test data

Fishing Spots

  • Data: 1,247 Ontario locations
  • Weather: Real-time from Open-Meteo (cached per region)
  • Score Calc: <100ms per 50 spots

Frontend

  • Framework: Next.js 16 (modern React)
  • Bundle: ~300KB gzipped
  • Load Time: <2s on 3G

Troubleshooting

Models Not Loading

# Check file exists
ls -la fish-scan/models/

# Download via Git LFS
git lfs pull

# Or retrain
python fish-scan/train_fish_model.py

MongoDB Connection Failed

# Check connection string in .env
# Whitelist your IP in MongoDB Atlas
# Test connection:
python -c "import pymongo; pymongo.MongoClient('YOUR_MONGO_URL').server_info()"

Frontend Can't Connect to Backend

# Check backend is running
curl http://localhost:8000/api/health

# Check CORS in app.py
# Ensure NEXT_PUBLIC_API_URL is set correctly

CUDA/GPU Issues

# Force CPU
export CUDA_VISIBLE_DEVICES=""
python app.py

# Check CUDA
python -c "import torch; print(torch.cuda.is_available())"

Contributing

  1. Create feature branch: git checkout -b feature/new-feature
  2. Make changes and test
  3. Commit: git commit -m "Add new feature"
  4. Push: git push origin feature/new-feature
  5. Create Pull Request

License

MIT License - See LICENSE file

Support

Credits

  • 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! 🎣

About

Won @ DeltaHacks!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •