Predictions API returning [] Even though Roboflow Visualization Returns Multiple Objects

Hi I am using python and my code was working until the last day of my free trial, and then it gave me predictions =

When I upgraded my account, the visualization tool on Roboflow.com started working again. But my API routines still yield an empty set.

And one other issue. I can recognize a 20MB jpg file on Roboflow.com visualize, but it wont recognize on the API. I am not sure what the limitations of the API are, or the best way to preprocess an image before sending it to the roboflow API.

Because it would be nice to produce a high quality image for visualization, and simply overlay the bounding boxes.

Code snippets:
#@title Connect to Roboflow

#Downloading data from Roboflow

from roboflow import Roboflow

rf = Roboflow(api_key=“API_KEY”)

project = rf.workspace(“XXX”).project(“XXXX”)

model = project.version(3).model

#dataset = project.version(3).download(“tfrecord”)

try:
# This is the line where the error is being thrown
predictions = model.predict(image_path, confidence=50).json()
print(predictions)

# Continue with the rest of your code that processes the predictions
# ...

except UnidentifiedImageError as e:
print(f"Error: Cannot identify image file. Please ensure the file is a valid image. {e}“)
except Exception as e:
print(f"An unexpected error occurred: {e}”)

Errors:

Enter the image file name (with extension, e.g., ‘example.jpg’): page_15L.png
{‘predictions’: , ‘image’: {‘width’: ‘2286’, ‘height’: ‘1616’}}

Based on the information provided in the extracts, there could be a few reasons why you’re not getting any predictions from the Roboflow API.

  1. Confidence Level: The confidence level you’ve set for your predictions is 50%. This means that any predictions with a confidence level below 50% will not be returned. If your model is not very confident about its predictions, this could result in an empty set of predictions. You could try lowering the confidence level to see if this resolves the issue.

    predictions = model.predict(image_path, confidence=30).json()
    
  2. Image Size: The Roboflow API might have limitations on the size of the images it can process. If your image is too large, it might not be able to process it. You could try resizing your image before sending it to the API. However, the exact limitations of the API are not specified in the extracts provided.

  3. API Key and Project Details: Ensure that your API key and project details are correct. If you’ve recently upgraded your account, you might need to update your API key. Also, make sure that the project and version you’re trying to access exist and are accessible with your current account permissions.

    rf = Roboflow(api_key="NEW_API_KEY")
    project = rf.workspace("YOUR_WORKSPACE").project("YOUR_PROJECT")
    model = project.version(YOUR_VERSION).model
    
  4. Image File Format: Ensure that the image file you’re trying to predict is in a format that the Roboflow API can process (e.g., .jpg, .png). If the file format is not supported, this could result in an error.

If none of these suggestions resolve your issue, I would recommend reaching out to Roboflow’s support for further assistance. They might be able to provide more specific guidance based on your account details and the specifics of your project.

Sources:


Hi! I’m Roboflow’s AI powered bot. This is an automated response powered using AI with knowledge from our docs, blog, and forum. If this solves your issue, please mark it as the solution using the checkbox icon. If this doesn’t solve your issue, please follow up with what you’ve tried/why, and the community will continue to chime in as usual.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.