--- title: Oil Spill Detection emoji: 🌊 colorFrom: blue colorTo: indigo sdk: docker pinned: false --- # Oil Spill Detection & Monitoring System This is a full-stack AI-driven application that detects oil spills from satellite imagery using a deep learning segmentation model (U-Net). ## System Architecture * **AI/ML**: TensorFlow / Keras (U-Net) * **Backend**: FastAPI (REST API with Python) * **Frontend**: React + Vite + TypeScript (Modern UI) * **Containerization**: Docker & Docker Compose ## Repository Directory Structure * `backend/` - FastAPI predict/health endpoints and Inference Engine * `frontend/` - React Vite App for the UI * `model/` - U-Net architecture, Custom losses, and Training logic * `utils/` - Data loading and augmentation pipelines utilizing `tf.data.Dataset` * `data/` - Holds your images and masks * `notebooks/` - Place to run exploratory code ## Getting Data (Google Drive) Download the dataset using the following Google Drive link provided: `https://drive.google.com/drive/folders/1j35RM-5uZbTOfDv0mBTeRRmOUPvvg28t?usp=sharing` 1. Download the images and masks folders inside it. 2. Place them inside the `./data/` folder in the root directory like so: ``` d:/Oill_SPLIT/data/images/ d:/Oill_SPLIT/data/masks/ ``` ## Local Setup (Without Docker) ### Backend 1. `cd backend` 2. `pip install -r requirements.txt` 3. `uvicorn main:app --reload` The API will be available at `http://localhost:8000` ### Frontend 1. `cd frontend` 2. `npm install` 3. `npm run dev` The React UI will be available at `http://localhost:5173` ## Setup (With Docker) To run the entire suite using Docker: ```bash docker-compose up --build ``` ## Model Training Instructions (Google Colab / Kaggle) You can train the model on Google Colab leveraging the free T4 GPU. 1. Zip the `model/`, `utils/`, and `data/` directories and upload them to Google Drive or directly to Colab/Kaggle. 2. Open a Colab Notebook. 3. Install dependencies: `!pip install tensorflow scikit-learn pillow numpy` 4. Run the training script: ```bash !python model/train.py --data_dir ./data --save_dir ./model/saved_models --epochs 50 --batch_size 16 ``` 5. Once trained, download `oil_spill_unet_best.keras` from `./model/saved_models` and place it in your local folder structure. *(Note: During initial development, if `oil_spill_unet_best.keras` isn't found, the backend will auto-initialize an untrained "stub" model so you can immediately test the UI and API offline).*