Package: coco2customvision
Coco to Custom Vision (in Azure)A simple utility to upload aCOCO datasetformat to custom vision and vice versa. This can be used to backup your custom vision object detection projects into a storage account and restore it later or use AzureML to create a more custom CV model.Currently the scripts work with Object Detection but can be easily updated to work with Classification.InstallationInstall from pip:pipinstallcoco2customvisionUsageTo export a custom vision project to an Azure storage account use the following:coco2customvisionexport-sk"<storage_account_key>"-sn<storage_account_name>-sc<storage_account_container_name>-cvk<custom_vision_key>-cve<custom_vision_endpoint>-cvp<custom_vision_project_name>coco_dataset_filename.jsonTo import a coco dataset that is located in an Azure storage account container into a custom vision project (the project may not exist yet):coco2customvisionimport-sk"<storage_account_key>"-sn<storage_account_name>-sc<storage_account_container_name>-cvk<custom_vision_key>-cve<custom_vision_endpoint>-cvp<custom_vision_project_name>coco_dataset_filename.jsonYou can get the parameters from:Custom vision: custom_vision_key, custom_vision_endpoint, custom_vision_project_nameAzure portal: storage_account_key, storage_account_name, storage_account_container_nameCode developmentIf you want to contribute to this code base, clone the repo and follow these instructions.Development installationInstall module ineditable/develop mode(-e) and include the development dependencies (the[dev]argument you see) using the following:pipinstall-e.[dev]For tests to complete, you need to configure some secrets. These secrets are retrieved from environment variables. To avoid adding these environment variables in your system, you need to create apytest.inifile based on thepytest.ini.templatetemplate and fill in all needed values. Use the following links to retrieve the corresponding settings:Custom visionAzure storage account.Thepytest.inifile is in.gitignoreto avoid pushing credentials accidentally.To run all tests:python-mpytest.-cpytest.inior use theVSCode Test Explorerto even debug your code.[Optional] Invoking the dev code from command lineIf you installed the module in develop mode you can use it directly as seen in the instructions above. You can also use the module reference, as seen bellow.To export a custom vision project to an Azure storage account use the following:python-msrc.coco2customvisionexport-sk"<storage_account_key>"-sn<storage_account_name>-sc<storage_account_container_name>-cvk<custom_vision_key>-cve<custom_vision_endpoint>-cvp<custom_vision_project_name>coco_dataset_filename.jsonTo import a coco dataset that is located in an Azure storage account container into a custom vision project (the project may not exist yet):python-msrc.coco2customvisionimport-sk"<storage_account_key>"-sn<storage_account_name>-sc<storage_account_container_name>-cvk<custom_vision_key>-cve<custom_vision_endpoint>-cvp<custom_vision_project_name>coco_dataset_filename.jsonCode quality practicesBefore making any commit you can invoke thepre-commit.batfile which does the following:Format the code usingblack:python-mblack.Ensure that there is noflake8error:python-mflake8.Ensure all test pass:python-mpytest.-cpytest.iniEnsuresetup.cfgfile isconsistently formatted:setup-cfg-fmtsetup.cfgPublishing to pypiTo create a release you need to create an annotated tag:gittag-av0.1.0-m"First version of the tool"You can view existing tags and their comments (-n) using:gittag-nRun a build to create the corresponding version artifacts under thedistfolder. Then push them totestpypito verify:pipinstall--upgradetwine
twineupload--repositorytestpypidist/*Verify results in thetest Pypiinstance. You can try installing in a new python environment using:pipinstall--index-urlhttps://test.pypi.org/simple/--extra-index-urlhttps://pypi.org/simplecoco2customvisionIf you decide to make some more changes, you can delete a tag using the following:gittag-dv0.1.0Note: You will not be able to push the same version to the test Pypi instance. As a work around you can increase the prerelease 4th digit e.g. 0.1.0.1.When you are ready push changes to remote and let github actions publish the package to the production Pypi. Just push the tag to GitHub and the CD action will create the release:gitpushorigin--tagsNote that currently the CD process is kicked when you push the tag and it doesn't do the CI part. So make sure your code is passing the CI part before tagging and pushing the tag to GitHub.ReferencesHere is a list of related projects and references to this effort:Custom vision blob connectorpython tool to upload images to custom vision from blob storage.CustomVision.COCOC# tool to train models using a COCO definition file.VoTT2COCOconvertsVoTTjson files to COCO format.Azure cognitive services python SDKCustom vision SDKDescription of the COCO formatList of Python related references:Writing python in VSCodeFixtures in pytestClick arguments parserPackaging projectsDependency managementDocs authoring pack, highly recommended collection of VSCode plugins.