Arcade Adventure: Google Cloud ML APIs | GSP037

Solution for Arcade Adventure: Google Cloud ML APIs | GSP037. 1 lab: GSP037. Fast copy-paste commands for Google Cloud.

GSP037 — Detect Labels, Faces, and Landmarks in Images with the Cloud Vision API

Estimated time: 10 minutes

# 🚀 Detect Labels, Faces, and Landmarks in Images with the Cloud Vision API | GSP037 > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created for educational purposes, hands-on practice, and Google Cloud certification preparation. This guide is designed to help learners understand the Cloud Vision API, image analysis, Cloud Storage, API keys, and object access controls through practical exercises. Always attempt the lab yourself first and follow Google Cloud Skills Boost

clear
# Professional ANSI Color Variables
CYAN='\033[1;36m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
RESET='\033[0m'
BOLD='\033[1m'

echo -e "${CYAN}${BOLD}"
echo "   ____       _    _ _             __   ___             "
echo "  / __ \     | |  (_) |           / _| / _ \            "
echo " | |  | |_ __| |__  _| |_  ___   | |_ | | | |_ __ ___  "
echo " | |  | | '__| '_ \| | __| / _ \ |  _|| | | | '_ \ / __| "
echo " | |__| | |  | |_) | | |_ | (_) || |  | |_| | |_) \__ \ "
echo "  \____/|_|  |_.__/|_|\__| \___/ |_|   \___/| .__/|___/ "
echo "                                            | |         "
echo "                                            |_|         "
echo -e "${RESET}"

export PROJECT_ID=$(gcloud config get-value project)
export BUCKET_NAME="${PROJECT_ID}-bucket"

echo -e "${YELLOW}▶ Task 1: Creating API Key for Cloud Vision API...${RESET}"
# Applying the target restriction to prevent security policy errors
gcloud services api-keys create --display-name="Vision-Key" \
    --api-target=service=vision.googleapis.com

echo -e "${BLUE}▶ Task 2: Creating Cloud Storage bucket (gs://${BUCKET_NAME})...${RESET}"
gcloud storage buckets create gs://$BUCKET_NAME
gcloud storage buckets update gs://$BUCKET_NAME --no-uniform-bucket-level-access

echo -e "${YELLOW}▶ Downloading sample images...${RESET}"
curl -s -L -o donuts.png https://raw.githubusercontent.com/Orbit-of-Ops/Labs-Solutions/main/Detect%20Labels%2C%20Faces%2C%20and%20Landmarks%20in%20Images%20with%20the%20Cloud%20Vision%20API/donuts.png
curl -s -L -o selfie.png https://raw.githubusercontent.com/Orbit-of-Ops/Labs-Solutions/main/Detect%20Labels%2C%20Faces%2C%20and%20Landmarks%20in%20Images%20with%20the%20Cloud%20Vision%20API/selfie.png
curl -s -L -o city.png https://raw.githubusercontent.com/Orbit-of-Ops/Labs-Solutions/main/Detect%20Labels%2C%20Faces%2C%20and%20Landmarks%20in%20Images%20with%20the%20Cloud%20Vision%20API/city.png

echo -e "${BLUE}▶ Uploading images to Cloud Storage...${RESET}"
gcloud storage cp donuts.png gs://$BUCKET_NAME/
gcloud storage cp selfie.png gs://$BUCKET_NAME/
gcloud storage cp city.png gs://$BUCKET_NAME/

echo -e "${CYAN}▶ Applying public read access to all images...${RESET}"
gsutil acl ch -u allUsers:R gs://$BUCKET_NAME/donuts.png
gsutil acl ch -u allUsers:R gs://$BUCKET_NAME/selfie.png
gsutil acl ch -u allUsers:R gs://$BUCKET_NAME/city.png

echo -e "\n${GREEN}✓ All infrastructure and checkpoints provisioned successfully! You may now click 'Check my progress' on all tasks in the lab page to receive 100%.${RESET}"