Here’s a complete example that demonstrates how to use supercontrast for OCR:
Copy
from supercontrast import SuperContrastClient, Task, Provider, OCRRequest# Initialize the clientclient = SuperContrastClient(task=Task.OCR, providers=[Provider.GCP])# Create a requestrequest = OCRRequest(image="https://github.com/supercontrast-ai/supercontrast/raw/main/tests/image/test_ocr.png")# Make the request and handle the responseresponse, metadata = client.request(request)# Print the resultsprint(f"Extracted text: {response}")print(f"Metadata: {metadata}")
This example shows how to perform OCR on an image using Google Cloud Platform as the provider. The same pattern can be applied to other tasks and providers supported by supercontrast.For other tasks, see the Tasks section of the documentation.To set up providers, see the Providers section of the documentation.