Loading repository data…
Loading repository data…
luistrinta / repository
An Azure-based project that classifies X-ray images for pneumonia using a custom vision model trained with Python. It leverages Azure Storage for data, an Azure Function with a blob trigger for automatic classification, and stores results in Azure Table Storage.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
This project implements an automated pipeline to classify chest X-ray images into Normal, Viral Pneumonia, or Bacterial Pneumonia, using Azure Cognitive Services - Custom Vision. The pipeline leverages various Azure services for storage, model training/prediction, automation, and result persistence.
Since this is a cloud based project the project structure contemplates the parts that were developed locally and some of the data used.
project-root/
│
├── azure_function/
│ ├── StorageTrigger/
│ │ ├── __init__.py # Main Azure Function logic
│ │ └── function.json # Blob trigger configuration
│ ├── host.json # Azure Functions host settings
│ └── local.settings.json # Local development configuration
│
├── data/ # Training/test/validation image data
│
├── scripts/
│ ├── load_data.py # Uploads labeled images to Custom Vision
│ └── train_model.py # Triggers training on the uploaded data
│
├── requirements.txt # Python dependencies
└── terraform/ # (Planned) Infrastructure as Code setup
| Resource | Purpose |
|---|---|
| Resource Group | Logical container for all related resources |
| Storage Account | Stores training data (train container), trigger input blobs, and classification output (via Table Storage) |
Container: train | Holds labeled image data organized by tag (e.g., normal/image1.jpg) |
Container: uploaded | Container used to upload new image data that will be classified and stored using the Azure Function |
| Azure Custom Vision (Training & Prediction) | Powers model training and inference |
| Table Storage | Stores classification results in a structured, cost-effective format |
| Azure Function (Blob Trigger) | Automatically runs classification when new images are uploaded |
| Application Insights | Monitors logs, errors, and telemetry from the Azure Function |
Data Upload and Tagging
Data Registration The scripts/load_data.py script:
Model Training
Automated Inference An Azure Function (Storage Blob Trigger):
The training data files follow the structure below:
train/
├── normal/
├── viral/
└── bacterial/
Use Azure Storage Explorer, CLI or the Azure portal (Home > Storage Accounts > <your-project-name> > train) to upload your dataset to the train container.
Get into your Custom Vision Portal(https://www.customvision.ai/) and click create new project.
After specifying what type of model you want to create, give it a name and click create.
Ensure you have the required .env file with:
VISION_TRAINING_ENDPOINT=https://<your-training-endpoint>.cognitiveservices.azure.com/
VISION_TRAINING_KEY=<your-training-key>
STORAGE_ACCOUNT_URL=https://<your-storage-account>.blob.core.windows.net
Run the scripts:
cd scripts/
python load_data.py
python train_model.py
Dependencies Add to requirements.txt:
azure-functions
azure-identity
azure-storage-blob
azure-data-tables
msrest
azure-cognitiveservices-vision-customvision
python-dotenv
Set required environment variables in Azure Function App Configuration:
STORAGE_URL: url for your main storage container
TABLE_STORAGE_ENDPOINT: The endpoint for your table storage, inside your storage container
PREDICTION_ENDPOINT: The prediction endpoint created when you publish a trained model.
You can do so via Azure CLI or the Custom Vision portal
PREDICTION_KEY: The key for your prediciton model, same as above.
PROJECT_ID: The unique ID of the project you created inside
Custom Vision Portal or Azure CLI
PROJECT_NAME: The name you gave the project you created inside
Custom Vision Portal or Azure CLI
Function Trigger (function.json)
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "image",
"type": "blobTrigger",
"direction": "in",
"path": "uploaded/{name}",
"connection": "AzureWebJobsStorage"
}
]
}
Deploy via VSCode or Azure CLI.
To deploy through VSCode you can follow the tutorial from the microsoft documentation. If you cannot deploy your function via the VSCode editor try using the following command on your terminal:
Go to Function App > Monitoring > Application Insights > Logs, and use this Kusto query to debug:
traces
| where timestamp > ago(1h)
| where severityLevel >= 2
| order by timestamp desc
With this project I aimed to enhance my skills in the Azure Cloud, through an end-to-end pipeline for image classification. This helped me better understand how the Azure environment works and how different services work togeteher to create a full solution.