{"id":17593716,"url":"https://github.com/antazo/ai-python","last_synced_at":"2026-02-27T03:31:44.732Z","repository":{"id":258192714,"uuid":"870006436","full_name":"antazo/ai-python","owner":"antazo","description":"🐍 Harness AI advanced capabilities in a Pythonic way.","archived":false,"fork":false,"pushed_at":"2024-11-09T20:48:12.000Z","size":545,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-08T04:08:08.347Z","etag":null,"topics":["artificial-intelligence","azure","cognitive-services","computer-vision","docker","dockerfile","github-actions","kubernetes","minikube","pytest","python","selenium-webdriver","swagger","unittest"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/antazo/ai-python-app","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antazo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-09T09:26:37.000Z","updated_at":"2024-11-09T20:56:38.000Z","dependencies_parsed_at":"2024-10-27T20:44:33.655Z","dependency_job_id":"c63cc4b2-9570-48e6-871f-8e5a75ff6767","html_url":"https://github.com/antazo/ai-python","commit_stats":null,"previous_names":["antazo/ai-python"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/antazo/ai-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antazo%2Fai-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antazo%2Fai-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antazo%2Fai-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antazo%2Fai-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antazo","download_url":"https://codeload.github.com/antazo/ai-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antazo%2Fai-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29883703,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T23:51:21.483Z","status":"online","status_checked_at":"2026-02-27T02:00:06.759Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","azure","cognitive-services","computer-vision","docker","dockerfile","github-actions","kubernetes","minikube","pytest","python","selenium-webdriver","swagger","unittest"],"created_at":"2024-10-22T06:12:39.529Z","updated_at":"2026-02-27T03:31:44.701Z","avatar_url":"https://github.com/antazo.png","language":"Python","readme":"# AI with Python (Azure AI)\n\nHarness AI advanced capabilities in a Pythonic way.  The DotNet version of this repository is [here](https://github.com/antazo/ai-dotnet).\n\nA valid subscription is needed for your own endpoints. The project uses virtual environments, continuous integration pipelines, and containerization as optional. This repository is automatically deployed to container registries (Docker Hub and ACR) through GitHub Actions workflows.\n\nCognitive services used (so far):\n\n* Neural Machine Translation (NMT): Translator.\n* Convolutional Neural Networks (CNN): Computer Vision, Face.\n\nTechnologies used: Python, Flask, Pytest, unittest, Selenium, Swagger, GSAP, Docker, Minikube.\n\n## Overview\n\n* [Installation](#installation)\n  * [Virtual Environment (optional)](#virtual-environment-optional)\n  * [Libraries](#libraries)\n* [Azure Portal](#azure-portal)\n* [Deployment](#deployment)\n  * [Using local Web Server](#using-local-web-server)\n  * [Using Dockerfile](#using-dockerfile)\n  * [Using Kubernetes (Minikube)](#using-kubernetes-minikube)\n* [Pushing the images to container registries](#pushing-the-images-to-container-registries)\n  * [Docker Hub](#docker-hub)\n  * [Azure Container Registry (ACR)](#azure-container-registry-acr)\n* [Container registries and GitHub Actions workflow](#container-registries-and-github-actions-workflow)\n  * [CI Docker Hub](#ci-docker-hub)\n  * [CI Azure Container Registry (ACR)](#ci-azure-container-registry-acr)\n* [Resources](#resources)\n  * [Azure](#azure)\n  * [Azure AI](#azure-ai)\n\n## Installation\n\nClone (or fork) this git repository:\n\n```bash\ngit clone https://github.com/antazo/ai-python.git\ncd ai-python\n```\n\n### Virtual Environment (optional)\n\nIf we want to use a virtual environment, we need to invoke the **venv** module, and activate it. In my case, I'm calling it **my_env**:\n\nOn Linux/macOS:\n\n```bash\n# sudo apt-get install -y python3-pip python3-venv # Libraries needed\npython3 -m venv my_venv\nsource ./my_venv/bin/activate\n```\n\nOn Windows:\n\n```powershell\npy -3 -m venv my_venv\n.\\.my_venv\\Scripts\\activate\n```\n\n### Libraries\n\nThis project is using:\n\n```bash\npip install flask flask-swagger-ui python-dotenv requests azure-mgmt-compute\n```\n\n[!Web testing]\nSelenium is not included in the workflow, run it manually.\n\nOptionally, we can automate this process by adding the list of modules to **requirements.txt**. To create one with the current modules installed in our environment:\n\n```bash\npip freeze \u003e\u003e requirements.txt\n```\n\nCreate this file for later use in our Dockerfile or CI pipeline. It should look something like this:\n\n```plaintext\nflask\nflask-swagger-ui\npython-dotenv\nrequests\nazure-mgmt-compute\n\n```\n\nTo install them:\n\n```bash\npip install -r requirements.txt\n```\n\n## Azure Portal\n\nThis application uses a valid subscription to Azure AI Services and Cognitive APIs to be able to use Language, Vision (Computer Vision, Custom Vision, Face), Decision, Speech, Metrics Advisor, and Document Intelligence.\n\nCreate a single resource for all of them, your Keys and Endpoints information must be stored in a **.env** file.\n\nNote that the Translator service uses its own endpoint. Save your key-values like this:\n\n```plaintext\nLOCATION=\nAI_SERVICES_KEY=\nAI_SERVICES_ENDPOINT=\nTRANSLATOR_ENDPOINT=https://api.cognitive.microsofttranslator.com/\n```\n\n## Deployment\n\n### Using local Web Server\n\nSet the environment variables.\n\nOn Linux/macOS:\n\n```bash\nexport FLASK_ENV=development\n```\n\nOn Windows:\n\n```powershell\nset FLASK_ENV=development\n```\n\nRun **app.py**:\n\n```bash\npy app.py\n```\n\nor:\n\n```bash\nflask run -p 80\n```\n\nThis should run the web application on localhost:\n\n\u003chttp://127.0.0.1/\u003e\n\n### Using Dockerfile\n\nTo containerize this application, build the Docker image by using the Dockerfile included:\n\n```bash\ndocker build -t ai-python-app .\n```\n\nRun the image:\n\n```bash\ndocker run -it -p 80:80 ai-python-app\n# -it lets you stop it with Ctrl+C\n```\n\n### Using Kubernetes (Minikube)\n\nStart K8s and login your Docker:\n\n```bash\nminikube start --driver=docker\ndocker login\n```\n\nPoint the shell to Minikube's docker-daemon before building the Docker image:\n\n```bash\neval $(minikube -p minikube docker-env)\n```\n\nIf \"eval\" isn't working, you must be using CMD on Windows. In that case, do it manually:.\n\n```powershell\n\u0026 minikube -p minikube docker-env --shell powershell | Invoke-Expression\n```\n\nBuild the Docker image inside Minikube. Don't forget to login your Docker first:\n\n```bash\ndocker build -t ai-python-app .\n```\n\nApply the Deployment and Service YAML files. Inside **deployment.yaml** you should point to your Docker image (\"image: [DOCKER_USERNAME]/ai-python-app:latest\"):\n\n```bash\nkubectl apply -f static/deployment.yaml # Edit this file before applying!\nkubectl apply -f static/service.yaml\n```\n\nAccess the Flask application:\n\n```bash\nminikube service ai-flask-app-service\n```\n\nTroubleshoot:\n\n```bash\nkubectl get pods # Get the list of pods\nkubectl describe pod ai-flask-app -n default \n\nkubectl get services # Get the list of services\nkubectl describe service ai-flask-app-service\n```\n\n## Pushing the images to container registries\n\n### Docker Hub\n\nTag the Docker image (don't forget to replace [DOCKER_USERNAME]!):\n\n```bash\ndocker tag ai-python-app:latest [DOCKER_USERNAME]/ai-python-app:latest\n```\n\nLog in to your Docker Hub:\n\n```bash\ndocker login\n```\n\nPush the Docker image:\n\n```bash\ndocker push [DOCKER_USERNAME]/ai-python-app:latest\n```\n\nYou can use the image from my Docker Hub for integration tests (the keys are not valid for E2E tests):\n[https://hub.docker.com/repository/docker/antazo/ai-python-app/general](https://hub.docker.com/repository/docker/antazo/ai-python-app/general)\n\n### Azure Container Registry (ACR)\n\nThis repository integrates ACR in the GitHub Actions workflow. All the following steps are already automated in the **ci-acr.yml** file:\n\nLog in to your Azure CLI:\n\n```powershell\naz login\n```\n\nCreate your ACR in your own resource group (replace [AZURE_RESOURCE_GROUP]). My registry will be called **aipython**:\n\n```powershell\naz acr create --resource-group [AZURE_RESOURCE_GROUP] --name aipython --sku Basic\n```\n\nLogin to the ACR we just created:\n\n```powershell\naz acr login --name aipython\n```\n\nShow the ACR login server, and then use it to create a tag:\n\n```powershell\naz acr show --name aipython --query loginServer --output table\n```\n\nIn my case, it's **aipython.azurecr.io**:\n\n```powershell\ndocker tag ai-python-app aipython.azurecr.io/ai-python-app:v1\n```\n\nPush the image to the ACR (this step is not needed in the YAML file):\n\n```powershell\ndocker push aipython.azurecr.io/ai-python-app:v1\n```\n\nList the repository, and the tags:\n\n```powershell\naz acr repository list --name aipython --output table\n# is it \"ai-python-app\"?\naz acr repository show-tags --name aipython --repository ai-python-app --output table\n# is it \"v1\"?\n```\n\nCreate the container. You will also need to check your Access Keys and privileges to be able to replace [ACR_PASSWORD]. The DNS label will be **aidemo**:\n\n```powershell\naz container create \\\n    --resource-group [AZURE_RESOURCE_GROUP] \\\n    --name ai-python-app \\\n    --image aipython.azurecr.io/ai-python-app:v1 \\\n    --cpu 1 \\\n    --memory 1 \\\n    --registry-login-server aipython.azurecr.io \\\n    --registry-username aipython \\\n    --registry-password [ACR_PASSWORD] \\\n    --ip-address Public \\\n    --dns-name-label aidemo \\\n    --ports 80\n```\n\nTry it:\n\n\u003chttp://aidemo.northeurope.azurecontainer.io/\u003e\n\n## Container registries and GitHub Actions workflow\n\n### CI Docker Hub\n\nAll you need to do is add your Docker credentials to secrets:\n\n* DOCKER_USERNAME\n* DOCKER_PASSWORD\n\nNow, enable the workflow.\n\n### CI Azure Container Registry (ACR)\n\nFirst, add these information to your secrets:\n\n* AZURE_RESOURCE_GROUP: Name of your Azure resource group.\n* ACR_USERNAME: The registry admin username.\n* ACR_PASSWORD: The registry password.\n\nCreate a role assignment (RBAC) to be able to pull and push as a **Contributor** (in other cases we would use **acrpull** or  **acrpush** for least privileges):\n\n```powershell\naz ad sp create-for-rbac \\\n    --name \"http://ai-python-sp\" \\\n    --role Contributor \\\n    --scopes /subscriptions/[AZURE_SUBSCRIPTION_ID]/resourceGroups/[AZURE_RESOURCE_GROUP]/providers/Microsoft.ContainerRegistry/registries/aipython \\\n    --sdk-auth \u003e acr-credentials.json\n```\n\nThis will output a JSON to the file **acr-credentials.json** with the rest of information needed for your secrets. Add them to make the workflow work:\n\n* AZURE_CLIENT_ID: The client ID of your Azure service principal.\n* AZURE_CLIENT_SECRET: The client secret of your Azure service principal.\n* AZURE_CREDENTIALS: Azure service principal credentials in JSON format (**acr-credentials.json**).\n\n## Resources\n\n### Azure\n\n[Getting started with Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/functions-get-started)\\\n[Create an Azure storage account](https://learn.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal)\\\n[Create a single database - Azure SQL Database](https://learn.microsoft.com/en-us/azure/azure-sql/database/single-database-create-quickstart?view=azuresql\u0026tabs=azure-portal)\\\n[Use the Azure portal to create a virtual network](https://learn.microsoft.com/en-us/azure/virtual-network/quick-create-portal)\\\n[Create a Windows virtual machine in the Azure portal](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-portal)\\\n[Host a web application with Azure App Service](https://learn.microsoft.com/en-us/training/modules/host-a-web-app-with-azure-app-service/)\\\n[Deploy and run a containerized web app with Azure App Service](https://learn.microsoft.com/en-us/training/modules/deploy-run-container-app-service/)\\\n[Create a container image for deployment to Azure Container Instances](https://learn.microsoft.com/en-us/azure/container-instances/container-instances-tutorial-prepare-app)\\\n[Deploy a container instance in Azure using the Azure portal](https://learn.microsoft.com/en-us/azure/container-instances/container-instances-quickstart-portal)\n\n### Azure AI\n\n[Azure Portal](https://portal.azure.com?azure-portal=true)\\\n[Azure AI Studio](https://ai.azure.com/)\\\n[Vision Studio](https://portal.vision.cognitive.azure.com?azure-portal=true)\\\n[Language Studio](https://language.cognitive.azure.com)\\\n[Document Intelligence Studio](https://formrecognizer.appliedai.azure.com/studio)\\\n[Sample documents](https://aka.ms/mslearn-receipt)\\\n[OneDrive](https://onedrive.live.com)\n\n#### Labs\n\n[Lab Environment Setup](https://microsoftlearning.github.io/AI-102-AIEngineer/Instructions/00-setup.html)\\\n[Azure AI Vision documentation](https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/)\\\n[Create computer vision solutions with Azure AI Vision](https://learn.microsoft.com/en-us/training/paths/create-computer-vision-solutions-azure-ai/)\\\n[Create Translator service](https://learn.microsoft.com/en-us/training/modules/python-flask-build-ai-web-app/5-exercise-create-translator-service)\\\n[Lab files for Azure AI Vision modules](https://github.com/MicrosoftLearning/mslearn-ai-vision)\\\n[Lab 01 - Machine Learning: Explore Automated Machine Learning in Azure Machine Learning](https://microsoftlearning.github.io/mslearn-ai-fundamentals/Instructions/Labs/01-machine-learning.html)\\\n[Lab 02 - Content Safety: Explore Azure AI Services](https://microsoftlearning.github.io/mslearn-ai-fundamentals/Instructions/Labs/02-content-safety.html)\\\n[Lab 11 - Explore an Azure AI Search index (UI)](https://microsoftlearning.github.io/mslearn-ai-fundamentals/Instructions/Labs/11-ai-search.html)\\\n[Lab 12 - Explore Microsoft Copilot in Microsoft Edge](https://microsoftlearning.github.io/mslearn-ai-fundamentals/Instructions/Labs/12-generative-ai.html)\\\n[Explore the components and tools of the Azure AI Studio](https://microsoftlearning.github.io/mslearn-ai-studio/Instructions/01-Explore-ai-studio.html)\\\n[Explore space with Python and Visual Studio Code; inspired by Netflix's Over the Moon](https://learn.microsoft.com/en-us/training/paths/explore-space-using-python/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantazo%2Fai-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantazo%2Fai-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantazo%2Fai-python/lists"}