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)