项目作者: MirosTruckstop

项目描述 :
Detect text in images (Google Cloud function)
高级语言: Python
项目地址: git://github.com/MirosTruckstop/mt-photo-analysis-function.git


MT Photo Analysis Cloud Function

Build Status

Setup

Local setup

Requirements

  • Python 3.7+ is installed
  • virtualenv is installed

Install the dependencies

  1. Create a virtual environment: virtualenv --python python3.7 env
  2. Activate virtual environment: source ./env/bin/activate
  3. Install the dependencies: pip install -r requirements.txt

Google Cloud Platform project setup

Requirements

  • A Google Cloud Platform project exists
  • gcloud is installed and initialised
  1. Enable the required APIs

    1. gcloud services enable pubsub.googleapis.com
    2. gcloud services enable cloudfunctions.googleapis.com
    3. gcloud services enable vision.googleapis.com
  2. Create a service account

    1. gcloud iam service-accounts create photo-analysis-function --display-name "photo-analysis-function"
  3. Create a Cloud Pub/Sub Topic: gcloud pubsub topics create photo-analysis-request

Deploy

Deploy the Cloud Function.

  1. GCP_PROJECT=YOUR-PROJECT-ID
  2. WP_HOST=https://YOUR-HOST.ORG
  3. GCP_REGION=europe-west1
  4. GCP_TOPIC=photo-analysis-request
  5. # 'beta' is required to set the service account
  6. gcloud --project ${GCP_PROJECT} beta functions deploy photo_analysis \
  7. --runtime python37 \
  8. --trigger-topic ${GCP_TOPIC} \
  9. --region ${GCP_REGION} \
  10. --set-env-vars WP_HOST=${WP_HOST} \
  11. --service-account photo-analysis-function@${GCP_PROJECT}.iam.gserviceaccount.com