# Buggy code
def display(self, pprint=False, show=False, save=False, render=False, save_dir=""):
    colors = color_list()
    for i, (img, pred) in enumerate(zip(self.imgs, self.pred)):
        str = f"image {i + 1}/{len(self.pred)}: {img.shape[0]}x{img.shape[1]} "
        if pred is not None:
            for c in pred[:, -1].unique():
                n = (pred[:, -1] == c).sum()  # detections per class
                str += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, "  # add to string
            if show or save or render:
                img = (
                    Image.fromarray(img.astype(np.uint8))
                    if isinstance(img, np.ndarray)
                    else img
                )  # from np
                for *box, conf, cls in pred:  # xyxy, confidence, class
                    # str += '%s %.2f, ' % (names[int(cls)], conf)  # label
                    ImageDraw.Draw(img).rectangle(
                        box, width=4, outline=colors[int(cls) % 10]
                    )  # plot
        if pprint:
            print(str.rstrip(", "))
        if show:
            img.show(self.files[i])  # show
        if save:
            f = Path(save_dir) / self.files[i]
            img.save(f)  # save
            print(
                f"{'Saving' * (i == 0)} {f},", end="" if i < self.n - 1 else " done.\n"
            )
        if render:
            self.imgs[i] = np.asarray(img)


# Traceback (ValueError)
ValueError                                Traceback (most recent call last)
<ipython-input-1-86a3d667ec69> in <module>()
9
10 # Inference
---> 11 results = model(imgs)
12
13 # Results

2 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
725             result = self._slow_forward(*input, **kwargs)
726         else:
--> 727             result = self.forward(*input, **kwargs)
728         for hook in itertools.chain(
729                 _global_forward_hooks.values(),

/root/.cache/torch/hub/ultralytics_yolov5_master/models/common.py in forward(self, imgs, size, augment, profile)
201             if isinstance(im, str):  # filename or uri
202                 im = Image.open(requests.get(im, stream=True).raw if im.startswith('http') else im)  # open
--> 203             files.append(Path(im.filename).with_suffix('.jpg').name if isinstance(im, Image.Image) else f'image{i}.jpg')
204             im = np.array(im)  # to numpy
205             if im.shape[0] < 5:  # image in CHW

/usr/lib/python3.6/pathlib.py in with_suffix(self, suffix)
835         name = self.name
836         if not name:
--> 837             raise ValueError("%r has an empty name" % (self,))
838         old_suffix = self.suffix
839         if not old_suffix:

ValueError: PosixPath('.') has an empty name

# Fixed code
def display(self, pprint=False, show=False, save=False, render=False, save_dir=""):
    colors = color_list()
    for i, (img, pred) in enumerate(zip(self.imgs, self.pred)):
        str = f"image {i + 1}/{len(self.pred)}: {img.shape[0]}x{img.shape[1]} "
        if pred is not None:
            for c in pred[:, -1].unique():
                n = (pred[:, -1] == c).sum()  # detections per class
                str += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, "  # add to string
            if show or save or render:
                img = (
                    Image.fromarray(img) if isinstance(img, np.ndarray) else img
                )  # from np
                for *box, conf, cls in pred:  # xyxy, confidence, class
                    # str += '%s %.2f, ' % (names[int(cls)], conf)  # label
                    ImageDraw.Draw(img).rectangle(
                        box, width=4, outline=colors[int(cls) % 10]
                    )  # plot
        if pprint:
            print(str.rstrip(", "))
        if show:
            img.show(self.files[i])  # show
        if save:
            f = Path(save_dir) / self.files[i]
            img.save(f)  # save
            print(
                f"{'Saving' * (i == 0)} {f},", end="" if i < self.n - 1 else " done.\n"
            )
        if render:
            self.imgs[i] = np.asarray(img)