When using ultralytics/yolov5, the following error occurred.

AttributeError: 'Detections' object has no attribute 'imgs'

As mentioned in the following issue, this appears to be caused by an API change.

https://github.com/robmarkcole/yolov5-flask/issues/23

As one example, the error was resolved by rewriting the program as follows.

results = model(im)  # inference

# new
def getImage(results):
    output_dir = "static"
    if os.path.exists(output_dir):
        shutil.rmtree(output_dir)
    results.save(save_dir=f"{output_dir}/")
    return Image.open(f"{output_dir}/image0.jpg")

# old
def oldGetImage(results):
    results.render()
    return Image.fromarray(results.imgs[0])

renderedImg = getImage(results)

I hope this is helpful for those experiencing the same issue.