This repository contains an Image Segmentation Application built with DeepLabV3, leveraging PyTorch and Streamlit for a seamless and interactive experience. The application processes images to perform segmentation tasks, providing fine-tuned results with performance metrics such as Intersection over Union (IoU).
- DeepLabV3 Model: Utilizes a pre-trained
DeepLabV3-ResNet101model for semantic segmentation. - Interactive Interface: Built with Streamlit, enabling parameter tuning and visualization.
- Customizable Segmentation: Adjust kernel size and iterations for morphological operations.
- IoU Score Calculation: Evaluate segmentation accuracy against ground truth masks.
- Dataset Support: Supports datasets with original images and corresponding no-background masks.
Ensure you have Python 3.8 or higher installed. The required Python libraries can be installed using the provided requirements.txt.
pip install -r requirements.txt-
Clone the repository:
git clone https://github.com/yourusername/image-segmentation-pipeline.git cd image-segmentation-pipeline -
Install dependencies:
pip install -r requirements.txt
-
Run the Streamlit app:
streamlit run image_segmentation_app.py
-
Access the application in your browser at
http://localhost:8501.
- Number of Images: Select the number of images to process and display.
- Kernel Size: Define the size of the kernel for morphological operations.
- Iterations: Specify the number of iterations for refining segmentation masks.
image-segmentation-pipeline/
├── public_hand_dataset/ # Dataset directory (default)
│ ├── [image_id]/
│ ├── original/ # Original images
│ └── no_bg/ # Corresponding no-background masks
├── image_segmentation_app.py # Main application file
├── requirements.txt # Dependencies
└── README.md # Project documentation
The app expects the dataset to be structured as follows:
public_hand_dataset/
├── [image_id]/
│ ├── original/
│ │ ├── image1.jpg
│ │ ├── image2.jpg
│ └── no_bg/
│ ├── image1.jpg
│ ├── image2.jpg
Place your dataset in the public_hand_dataset/ directory or specify a custom path in the code.
load_model(): Loads the pre-trained DeepLabV3 model.load_dataset(dataset_dir): Loads image paths from the dataset.process_images(file_paths, kernel_size, iterations, model): Processes images and applies segmentation.fn_compute_iou(predicted, ground_truth): Computes the IoU score for evaluation.
The app displays the following:
- Original Image: Input image for segmentation.
- Initial Segmentation: Initial segmentation mask with IoU score.
- Fine-Tuned Segmentation: Refined segmentation mask with IoU score.
- Expected Segmentation: Ground truth segmentation mask.
- Python: Primary language for implementation.
- PyTorch: For deep learning model loading and inference.
- Streamlit: For creating an interactive web app.
- OpenCV: For morphological operations and image processing.
- Pillow: For image manipulation and preprocessing.
Contributions are welcome! If you'd like to contribute, please fork the repository and create a pull request.
- DeepLabV3: Pre-trained model from PyTorch's TorchVision library.
- Streamlit: Simplifies building data-driven apps.