Error in RoboflowEvaluator

I need help with RoboflowEvaluator. I am trying to evaluate a computer vision model using cvevals by following this vlog, How to Evaluate Computer Vision Models with CVevals

This is my code which I erased my API key for privacy:

import argparse
import os

from roboflow import Roboflow
from evaluations.dataloaders import (RoboflowDataLoader,
RoboflowPredictionsDataLoader)
from evaluations.roboflow import RoboflowEvaluator

rf = Roboflow(api_key=“”)
project = rf.workspace().project(“final-grape-leaf-disease-detection-and-classification”)
model = project.version(15).model

EVAL_DATA_PATH = “/Users/green/OneDrive/Desktop/Code/YOLOFORPYTHON/data”
ROBOFLOW_WORKSPACE_URL = “thesis-t6sjh”
ROBOFLOW_PROJECT_URL = “final-grape-leaf-disease-detection-and-classification”
ROBOFLOW_MODEL_VERSION = 15
class_names = [“Healthy”, “Birds_Eye_Rot”, “Powdery_Mildew”]

class_names, data, model = RoboflowDataLoader(
workspace_url=ROBOFLOW_WORKSPACE_URL,
project_url=ROBOFLOW_PROJECT_URL,
project_version=ROBOFLOW_MODEL_VERSION,
image_files=EVAL_DATA_PATH,
).download_dataset()

predictions = RoboflowPredictionsDataLoader(
model=model,
model_type=“multiclass”,
image_files=EVAL_DATA_PATH,
class_names=class_names,
).process_files()

evaluator = RoboflowEvaluator(
model_type=“multiclass”,
ground_truth=data, predictions=predictions, class_names=class_names, mode=“batch”
)

cf = evaluator.eval_model_predictions()

print(cf)

data = evaluator.calculate_statistics()

print(“Precision:”, data.precision)
print(“Recall:”, data.recall)
print(“f1 Score:”, data.f1)

I keep getting this error:
Exception has occurred: KeyError
‘images\20230717_093620_jpg.rf.efbf9b981bda623c03ff65b3c8a52612.jpg’
File “C:\Users\green\OneDrive\Desktop\Code\testing.py”, line 35, in
evaluator = RoboflowEvaluator(
^^^^^^^^^^^^^^^^^^
KeyError: ‘images\20230717_093620_jpg.rf.efbf9b981bda623c03ff65b3c8a52612.jpg’

The image shown on the error is the first image of my dataset. What can I do to solve this issue? I have tried combining both the txt files and image files into one folder (One folder for test, one folder for train, and one folder for valid). For reference I will attach a pic.

Based on the information provided in the extracts, it seems like the error you’re encountering might be related to the file path of your images. The error message KeyError: 'images\\20230717_093620_jpg.rf.efbf9b981bda623c03ff65b3c8a52612.jpg' suggests that the script is unable to locate the image file at the specified path.

In the Roboflow CVevals Documentation, it is mentioned that you need to specify a source from which to load your ground truth data and a source from which to load model predictions. In your case, it seems like the EVAL_DATA_PATH is the source for your ground truth data.

You might want to double-check the following:

  1. Ensure that the EVAL_DATA_PATH is correctly pointing to the directory where your images are stored. The path should be absolute and not relative.

  2. Verify that the image file ‘20230717_093620_jpg.rf.efbf9b981bda623c03ff65b3c8a52612.jpg’ indeed exists in the specified directory.

  3. Check if the file paths in your dataset are consistent with the actual file paths. For instance, if your dataset contains file paths with forward slashes (/), but your operating system uses backslashes (\), this could cause issues.

If you continue to face issues, you might want to refer back to the Roboflow CVevals Documentation or the Roboflow Blog for more detailed instructions and examples.


Hi! I’m Roboflow’s AI powered bot. This is an automated response powered using AI with knowledge from our docs, blog, knowledge base, and previous forum responses. If you find this to be a helpful answer, please mark it as the solution using the checkbox icon below. 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.

I have tried the recommendations of the ai bot but the code still does not work, what are the other solutions that I can try?