A Final Year Project (FYP) focusing on enhancing ultrasound imaging quality through state-of-the-art Denoising Diffusion Probabilistic Models (DDPMs). This project combines cutting-edge deep learning techniques with medical imaging to improve diagnostic precision and image clarity.
UltraDiffusion addresses the critical challenge of noise in ultrasound imaging, particularly speckle noise and low contrast issues that affect diagnostic accuracy. By leveraging fine-tuned Stable Diffusion models with specialized architectures, this project delivers real-time image enhancement suitable for clinical applications.
- π§ AI-Powered Denoising: Fine-tuned Stable Diffusion with UNet2DCondition architecture
- β‘ Real-time Processing: Optimized with mixed-precision training (FP16) and Hugging Face Accelerate
- π Comprehensive Metrics: PSNR, SSIM, and LPIPS evaluation metrics
- π§ Classical Filters: Gaussian, Median, and Non-Local Means filters for comparison
- π Interactive Web Interface: Modern React-based frontend for easy image processing
- π± Responsive Design: Works seamlessly across desktop and mobile devices
- Framework: React 18 with TypeScript
- Routing: React Router DOM for navigation
- Styling: Tailwind CSS for modern UI design
- Icons: Lucide React for consistent iconography
- Build Tool: Vite for fast development and optimized builds
- Deep Learning: PyTorch with Diffusers library
- Model Architecture: Stable Diffusion v1.5 with custom fine-tuning
- API Framework: Flask with CORS support
- Image Processing: PIL, scikit-image, OpenCV
- Metrics: LPIPS, PSNR, SSIM for quantitative evaluation
- UNet2DConditionModel: Core denoising architecture
- AutoencoderKL: Latent space compression
- CLIPTextModel & Tokenizer: Text conditioning (if applicable)
- DDPMScheduler: Diffusion process scheduling
- Node.js (v16 or higher)
- Python (v3.8 or higher)
- CUDA-compatible GPU (recommended for optimal performance)
- Git for version control
-
Clone the repository
git clone https://github.com/AselInukeHidallearachchi/FYP-IIT-UltraDiffusion.git cd UltraDiffusionFE(V2) -
Install dependencies
npm install
-
Start development server
npm run dev
-
Build for production
npm run build
-
Navigate to the API directory
cd api -
Install Python dependencies
pip install flask flask-cors diffusers transformers torch pillow pyngrok py7zr lpips scikit-image scipy
-
Download the trained model
- The notebook includes automatic model download from MediaFire
- Alternatively, manually download and extract the model files to
./models/trainedModel/
-
Run the Jupyter notebook
jupyter notebook "difapi-version-4-0 (1).ipynb"
- Home Page: Overview of the project and technology features
- Denoise Images: Upload ultrasound images for AI-powered denoising
- Filters: Apply classical denoising filters (Gaussian, Median, Non-Local Means)
- About: Learn more about the project objectives and methodology
-
POST
/denoiser/: Upload image for diffusion-based denoising- Parameters:
image,strength(0.1-1.0),steps(50-200) - Returns: Enhanced image with evaluation metrics
- Parameters:
-
POST
/filters/: Apply classical filters to uploaded image- Parameters:
image - Returns: Filtered images (Gaussian, Median, NLM)
- Parameters:
- PSNR (Peak Signal-to-Noise Ratio): Higher values indicate better quality
- SSIM (Structural Similarity Index): Values closer to 1 indicate better similarity
- LPIPS (Learned Perceptual Image Patch Similarity): Lower values indicate better perceptual similarity
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch- Unit Tests: Component-level testing with Jest and React Testing Library
- Integration Tests: Full application flow testing
- Coverage Reports: Generated in
/coveragedirectory
- Vite Config:
vite.config.ts- Build and development settings - TypeScript:
tsconfig.json- Type checking configuration - Tailwind CSS:
tailwind.config.js- Styling framework setup - ESLint:
eslint.config.js- Code linting rules
- Model Settings: Adjustable strength and diffusion steps
- Device Selection: Automatic CUDA/CPU detection
- CORS Settings: Configured for cross-origin requests
UltraDiffusionFE(V2)/
βββ src/
β βββ components/ # Reusable React components
β β βββ ImageUpload.tsx # File upload component
β β βββ Layout.tsx # Main layout wrapper
β β βββ MetricsLoader.tsx # Loading state for metrics
β βββ pages/ # Page components
β β βββ Home.tsx # Landing page
β β βββ Denoise.tsx # AI denoising interface
β β βββ Filters.tsx # Classical filters interface
β β βββ About.tsx # Project information
β βββ __tests__/ # Test files
β βββ App.tsx # Main application component
β βββ main.tsx # Application entry point
β βββ config.ts # API configuration
βββ api/
β βββ difapi-version-4-0 (1).ipynb # Backend API notebook
βββ notebook/
β βββ Denoicer V5.1 (6).ipynb # Model training notebook
βββ coverage/ # Test coverage reports
βββ package.json # Node.js dependencies
βββ vite.config.ts # Vite configuration
βββ tailwind.config.js # Tailwind CSS configuration
βββ README.md # Project documentation
- Ultrasound images with realistic noise patterns
- Speckle noise augmentation for robust training
- Validation on clinical-quality imaging data
- Base Model: Stable Diffusion v1.5
- Fine-tuning: Custom UNet2D architecture
- Loss Functions: LPIPS perceptual loss + L2 reconstruction
- Optimization: Mixed-precision training with gradient scaling
- Quantitative: PSNR, SSIM scores
- Perceptual: LPIPS distance measurements
- Clinical: Visual quality assessment by domain experts
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Hugging Face for the Diffusers library
- OpenAI for Stable Diffusion methodology
- Medical imaging community for dataset insights
- Academic supervisors and mentors
Note: This project is for academic and research purposes. For clinical applications, please ensure proper validation and regulatory compliance.



