Image Inference Error

Im trying out an example from one of the blog posts and am getting an error. I looked through the forum, and the solution of upgrading roboflow to latest doesnt solve the issue. Whats the problem?
from roboflow import Roboflow

import supervision as sv

import cv2

import tempfile

import os

Load the Roboflow API and authenticate with your API key

rf = Roboflow(api_key=“xxxxxxx”)

Load the project for identifying parts of the car

project_parts = rf.workspace().project(“car-parts-segmentation”)

model_parts = project_parts.version(2).model

Load the project for detecting damaged areas of the car

project_damage = rf.workspace().project(“car-damage-detection-ha5mm”)

model_damage = project_damage.version(1).model

Path to the input image

img_path = “13b15550cec5cabf63fe48bcf17aaa05.jpg”

Run the models on the input image

result_damage = model_damage.predict(img_path, confidence=40).json()

Im getting the following error " line 22, in

result_damage = model_damage.predict(img_path, confidence=40).json()
                ^^^^^^^^^^^^^^^^^^^^

AttributeError: ‘NoneType’ object has no attribute ‘predict’"

I have the exact same problem but haven’t found a good solution, if you use roboflow==0.2.23 it will instead download the json_response file with another error. However I found that by doing the image recognition online it seams to work if that is viable to you? Check out my post to see if you find anything of help and please let me know if you solve it! Roboflow Post

Here is a way to run It online:

Install inference.

pip install inference

If you have an NVIDIA GPU that supports CUDA

pip install inference-gpu

Add your Roboflow API Key as an environment variable or in a .env file. Just run it in the terminal basically

export ROBOFLOW_API_KEY="YOUR_PRIVATE_API_KEY"

Use it in your python project.

import inference
model = inference.get_model("Project_ID/Version number") #It should be in one sentence like this (untilted-asfg/1) where untilted-asfg is the model ID and 1 is the version
results = model.infer(image="YOUR_IMAGE.jpg")
print(results)

please let me know if that works for you! If my "tutorial" is uncomprehendable you can just find it under model-> deployments -> Self Hosted Reference (native Python)

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