or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

image-annotation.mdindex.mdproduct-search.mdtypes-and-data.md
tile.json

tessl/pypi-google-cloud-vision

Google Cloud Vision API client library for image analysis, OCR, face detection, and machine learning-based visual content recognition.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/google-cloud-vision@3.10.x

To install, run

npx @tessl/cli install tessl/pypi-google-cloud-vision@3.10.0

index.mddocs/

Google Cloud Vision API

A comprehensive Python client library for Google Cloud Vision API that provides image analysis capabilities including object detection, text recognition, face detection, landmark identification, and more. The library offers both synchronous and asynchronous clients with convenient helper methods for common use cases.

Package Information

  • Package Name: google-cloud-vision
  • Language: Python
  • Version: v3.10.2
  • Installation: pip install google-cloud-vision

Core Imports

from google.cloud import vision

Common for image annotation:

from google.cloud.vision import ImageAnnotatorClient, Image, Feature

For product search:

from google.cloud.vision import ProductSearchClient

Basic Usage

from google.cloud.vision import ImageAnnotatorClient, Image

# Initialize the client
client = ImageAnnotatorClient()

# Analyze an image from a URL
image = Image(source={'image_uri': 'https://example.com/image.jpg'})
response = client.annotate_image({'image': image})

# Access detection results
labels = response.label_annotations
faces = response.face_annotations
text = response.text_annotations

# Use convenience methods for specific features
response = client.label_detection(image)
response = client.face_detection(image, max_results=10)
response = client.text_detection(image)

# Analyze local image file
with open('local_image.jpg', 'rb') as image_file:
    content = image_file.read()
    
image = Image(content=content)
response = client.annotate_image({'image': image})

# Batch processing multiple images
images = [Image(source={'image_uri': f'https://example.com/image{i}.jpg'}) 
          for i in range(3)]
requests = [{'image': img, 'features': [{'type_': Feature.Type.LABEL_DETECTION}]} 
           for img in images]
response = client.batch_annotate_images(requests=requests)

for image_response in response.responses:
    print(f"Labels: {[label.description for label in image_response.label_annotations]}")

Architecture

Google Cloud Vision API is organized around two main client types and a rich type system:

  • ImageAnnotatorClient: Primary client for image analysis operations, enhanced with VisionHelpers for convenience methods and single-feature detection methods
  • ProductSearchClient: Specialized client for product catalog management and product-based image search
  • Type System: Comprehensive data types for requests, responses, geometry, annotations, and configuration

The library provides multiple API versions (v1 stable, plus beta versions v1p1beta1 through v1p4beta1) with the main google.cloud.vision module exposing the stable v1 API.

Design Patterns

The library follows several key patterns:

  • Convenience Methods: VisionHelpers provides annotate_image() that auto-detects all features when none specified
  • Single-Feature Methods: Dynamically generated methods like face_detection(), text_detection() for common operations
  • Batch Operations: Support for processing multiple images efficiently
  • Async Support: Full async client implementations for non-blocking operations
  • Flexible Input: Support for image URIs, local files, raw bytes, and file handles

Capabilities

Image Analysis and Annotation

Core image analysis functionality including face detection, object localization, text recognition, landmark detection, logo detection, and image properties analysis. Provides both batch and single-image processing with extensive customization options.

class ImageAnnotatorClient:
    def annotate_image(self, request, *, retry=None, timeout=None, metadata=()) -> AnnotateImageResponse: ...
    def batch_annotate_images(self, requests, *, retry=None, timeout=None, metadata=()) -> BatchAnnotateImagesResponse: ...
    def batch_annotate_files(self, requests, *, retry=None, timeout=None, metadata=()) -> BatchAnnotateFilesResponse: ...
    def async_batch_annotate_images(self, requests, output_config, *, retry=None, timeout=None, metadata=()) -> Operation: ...
    def async_batch_annotate_files(self, requests, *, retry=None, timeout=None, metadata=()) -> Operation: ...
    
    # Single-feature convenience methods (dynamically generated)
    def face_detection(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def landmark_detection(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def logo_detection(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def label_detection(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def text_detection(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def document_text_detection(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def safe_search_detection(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def image_properties(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def crop_hints(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def web_detection(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def product_search(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...
    def object_localization(self, image, *, max_results=None, retry=None, timeout=None, metadata=(), **kwargs) -> AnnotateImageResponse: ...

Image Analysis

Product Search and Catalog Management

Functionality for managing product catalogs and performing product-based image searches. Includes creation and management of products, product sets, and reference images with comprehensive CRUD operations and batch import capabilities.

class ProductSearchClient:
    def create_product_set(self, parent, product_set, product_set_id=None, *, retry=None, timeout=None, metadata=()) -> ProductSet: ...
    def list_product_sets(self, parent, *, page_size=None, page_token=None, retry=None, timeout=None, metadata=()) -> ListProductSetsResponse: ...
    def get_product_set(self, name, *, retry=None, timeout=None, metadata=()) -> ProductSet: ...
    def update_product_set(self, product_set, *, update_mask=None, retry=None, timeout=None, metadata=()) -> ProductSet: ...
    def delete_product_set(self, name, *, retry=None, timeout=None, metadata=()) -> None: ...
    
    def create_product(self, parent, product, product_id=None, *, retry=None, timeout=None, metadata=()) -> Product: ...
    def list_products(self, parent, *, page_size=None, page_token=None, retry=None, timeout=None, metadata=()) -> ListProductsResponse: ...
    def get_product(self, name, *, retry=None, timeout=None, metadata=()) -> Product: ...
    def update_product(self, product, *, update_mask=None, retry=None, timeout=None, metadata=()) -> Product: ...
    def delete_product(self, name, *, retry=None, timeout=None, metadata=()) -> None: ...
    
    def create_reference_image(self, parent, reference_image, reference_image_id=None, *, retry=None, timeout=None, metadata=()) -> ReferenceImage: ...
    def list_reference_images(self, parent, *, page_size=None, page_token=None, retry=None, timeout=None, metadata=()) -> ListReferenceImagesResponse: ...
    def get_reference_image(self, name, *, retry=None, timeout=None, metadata=()) -> ReferenceImage: ...
    def delete_reference_image(self, name, *, retry=None, timeout=None, metadata=()) -> None: ...
    
    def add_product_to_product_set(self, name, product, *, retry=None, timeout=None, metadata=()) -> None: ...
    def remove_product_from_product_set(self, name, product, *, retry=None, timeout=None, metadata=()) -> None: ...
    def list_products_in_product_set(self, name, *, page_size=None, page_token=None, retry=None, timeout=None, metadata=()) -> ListProductsInProductSetResponse: ...
    def import_product_sets(self, parent, input_config, *, retry=None, timeout=None, metadata=()) -> Operation: ...
    def purge_products(self, parent, *, product_set_purge_config=None, delete_orphan_products=None, force=None, retry=None, timeout=None, metadata=()) -> Operation: ...

Product Search

Data Types and Response Objects

Comprehensive type system including request/response objects, annotation results, geometry types, configuration parameters, and enums. Provides strong typing for all API interactions with detailed structured data for analysis results.

# Core annotation types
class AnnotateImageRequest: ...
class AnnotateImageResponse: ...
class BatchAnnotateImagesRequest: ...
class BatchAnnotateImagesResponse: ...

# Detection result types  
class FaceAnnotation: ...
class EntityAnnotation: ...
class LocalizedObjectAnnotation: ...
class TextAnnotation: ...
class SafeSearchAnnotation: ...
class ImageProperties: ...
class WebDetection: ...

# Geometry and positioning
class BoundingPoly: ...
class Vertex: ...
class NormalizedVertex: ...
class Position: ...

# Configuration and parameters
class Feature: ...
class ImageContext: ...
class Likelihood: ...

Types and Data