This creates a Cloud Function that handles Image Moderation API and Compression endpoint. The files that should be uploaded to the Cloud Function are already created, this just shows how to set up the Cloud Function.
!IMPORTANT! For this to work properly, you must enable the Cloud Vision API from GCP.
-
Click Create Function
-
Choose a name and region for the serverless function to be run (Belgium is preferred)
-
Leave trigger type as default and check
Allow unauthenticated invocations
-
Adjust Runtime etc. according to your needs (Concurrency and number of instances are important)
-
Click Next
-
You should see the function creation screen now. Choose
Python 3.11
as runtime from the dropdown , modify the entry point tocompress_and_check_image
, and updatemain.py
andrequirements.txt
with the files provided under the src folder in this directory -
Click deploy, then copy the access URL for the function. Make sure to note it down