If you came here for instructions how to start the Web UI (flask API + react widget) to annotate images please see related readme
After setting up the API as above, a new UI is in development at src/t4t-annotation-UI. Contact simra for access to the repo
src/predict_api stands up a small flask app for uploading images and detecting headstamps. Contact simra for a copy of the model weights.
src/model/training folder contains the training code based on AML headstamp annotations. src/AML runs training in AzureML
src/webapp: This app can be used for image capture. It's connected to the prediction API but doesn't predict in real time. It's not connected to the annotation database.
h4g deck is here
You might alo need the Workspace configuration. You can find it by going to the Machine Learning workspace in Azure Portal, then in the overview it's next to the delete button as Download config.json
. Ask a teammate for a copy of this if you don't have access in Azure.
If you export a dataset from AML, some conversion is needed- see convert_coco_urls.py
Some areas to explore:
The following architecture diagram shows the major CartridgeOCR components from a Azure resource and network perspective.
Clone the repository to your local machine (git clone https://github.com/Tech4Tracing/CartridgeOCR.git
)
You will require the following pre-requisites installed.
The environment is going to be provisioned using Terraform scripts. In order to run Terraform, you need to set the environment variables in /terraform/terraform.tfvars.tmpl.
Rename the terraform.tfvars.tmpl
to terraform.tfvars
Edit the terraform.tfvars as required. As resource_name_prefix
and environment
are used in Azure resource names they must be alpha numeric (a-z,0-9)
. The defaults are as follows:
resource_name_prefix = "cartridgeocr"
environment = "dev"
location = "westeurope"
Notice that some resources require a globally unique name, so make sure that resource name prefix makes the generated resource name unique.
Login and select the azure subscription you wish to deploy to:
az login
az account set -s <subscription_name_or_id>
A deployment script automates the deployment process. Run the script to deploy resources to Azure as well as any code. The script will:
terraform apply
provisioning all resources in AzureYou may wish to grant an exception to the webapp folder in Defender settings- running a build churns the malware scanner.
To test the image upload API you can submit an upload request with curl. Replace the myImage.jpg with an image file that you want to upload, and change the URL to the one that has been outputted by the deployment script.
(echo -n '{"filename": "myImage.jpg","filetype":"image/jpeg","data": "'; base64 myImage.jpg; echo '"}') |
curl -H "Content-Type: application/json" -d @- https://api-cartridgeocr-dev.azurewebsites.net/api/image-upload
If you have a data (image) and label datasets that you would like to upload to Azure Storage for training, you can use the upload.sh script after running the deployment script. Script will use the .env file to connect to the right storage account and look for images and labels folders to upload image and label datasets respectively.
To run the training on the AML cluster provisioned in the deployment script, you can run run_training.py from the src folder. Notice that to run training in AML you don't have to run the full requirements.txt file locally, but you would need to pip install azure-ml and azure-ml-core.
pip install azureml-core
python ./AML/run_training.py
https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html
Torchvision todo: