def make_tf_example(self, image_or_path, detections, filename=None):
        """Makes a ``tf.train.Example`` for the given data.

        Args:
            image_or_path: an image or the path to the image on disk
            detections: a :class:`fiftyone.core.labels.Detections` instance, or
                ``None``
            filename (None): a filename for the image. Required when
                ``image_or_path`` is an image, in which case the extension of
                this filename determines the encoding used. If
                ``image_or_path`` is the path to an image, this is optional; by
                default, the basename of ``image_path`` is used

        Returns:
            a ``tf.train.Example``
        """
        img_bytes, img_shape, filename = self._parse_image_or_path(
            image_or_path, filename=filename
        )
        format = os.path.splitext(filename)[1][1:]  # no leading `.`

        feature = {
            "image/height": _int64_feature(img_shape[0]),
            "image/width": _int64_feature(img_shape[1]),
            "image/filename": _bytes_feature(filename.encode()),
            "image/source_id": _bytes_feature(filename.encode()),
            "image/encoded": _bytes_feature(img_bytes),
            "image/format": _bytes_feature(format.encode()),
        }

        if detections is not None:
            xmins, xmaxs, ymins, ymaxs, texts, labels = [], [], [], [], [], []
            for detection in detections.detections:
                xmin, ymin, w, h = detection.bounding_box
                text = detection.label

                if self._dynamic_classes:
                    if text not in self._labels_map_rev:
                        label = len(self._labels_map_rev)
                        self._labels_map_rev[text] = label
                    else:
                        label = self._labels_map_rev[text]
                elif text not in self._labels_map_rev:
                    msg = (
                        "Ignoring detection with label '%s' not in provided "
                        "classes" % text
                    )
                    warnings.warn(msg)
                    continue
                else:
                    label = self._labels_map_rev[text]

                xmins.append(xmin)
                xmaxs.append(xmin + w)
                ymins.append(ymin)
                ymaxs.append(ymin + h)
                texts.append(text.encode())
                labels.append(label)

            feature.update(
                {
                    "image/object/bbox/xmin": _float_list_feature(xmins),
                    "image/object/bbox/xmax": _float_list_feature(xmaxs),
                    "image/object/bbox/ymin": _float_list_feature(ymins),
                    "image/object/bbox/ymax": _float_list_feature(ymaxs),
                    "image/object/class/text": _bytes_list_feature(texts),
                    "image/object/class/label": _int64_list_feature(labels),
                }
            )

        return tf.train.Example(features=tf.train.Features(feature=feature))
Makes a ``tf.train.Example`` for the given data.

        Args:
            image_or_path: an image or the path to the image on disk
            detections: a :class:`fiftyone.core.labels.Detections` instance, or
                ``None``
            filename (None): a filename for the image. Required when
                ``image_or_path`` is an image, in which case the extension of
                this filename determines the encoding used. If
                ``image_or_path`` is the path to an image, this is optional; by
                default, the basename of ``image_path`` is used

        Returns:
            a ``tf.train.Example``
        
fiftyone/utils/tf.py