import requests import os # API endpoint url = "https://wjbmattingly-kraken-api.hf.space/ocr" # 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')} # Send the POST request response = requests.post(url, files=files) # Check if the request was successful if response.status_code == 200: # Parse the JSON response result = response.json() for line in result["result"]["lines"]: print(line) print() else: print(f"Error: {response.status_code}") print(response.text)