Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

DRP Segmentation

Diabetic retinopathy screening prototype built with FastAPI. The project combines retinal image analysis, segmentation, and LLM-based report generation to produce interpretable outputs for screening workflows.

What is in this repo

  • FastAPI backend with vision and NLP endpoints
  • Retina image segmentation pipeline for vessel and lesion analysis
  • Prompt/template layer for generating structured reports
  • Notebooks for experimentation, training, and evaluation

Repository Layout

DRP_segmentation/
├── notebooks/ # Exploration, training, and evaluation notebooks
├── src/
│ ├── main.py # FastAPI app entry point
│ ├── routes/ # API routes for vision and NLP
│ ├── controllers/ # Application logic
│ ├── engine/ # Image preprocessing and segmentation
│ ├── llm/ # LLM provider and template utilities
│ ├── helpers/ # Settings and shared helpers
│ ├── models/ # Enums and model-related assets
│ └── requirements.txt # App-specific dependencies
├── requirements.txt # Root dependencies for the app
├── Dockerfile # Containerized runtime
└── README.md

Main Capabilities

  • Analyze a retinal image and return an overlay plus a generated report
  • Generate structured NLP outputs from model results
  • Load segmentation weights at startup for vessel and lesion inference
  • Support configurable LLM providers through environment settings

Requirements

  • Python 3.10+
  • A valid Cohere API key if you want to use the LLM-backed report generation
  • Trained model weights placed at the paths expected by src/main.py

Installation

pip install -r requirements.txt

If you are running the application from inside src/, install the dependencies from src/requirements.txt instead.

Configuration

The application reads settings from a .env file through Pydantic settings. At minimum, provide:

APP_NAME=DRP Segmentation
APP_VERSION=1.0.0
GENERATION_BACKEND=cohere
COHERE_API_KEY=your_api_key_here
GENERATION_MODEL_ID=your_model_id_here

Optional tuning values:

INPUT_DAFAULT_MAX_CHARACTERS=2000
GENERATION_DAFAULT_MAX_TOKENS=2000
GENERATION_DAFAULT_TEMPERATURE=0.1
ORGINAL_LANGUGE=ar
DEFAULT_LANGUGE=ar

Run the API

The Docker image starts the service with Uvicorn on port 7860.

uvicorn src.main:app --host 0.0.0.0 --port 7860

API Endpoints

POST /apiv1/vision/analyze

Upload a retinal image and receive:

  • original_image
  • overlay_image
  • report
  • full_prompt

The endpoint rejects non-image uploads.

POST /apiv1/nlp/result/answer

Generates a structured report from sample model results using the configured LLM provider.

Notebooks

The notebooks in notebooks/ are still useful for experimentation and evaluation, but they are no longer the primary way to run the project.

  • 01_disease_segmentation.ipynb - DR grading and preprocessing
  • 02_vessel_segmentation.ipynb - vessel segmentation experiments
  • 03_binary_classification_filter.ipynb - binary DR filtering
  • 04_dr_grading_model.ipynb - grading model work
  • 05_evaluation.ipynb - evaluation experiments
  • 06_gradcam_pipeline.ipynb - explainability pipeline

Data and Models

  • Keep raw datasets outside version control
  • Store processed artifacts separately from source code
  • Place the trained weights where src/main.py expects them before starting the API

Notes

  • The codebase currently mixes API, prompting, and inference concerns, so the README now focuses on how to run and use the service.
  • Several notebook workflows are still useful, but they are historical support material rather than the main entry point.

About

Collaborative repository for advanced image segmentation techniques. Built core Python components, tuned model performance, and maintained project structure.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /