A comprehensive Streamlit application for Blind Source Separation comparing Independent Component Analysis (ICA) and Principal Component Analysis (PCA) for both audio and image data.
✨ Audio Source Separation
- Upload MP3 or WAV files
- Automatic audio mixture creation (synthetic mixtures for mono files)
- Separate components using ICA and PCA
- Download separated audio components
- View waveforms and spectrograms
- Compare RMS energy statistics
🖼️ Image Source Separation
- Upload up to 3 images (JPG, PNG, BMP, TIFF)
- Automatic image mixing using random mixing matrices
- Separate mixed images using ICA and PCA
- Download separated image components
- Visual comparison grid of all stages
- Performance metrics and statistics
- Python 3.8 or higher
- pip package manager
- Clone or navigate to the project directory:
cd C:\Documents\ICA- Create and activate virtual environment:
python -m venv venv
venv\Scripts\activate.bat- Install dependencies:
pip install numpy matplotlib streamlit librosa soundfile scipy scikit-image scikit-learnRun the Streamlit app:
streamlit run main.pyThe app will open in your default browser at http://localhost:8501
- Select "🎵 Audio Source Separation" from the dropdown
- Upload an MP3 or WAV file
- Adjust parameters (number of components, sample rate)
- View original audio waveform and spectrogram
- Wait for ICA and PCA separation
- Compare results in different tabs
- Download separated audio components
- Select "🖼️ Image Source Separation" from the dropdown
- Upload exactly 3 images
- Adjust image processing size if needed
- Wait for image mixing and separation
- View results in comparison tabs
- Download separated image components
- Best for: Blind source separation, extracting independent signals
- Principle: Finds statistically independent components
- Assumption: Signals have non-Gaussian distributions
- Result: Components often resemble original sources
- Note: Order may differ from originals
- Best for: Dimensionality reduction, data compression
- Principle: Finds orthogonal directions of maximum variance
- Result: Maximizes explained variance
- Limitation: May produce blurred/averaged components
- Use case: Better for noise reduction than source separation
ICA/
├── main.py # Main Streamlit application
├── venv/ # Virtual environment (created locally)
├── README.md # This file
├── requirements.txt # (Optional) Dependencies list
└── ica_outputs/ # Output folder for processed files
convert_mp3_to_wav()- Convert MP3 to WAV formatcreate_audio_mixtures()- Generate synthetic audio mixturesprocess_audio_ica_pca()- Apply ICA and PCA to audioplot_audio_waveform()- Visualize waveformsplot_audio_spectrogram()- Visualize spectrograms
load_and_preprocess_image()- Load and normalize imagescreate_image_mixtures()- Generate mixed imagesprocess_image_ica_pca()- Apply ICA and PCA to imagesnormalize_component()- Normalize output components
- RAM: 2GB minimum (4GB+ recommended)
- Disk Space: 500MB
- Python: 3.8+
- Browsers: Modern browsers (Chrome, Firefox, Edge)
# Ensure venv is activated
venv\Scripts\activate.bat
# Reinstall dependencies
pip install --upgrade pip setuptools wheel
pip install numpy matplotlib streamlit librosa soundfile scipy scikit-image scikit-learn# Check if streamlit is installed
pip show streamlit
# Reinstall if necessary
pip install --force-reinstall streamlit- Ensure audio file is not corrupted
- Try a different audio format
- Reduce sample rate to 22050 Hz
- Upload only 3 images
- Ensure images are RGB or grayscale
- Check image file size (max ~10MB recommended)
✅ For Audio:
- Use WAV files when possible (faster than MP3)
- Larger sample rates increase processing time
- 2-3 components recommended for speed
✅ For Images:
- Start with 256×256 resolution
- Ensure images are diverse for better separation
- Reduce image size for faster processing
| Package | Version | Purpose |
|---|---|---|
| numpy | Latest | Numerical computing |
| matplotlib | Latest | Visualization |
| streamlit | Latest | Web app framework |
| librosa | Latest | Audio processing |
| soundfile | Latest | Audio I/O |
| scipy | Latest | Signal processing |
| scikit-learn | Latest | Machine learning (ICA, PCA) |
| scikit-image | Latest | Image processing |
- ICA works best with multiple observed mixtures (multiple recordings/viewpoints)
- For single mono audio, synthetic mixtures are created for analysis
- Image separation quality depends on mixing matrix properties
- PCA components are ordered by variance, ICA by independence