API Key not working for license plate example
Running the code below from the license plate recognition example, I get the following error:
UnauthorizedError: Unauthorized. Please check your API key and API secret is correct.
Response detail:
{'content_length': 107,
'data': {'data': {},
'errorCode': 'UNAUTHORIZED',
'message': 'Failed to find user record with apiKey: '
'***'},
'headers': {'Date': 'Thu, 24 Aug 2023 19:11:12 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '107', 'Connection': 'keep-alive', 'Access-Control-Allow-Credentials': 'true', 'Vary': 'Origin'},
'reason': 'Unauthorized',
'request': <PreparedRequest [POST]>,
'status_code': 401,
'uri': 'https://app.staging.landing.ai/ocr/v1/detect-text?device_type=pylib&runtime=notebook&lib_version=0.2.23'}I’ve confirmed that the provided key is the one I have in my account. Do I need to use a different key fore OCR? (I’m in the free trial, if that matters.)
from landingai.predict import OcrPredictor
import PIL.Image
api_key_personal = os.getenv("LANDINGAI_PI_KEY_PERSONAL")
ocr_predictor = OcrPredictor(api_key=api_key_personal)
ocr_preds = []
overlayed_ocr = []
print(cropped_imgs[0])
for frame in cropped_imgs:
for plate in frame:
ocr_pred = ocr_predictor.predict(plate)
ocr_preds.append(ocr_pred)
overlay = visualize.overlay_predictions(ocr_pred, plate)
overlayed_ocr.append(overlay)
print(ocr_preds)
for frame, ocr_pred in zip(overlayed_ocr, ocr_preds):
if len(ocr_pred) == 0:
continue
display(frame)
for text in ocr_pred:
print(text.text)