Skip to content

Godwinlinus/medgemma-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MedGemma Medical AI Assistant

A Python application that provides an easy-to-use interface for Google's MedGemma model, a specialized AI model for medical question answering and healthcare assistance.

Features

  • 🏥 Medical question answering using Google's MedGemma model
  • 💻 Interactive command-line interface
  • 🔧 Single question mode for automation
  • 🚀 GPU acceleration support (CUDA)
  • 🔐 Secure Hugging Face authentication

Prerequisites

  • Python 3.8+
  • Hugging Face account with access to MedGemma models (see below)
  • Sufficient RAM/VRAM (at least 16GB recommended for 4B model)

Getting Access to MedGemma

MedGemma models are gated and require approval from Google. To get access:

  1. Visit the MedGemma model page
  2. Click "Request access" and fill out the form
  3. Wait for approval (may take a few days)
  4. Once approved, your Hugging Face token will work with the model

Alternative Models

If you don't have access to MedGemma yet, you can use alternative open medical models:

  • medicalai/ClinicalBERT - Clinical text understanding
  • Cannae-AI/MedicalLlama3.2-vision-11B-IT - Medical vision model
  • Intelligent-Internet/II-Medical-8B - General medical assistant

Use these with: python medgemma_assistant.py --model medicalai/ClinicalBERT

Installation

  1. Clone this repository:
git clone <your-repo-url>
cd medgemma-project
  1. Create and activate a virtual environment:
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up your Hugging Face token:
    • Copy venv/.env.local to .env in the project root
    • Or set the HF_TOKEN environment variable
    • Or modify the .env.local file with your token

Quick Start

  1. Test the setup: python demo.py
  2. Get MedGemma access (see prerequisites)
  3. Run the assistant: python medgemma_assistant.py
  4. Try examples: python example.py

Usage

Testing Setup

python demo.py

This will verify that your environment is properly configured.

Interactive Mode

python medgemma_assistant.py

Single Question Mode

python medgemma_assistant.py --question "What are the symptoms of diabetes?"

Advanced Options

# Use CPU instead of GPU
python medgemma_assistant.py --device cpu

# Use a different model (if available)
python medgemma_assistant.py --model google/medgemma-4b-it

Model Information

  • Model: MedGemma-4B-IT (Instruction Tuned)
  • Provider: Google
  • Purpose: Medical question answering and healthcare assistance
  • Size: ~8GB (4B parameter model)

Important Notes

⚠️ Medical Disclaimer: This tool is for educational and research purposes only. Always consult qualified medical professionals for actual medical advice and treatment decisions.

🔒 Privacy: Be careful with sensitive medical information. The model responses should not be considered as medical advice.

Troubleshooting

Common Issues

  1. "Authentication failed"

    • Ensure your Hugging Face token is valid and has access to MedGemma
    • Check that the token is properly set in .env.local
  2. "CUDA out of memory"

    • Use --device cpu to run on CPU
    • Or use a machine with more VRAM
  3. "Model download failed"

    • Check your internet connection
    • Ensure you have sufficient disk space (~4GB)

Performance Tips

  • Use GPU acceleration for faster responses
  • For CPU-only machines, consider using smaller quantized models
  • Close other applications to free up memory

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Google for the MedGemma model
  • Hugging Face for the transformers library
  • The open-source AI community

Quick Demo Instructions (Hackathon)

This repo includes a demo-friendly fallback so you can present without gated HF access.

  • Use the included run_demo.ps1 to run the server in mock/demo mode (Windows PowerShell):
# create venv if needed
python -m venv venv
.\venv\Scripts\Activate.ps1
pip install -r requirements.txt

# build frontend (if you edit it)
cd frontend\ai_diagnostic_assistant
npm ci --legacy-peer-deps
npm run build
cd ..\..

# run demo (mock responses)
.\run_demo.ps1
  • To use real Hugging Face inference (if you have access to the gated model): set HUGGINGFACEHUB_API_TOKEN in your environment before running. The server will try local -> HF -> mock automatically.

Supported upload types for demo: txt, png, jpg, jpeg, gif, dcm, pdf.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors