This project was created in order to improve the efficiency of clothing returns. An online shopping platform for sustainable clothing is growing rapidly in terms of purchases, customers, and the unavoidable associated returns. This RESTful API was created to help relieve some of the work load of having to manually categorize clothing orders for returns.
The intention for the design and creation of this application was to have it be completely integrated into the cloud through Azure products. This would provide improved scalability and data protection.
The design goal:
- Create CNN (Convolutional Neural Network) clothing image classification model using TensorFlow tutorial and MNIST clothing dataset with KERAS
- Model to be stored remotely in Azure Blob Storage
- Images to be batch processed every evening at 11pm stored remotely in Azure Blob Storage
- RESTful API developed using Flask, hosted on Azure Web App with Continuous Integration and Continuous Deployment using GitHub Actions.
- Clothing categorization probabilities and most likely category classification stored remotely using Azure SQL Server and Database
- Microsoft Entra ID Security Login for SQL Database
- System Requirements and Dependencies for Containerization
Despite being able to use GitHub Actions to successfully build and deploy the Clothing Refund Flask App, the app is not yet working properly in Azure Web App. I believe it is because I have not yet been able to adjust for the system dependencies required to download the Tensorflow model from Azure Blob Storage, and perhaps there may be additional dependencies to run the ODBC Driver for SQL Server.
While Azure Web App is currently unable to automatically batch process images, solution is currently running on local computer using Microsoft Task Scheduler to send curl request to initiate run.
- Python 3.12 +
- ODBC Driver 18 for SQL Server
- Microsoft Azure Portal Login
Note: Currently if all files were downloaded, access to Azure Blob Storage and Azure SQL Database is not accessible due to Firewall and Security Features. In order to recreate current solution, individual Azure Blob Storage and Azure SQL Database must be created.
- Create local project in VSCODE or preferred IDE
- Download model.ipynb and app.py
- Create Virtual Environment using requirements.txt
pip install -r requirements.txt
-
Run model.ipynb which will create a local file named: 'clothing_model.keras'
-
Log in to Microsoft Azure Portal
-
Create a Resource Group which will contain all resources for the ClothingRefundFlaskApp

-
Create two containers within Azure Storage Account:
-
In app.py update account_key variable (line 20)
- account_key = 'xxxxxxx'
- Create Azure SQL Server and Database to store clothing category probabilities and image classification data. In Security: Make sure to select SQL Server Authentication only and save SQL UserId and SQL Password. Server Name: datascience Database Name: clothingrefund
-
Using Query editor log in with SQL Server Authentication to create two tables to store image predictions and image probabilities.

- Select New Query: From SQL_Scripts folder run query: image_prediction From SQL_Scripts folder run query: Image_Probabilities
-
Update SQL Database access information in app.py Note: Ideally SQL access would not be hardcoded. Originally Microsoft Entra ID was used, however this required manually entering Azure Microsoft ID and Password for every run, limiting automatic deployment.

-
Set up Microsoft Task Scheduler creating a Basic Task to initiate batch processing
Under Actions Tab:
- Select New
- Name: Batch Processing
- Action: Start a Program
- Settings:
- Program/Script: curl
- Add arguments:
commandline curl -X POST "http://127.0.0.1:5000/prediction" -H "Content-Type: application/json"
- Add arguments:
- Triggers tab:
- Daily
- At 23:00 every day
- Satus: Enabled
- Daily
- Run Flask APP locally in python IDE
flask run
Note: In order for Microsoft Task Scheduler to work correctly App must be running in IDE. For demonstration purposes time set to 15:42pm.
Screen Shot of Image Prediction Table in Azure SQL Database
Screen Shot of Image Probabilities Table in Azure SQL Database
-
Finish Project by creating Azure Web App Service
-
Use GitHub Actions for Continuous Integration and Continuous Deployment with YAML file
- Use cron setting in YAML file and gunicorn start-up command to automatically run application at 11pm.















