This project is designed to be a sample Azure project using Computer Vision. You can use this to see how Computer Vision works, or as a starter for a project you're creating.
In order to run the site you will need Python installed locally. You can install Python by visiting the Python downloads page.
To use Computer Vision you will need a key for Azure Cognitive Services. We will create this by using az hack create
in Azure Cloud Shell.
-
Navigate to the Azure Portal and authenticate with your account.
-
After the shell opens in the browser, issue the following command to install the
az hack
extension.
az extension add -n hack
- Issue the following command to create an App Service to host your website, an instance of MySQL for data, and a key for Cognitive Services.
az hack create -n signdemo -r python -d mysql -l westus2 --ai
NOTE: The command will add a random set of characters to the name you provide (signdemo in our example). This ensures the name will always be unique.
- Make a note of the COGSVCS_CLIENTURL and COGSVCS_KEY values; you'll be using those in just a few moments.
- Open a command or terminal window. Clone the sample repository.
git clone https://github.com/geektrainer/sign-reader
- Navigate to the folder using a terminal or command window.
cd sign-reader
- Create a virtual environment using Python and install the libraries listed in requirements.txt
# Windows
python -m venv env
.\env\Scripts\activate
pip install -r requirements.txt
# macOS or Linux
python3 -m venv env
. ./env/bin/activate
pip3 install -r requirements.txt
- Open the folder in the code editor of your choice. If you are using Visual Studio Code you can use the command below.
code .
- Add a new file named .env, which is used by dotenv, which simulates environment variables. Add the text below, and then update the placeholders with the values you created in the earlier step.
NOTE: The leading . is required on the file name.
COGSVCS_CLIENTURL=<your url>
COGSVCS_KEY=<your key>
- Run your application!!! Return to the terminal or command window you had previously, and run the application in flask.
flask run
- Navigate to http://localhost:5000. Click Upload, and choose an image (such as the sample.jpg in this repository) which has text. The image and text will be displayed!
Ready to take show your project to the world? If so, the az hack create
utility you used previously will help you out. If you return to the portal shell, you'll notice steps to perform a Git deploy are listed there.