Spaces:
Sleeping
Sleeping
File size: 966 Bytes
15f423a 7497534 4682866 15f423a 107dc4b 15f423a 107dc4b 15f423a 107dc4b 56a0241 107dc4b 56a0241 9bbf9be 15f423a 107dc4b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import requests
import os
# API endpoint
url = "https://wjbmattingly-kraken-api.hf.space/ocr"
# url = "http://127.0.0.1:8000/process_all"
# Path to the image file
image_path = os.path.join("data", "ms.jpg")
# Prepare the file for upload
files = {'file': ('ms.jpg', open(image_path, 'rb'), 'image/jpeg')}
# Specify the model to use
data = {'model_name': 'catmus-medieval.mlmodel'}
# Send the POST request
response = requests.post(url, files=files, data=data)
# Check if the request was successful
if response.status_code == 200:
# Parse the JSON response
result = response.json()
# The OCR results are directly in result['result']
ocr_results = result['result']
for record in ocr_results:
print(f"Text: {record['text']}")
# print(f"Confidence: {record['confidence']}")
print(f"Bounding Box: {record['bbox']}")
# print()
else:
print(f"Error: {response.status_code}")
print(response.text) |