An open API service indexing awesome lists of open source software.

https://github.com/gaoux/oct-diagnosis-backend

is a Django-based backend for an Optical Coherence Tomography (OCT) diagnostic system. It provides API endpoints for image processing, classification, and data management to assist ophthalmologists in diagnosing retinal conditions.
https://github.com/gaoux/oct-diagnosis-backend

django oct

Last synced: about 2 months ago
JSON representation

is a Django-based backend for an Optical Coherence Tomography (OCT) diagnostic system. It provides API endpoints for image processing, classification, and data management to assist ophthalmologists in diagnosing retinal conditions.

Awesome Lists containing this project

README

          

# ๐Ÿ“ฆ OCT-Diagnosis-Backend

## ๐Ÿง  Overview

OCT-Diagnosis-Backend is a Django-based backend for an Optical Coherence Tomography (OCT) diagnostic system. This backend provides RESTful API endpoints to handle image uploads, process medical images, and return AI-driven diagnostic insights.

## ๐Ÿ”— Related Repositories

- **Frontend (React + Vite)**
[https://github.com/Gaoux/OCTsense](https://github.com/Gaoux/OCTsense)

- **AI Model (Hugging Face โ€“ OCT Classification)**
[https://huggingface.co/gaoux/OCT_class](https://huggingface.co/gaoux/OCT_class)

## โœจ Features

- Image upload and preprocessing
- Deep learning model inference for classification
- User authentication and role-based access
- Database for storing diagnostic results
- API endpoints following RESTful architecture

## ๐Ÿš€ Installation & Development with Docker Compose

This project uses Docker Compose for development and deployment.

### ๐Ÿณ What Docker Compose Does

- Sets up a Django backend (`web` service)
- Sets up a PostgreSQL database (`db` service)
- Links both containers via a shared network
- Mounts local project files into the container
- Exposes Django at [http://localhost:8000](http://localhost:8000)

### ๐Ÿ“ How to Set It Up

#### 1. Clone the Repository

```bash
git clone https://github.com/gaoux/OCT-diagnosis-backend.git
cd OCT-diagnosis-backend
```

#### 2. Create a `.env` file

You can copy the provided `.env.example`:

```bash
cp .env.example .env
```

Or manually create your own `.env` with the structure of the `env.example` file.

#### 3. Build the Docker Images

```bash
docker-compose build --no-cache
```

#### 4. Run the Project

```bash
docker-compose up
```

Django will be available at:
[http://localhost:8000](http://localhost:8000)

### ๐Ÿงน Clean Up (Remove Volumes and Containers)

To stop and clean the environment, including database volumes:

```bash
docker-compose down -v
```

> โš ๏ธ Warning: This will delete all PostgreSQL data.

---

## ๐Ÿ“ฆ Keeping Dependencies Up to Date

If you or any team member installs or modifies dependencies inside the environment, they must update the `requirements.txt` file with:

```bash
pip freeze | grep -vE ' @ file://|^-e|pywin32|win32|colorama|pypiwin32|tensorflow-intel' > requirements.txt
```

This ensures clean, cross-platform, Docker-friendly dependencies.

---

## ๐Ÿ“‚ Project Structure

- `docker-compose.yml`: Defines services for Django and PostgreSQL
- `requirements.txt`: pip dependencies
- `environment.yml`: Defines the Conda environment (only if working outside Docker)
- `manage.py`, `settings.py`: Django backend
- `.env`: Environment variables for DB and Django setup

---

## ๐Ÿง  AI Model Integration

The backend integrates a deep learning model to classify OCT (Optical Coherence Tomography) images into four diagnostic categories. This model is based on a Keras-compatible architecture (e.g., Xception), trained to assist in ophthalmological pre-diagnosis.

## ๐Ÿ“ฌ API Endpoints

### ๐Ÿ‘ค User Endpoints

| Method | Endpoint | Description |
| ------ | ---------------------------- | ---------------------------- |
| POST | `/api/users/register/` | Register a new user |
| POST | `/api/users/login/` | Log in and obtain JWT token |
| POST | `/api/users/reset-password/` | Reset password using a token |

---

### ๐Ÿ›ก๏ธ Admin Endpoints

| Method | Endpoint | Description |
| ------ | ------------------------ | --------------------------------- |
| POST | `/api/users/register/` | Register a new user |
| GET | `/api/users/users/` | List all users |
| GET | `/api/users/users//` | Get user details |
| PATCH | `/api/users/users//` | Update user information |
| DELETE | `/api/users/users//` | Delete a user |
| POST | `/api/oct/upload-model/` | Upload or replace the `.h5` model |

---

### ๐Ÿ“„ Report Endpoints

| Method | Endpoint | Description |
| ------ | -------------------------------- | --------------------------------------- |
| POST | `/api/reports/create/` | Create a new report |
| GET | `/api/reports/history/` | List reports for the authenticated user |
| GET | `/api/reports/` | List all reports (admin only) |
| GET | `/api/reports//` | Get report details |
| PATCH | `/api/reports//update/` | Update report comments |
| DELETE | `/api/reports//delete/` | Delete a report |
| GET | `/api/reports//image/` | Download image associated with a report |
| GET | `/api/reports/summary/` | Get summary of reports (statistics) |

---

### ๐Ÿค– AI Prediction Endpoint

| Method | Endpoint | Description |
| ------ | ------------------- | ------------------------------ |
| POST | `/api/oct/predict/` | Run prediction on an OCT image |

> **Note:** All endpoints (except login, register and reset-password) require JWT authentication.

---

## ๐Ÿ“ License

This project is licensed under the GPL-3.0 license.