CoolFace
Apppublic

arnnv/xray-classification

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
App README

MediSync Backend

This is the backend service for MediSync, providing API endpoints for medical image analysis and report generation using AI models.

Prerequisites

  • Python 3.10 or higher
  • pip (Python package manager)
  • Docker (optional, for containerized deployment)

Project Structure

backend/
├── api.py              # Main API endpoints
├── app.py             # FastAPI application setup
├── predict.py         # Prediction logic
├── langgraph_agent.py # LangGraph agent implementation
├── requirements.txt   # Python dependencies
├── Dockerfile        # Docker configuration
├── weights/          # Directory for model weights
└── .env             # Environment variables

Setup Instructions

1. Local Development Setup

  1. 1.Create and activate a virtual environment (recommended):
bash
   python -m venv venv
   # On Windows
   .\venv\Scripts\activate
   # On Unix or MacOS
   source venv/bin/activate
  1. 1.Install dependencies:
bash
   pip install -r requirements.txt
  1. 1.Set up environment variables:
  • Create a .env file in the backend directory
  • Add required environment variables:
     GOOGLE_API_KEY=your_google_api_key_here
  1. 1.Download model weights:
  • Create a weights directory in the backend folder
  • Download the required model weights and place them in the weights directory
  1. 1.Run the development server:
bash
   python app.py

The server will start on http://localhost:7860

2. Docker Setup

  1. 1.Build the Docker image:
bash
   docker build -t medisync-backend .
  1. 1.Run the container:
bash
   docker run -p 7860:7860 --env-file .env medisync-backend

API Endpoints

The backend provides the following main endpoints:

  • POST /predict: Upload and analyze medical images
  • POST /generate-report: Generate medical reports based on analysis
  • Additional endpoints are documented in api.py

Dependencies

Key dependencies include:

  • TensorFlow (2.10.x)
  • LangChain & LangGraph for AI processing
  • FastAPI for API endpoints
  • Google Generative AI for report generation
  • Additional dependencies listed in requirements.txt

Environment Variables

Required environment variables:

  • GOOGLE_API_KEY: API key for Google's Generative AI services

Development Guidelines

  1. 1.Code Structure:
  • api.py: Contains all API endpoint definitions
  • predict.py: Handles image processing and model predictions
  • langgraph_agent.py: Implements the LangGraph agent for report generation
  1. 1.Adding New Features:
  2. 2.Add new endpoints in api.py
  3. 3.Implement corresponding logic in appropriate modules
  4. 4.Update requirements.txt if new dependencies are added

Troubleshooting

Common issues and solutions:

  1. 1.Model weights not found:
  • Ensure model weights are properly placed in the weights directory
  • Check file permissions
  1. 1.API key issues:
  • Verify .env file exists and contains valid API key
  • Check environment variable loading in application
  1. 1.Dependencies issues:
  2. 2.Try removing the virtual environment and recreating it
  3. 3.Update pip: pip install --upgrade pip
  4. 4.Install dependencies one by one if bulk installation fails