How to flush Results object prior to a run?

In Predict Mode, I have save enabled. Since I run my Python scripts in an IDE, I often encounter result displays from prior runs. I’ve quickly glanced at the Results object, but I could not understand which attribute will enable me to get a fresh object without the images of the previous runs. I’m probably not understanding a simple setting. Please advise. Thanks.

Regards.

Hello!

It sounds like you’re having a bit of trouble with residual data from previous runs in your Results object. To ensure you’re working with fresh results each time, you can clear any stored results by reinitializing the Results object or simply ensuring that your script does not retain any references to old results between runs.

Here’s a quick tip: make sure to reinitialize your model or results variable at the start of each run. For example:

from ultralytics import YOLO

# Load a model
model = YOLO("yolo11n.pt")

# Run inference on a new source
results = model.predict(source="new_image.jpg", save=True)

This approach ensures that each run starts with a clean slate. If you are using an IDE, consider restarting the kernel or clearing variables to prevent any carryover from previous executions.

For more detailed information, you might find the Predict Mode documentation helpful. It provides insights into managing results and other useful settings.

If you have any more questions, feel free to ask. Happy coding! :blush:

Please share the code you’re using to run inference.