An AI-powered web application for analyzing X-ray images using NVIDIA's advanced vision and medical language models. This tool provides educational insights and patient-friendly explanations of X-ray findings.
This tool is for educational and informational purposes ONLY. It is NOT a substitute for professional medical advice, diagnosis, or treatment. AI interpretations can have errors or limitations. Always consult with a qualified healthcare professional for any medical concerns or interpretation of your X-rays.
- AI Visual Analysis: Uses Meta's Llama 3.2 90B Vision model for detailed X-ray image analysis
- Patient-Friendly Explanations: Leverages Writer's Palmyra-Med-70B model for easy-to-understand medical explanations
- Medical Q&A Chat: Interactive chat feature for general medical questions
- PDF Report Generation: Download comprehensive reports with analysis and recommendations
- Specialist Finder: Integrated Google search to find relevant medical specialists
- Multi-format Support: Supports JPG, JPEG, and PNG image formats
- Python 3.7 or higher
- NVIDIA API key (required for AI model access)
-
Clone or download the repository
git clone <repository-url> cd Medical_Vision_X-ray
-
Install required dependencies
pip install -r requirements.txt
-
Get NVIDIA API Key
- Visit NVIDIA's API documentation
- Sign up and obtain your API key
-
Start the application
streamlit run Xray_Medical.py
-
Access the web interface
- Open your browser and navigate to
http://localhost:8501
- Open your browser and navigate to
-
Use the application
- Enter your NVIDIA API key in the sidebar
- Upload an X-ray image (JPG, JPEG, or PNG format)
- Click "Analyze X-ray (Vision AI)" for initial analysis
- Click "Get Patient-Friendly Explanation" for simplified interpretation
- Download PDF reports as needed
- Use the chat feature for general medical questions
vlm_demo/
Xray_Medical.py # Main application file
requirements.txt # Python dependencies
README.md # This file
logo.png # Optional logo file
sample_xray.jpg # Optional sample X-ray image
The application requires the following Python packages:
- streamlit: Web application framework
- Pillow: Image processing library
- openai: OpenAI API client (used for NVIDIA API calls)
- fpdf2: PDF generation library
- requests: HTTP library for API calls
Constants (configurable in Xray_Medical.py
)
MAX_ENCODED_IMAGE_SIZE_BYTES
: Maximum image size (770KB)APP_NAME
: Application titleAPP_LOGO_PATH
: Path to logo file (optional)SAMPLE_IMAGE_FILENAME
: Sample X-ray image filename
- Vision Analysis:
meta/llama-3.2-90b-vision-instruct
- Medical Explanations:
writer/palmyra-med-70b
encode_image_to_base64
: Converts images to base64 for API transmissionformat_vlm_output_for_display
: Formats AI analysis output with emojis
generate_xray_report_pdf
: Creates comprehensive PDF reports with analysis
call_llama_3_2_90b_vision_cached
: Calls vision model for X-ray analysiscall_palmyra_med_70b_cached
: Calls medical model for explanationscall_palmyra_chat_cached
: Handles general medical chat
- API keys are not stored permanently
- All processing happens locally except for API calls to NVIDIA
- No medical data is permanently stored
- API Key Errors: Ensure your NVIDIA API key is valid and has access to the required models
- Image Size Issues: Reduce image size if upload fails (max ~580KB original size)
- PDF Generation Errors: Ensure proper image format (JPG, PNG)
The application includes comprehensive error handling for:
- API connection issues
- Image processing errors
- PDF generation failures
- Invalid file formats
This is an educational demonstration project. For improvements or bug fixes:
- Ensure all changes maintain the educational/non-clinical nature
- Test thoroughly with various X-ray image formats
- Maintain proper error handling and user warnings
This project is for educational purposes only. Please respect NVIDIA's API terms of service and usage guidelines.
For technical issues:
- Check the console output for detailed error messages
- Verify API key validity
- Ensure all dependencies are properly installed
- Check image format and size requirements
Remember: This tool is for educational demonstration only. Always consult qualified medical professionals for health-related decisions.