YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Angiographic Vessel Extraction Model This repository contains a neural network model designed to process unsubtracted angiographic images and extract vessel structures. The model is based on a U-Net architecture with attention gates and has been specifically trained to isolate vascular structures from raw angiographic data, providing high-contrast vessel maps for medical analysis.
Model Overview Input: The model takes grayscale unsubtracted angiographic images as input (256x256 resolution). Output: The output is a high-contrast grayscale image highlighting the vessels extracted from the angiographic input, effectively "subtracting" the background to isolate the vascular structures. This model is particularly useful in scenarios where traditional digital subtraction angiography (DSA) may not be feasible or where preprocessing the images before vessel extraction is necessary.
Key Features U-Net Architecture: The model is based on a modified U-Net with residual blocks and attention gates, improving the precision of vessel extraction by focusing on relevant regions in the input images. Trained for Vessel Detection: The model has been trained on a specialized dataset of angiographic images, making it highly accurate for extracting vascular structures. Non-Subtracted Image Processing: Unlike traditional subtraction techniques, this model operates directly on unsubtracted images, making it more versatile for different angiographic scenarios. Model Usage You can use the model in two ways: through Hugging Face’s Inference API or by downloading the model weights and running it locally.
- Inference API (Hugging Face) Use Hugging Face’s Inference API to easily upload an angiographic image and obtain the vessel-extracted result.
python Copy code from PIL import Image import requests from io import BytesIO
Example: Load an image and send it to the model for inference
image_path = "path_to_your_image.jpg" image = Image.open(image_path).convert("L")
Hugging Face pipeline setup
from transformers import pipeline model = pipeline("image-to-image", model="Emilcohen/subtract")
Run inference
output = model(image)
Save or visualize the output
output_image = output[0]["generated_image"] output_image.save("output_vessels.png") 2. Running Locally To run the model locally, you can clone this repository, install the required dependencies, and run the app.py or use the functions from the model script.
bash Copy code
Clone the repository
git clone https://huggingface.co/Emilcohen/subtract cd subtract
Install dependencies
pip install -r requirements.txt
Run the script on an image
python app.py --input path_to_input_image --output path_to_save_output Preprocessing The input image should be preprocessed to match the model's expected format. The following preprocessing steps are applied:
Grayscale Conversion: Convert the input image to grayscale. Resizing: The image is resized to 256x256 pixels. Normalization: The pixel values are normalized to the range [0, 1]. You can preprocess your image with the following example code:
python Copy code from PIL import Image from torchvision import transforms
Load and preprocess the image
image = Image.open('path_to_your_image.jpg').convert('L')
transform = transforms.Compose([ transforms.Resize((256, 256)), transforms.ToTensor(), ])
input_tensor = transform(image).unsqueeze(0) # Add batch dimension Model Performance The model has been trained and validated on a diverse dataset of angiographic images, where it demonstrates strong performance in accurately extracting vascular structures. Here are some general observations:
High Sensitivity: Able to detect small, intricate vessels. High Contrast Output: Produces clean, well-separated vascular structures from complex background patterns. Efficient Processing: Works on unsubtracted images, making it more versatile and easier to apply in real-world medical imaging settings. Applications Medical Imaging: Automated vessel extraction can aid in diagnosis, analysis, and treatment planning in fields such as interventional radiology and cardiology. Real-Time Image Processing: The model can potentially be applied in real-time angiography during surgical procedures, providing immediate feedback without requiring manual image subtraction techniques. Limitations The model currently supports grayscale angiographic images. Future versions could potentially support other modalities or color images. While the model performs well on the dataset it was trained on, it may need fine-tuning for different types of angiograms or imaging conditions. Contributing We welcome contributions to improve the model's accuracy and generalization. If you have new datasets or improvements to the architecture, feel free to open a pull request or reach out.
License This project is licensed under the Apache 2.0 License. You are free to use, modify, and distribute this project, but please give appropriate credit, provide a link to the license, and indicate if changes were made. See the LICENSE file for details.