Coder Social home page Coder Social logo

tfrecord-viewer's Introduction

TFRecord Viewer

"How about checking your data before going deeper?"

Use TFRecord Viewer to browse contents of TFRecords with object detection/classification/segmentation annotations.

The viewer runs a Flask server to provide a web gallery with annotation overlays. I.e. you can run it on your server machine, but browse on your local machine.

The web gallery displayed with Fotorama.io.

Examples

python3 tfviewer.py datasets/COCO/tfrecord/coco_train.record-00003-of-00100 --labels-to-highlight='car;truck;bus;motorcycle'

Detection example

python3 tfviewer.py datasets/imagenet/tfrecord/train-00000-of-01024 --overlay classification

Classification example

python3 tfviewer.py tfrecord_samples/semantic_cityscapes_train-00000-of-00010.tfrecord --overlay=segmentation --segmap-colormap-file=./cityscapes_colormap.txt Segmentation example

tfrecord-viewer's People

Contributors

mitsvision avatar raudette avatar sulc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tfrecord-viewer's Issues

Error when used with Flask 2.2

The flask function 'send_file', used on line 173 of tfviewer.py, doesn't use the 'attachment_filename' keyword as of Flask 2.2. It seems to have been replaced with the 'download_name' keyword.

Draw label over detection boxed

First, thanks for making this. It's super useful!

The Problem

For objects that are very small compared to the total image size, the label might block the object.

I'm currently converting this dataset to TF Records: http://bird.nae-lab.org/dataset/

Suggestion

consider drawing the label over the bounding box.

A Solution

I would have sent a PR but my editor changed the formatting of the file.

Where's what I did:

# file: overlays/detection_overlay.py

...

    def draw_bboxes(self, image_bytes, bboxes):
        """Draw bounding boxes onto image.

        Args:
          image_bytes: JPEG image.
          bboxes (list of tuples): [ (label, xmin, xmax, ymin, ymax), (label, xmin, xmax, ymin, ymax) , .. ]

        Returns:
          image_bytes: JPEG image including bounding boxes.
        """
        img = Image.open(io.BytesIO(image_bytes))

        draw = ImageDraw.Draw(img)

        width, height = img.size

        for bbox in bboxes:
            label, xmin, xmax, ymin, ymax = self.bboxes_to_pixels(bbox, width, height)
            draw.rectangle([xmin, ymin, xmax, ymax], outline=self.bbox_color(label))
            # draw label over bounding box
            w, h = self.font.getsize(label)
            draw.rectangle((xmin, ymin - 2, xmin + w + 4, ymin - h - 4), fill="white")

            draw.text(
                (xmin + 2, ymin - h - 4),
                label,
                fill=self.bbox_color(label),
                font=self.font,
            )

        with io.BytesIO() as output:
            if img.mode in ("RGBA", "P"):
                img = img.convert("RGB")
            img.save(output, format="JPEG")
            output_image = output.getvalue()
        return output_image

Requirements.txt

Got some error in tensorflow no python_io, change to io but still get another error, may be we need to specify the packages version

Only Rectangle Box Shown

Hi,
Thank you for developing this , but in your viewer file it only takes xmin , ymin , xmax and ymax.But I am doing segmentation so I need to draw bounding box with polygoned segmentation points like below images.

image

Help me sort out this

boxes are misplaced on the image

38

Thank you so much for this amazing job! This viewer helps me a lot :)
But I found the boxes are misplaced on the image.

All feature names are default, and all arguments are default.

Not working on imagenet image

I ran to error with the followinig error:

python3 ./tfviewer.py /datasets/imagenet2012/5.1.0/imagenet2012-train.tfrecord-00004 --overlay classification

imagenet2012-train.tfrecord-00000-of-01024 imagenet2012-train.tfrecord-00003-of-01024 imagenet2012-train.tfrecord-00006-of-01024 imagenet2012-train.tfrecord-00009-of-01024
imagenet2012-train.tfrecord-00001-of-01024 imagenet2012-train.tfrecord-00004-of-01024 imagenet2012-train.tfrecord-00007-of-01024
imagenet2012-train.tfrecord-00002-of-01024 imagenet2012-train.tfrecord-00005-of-01024 imagenet2012-train.tfrecord-00008-of-01024
root@uefi-popos-20:/tfrecord-viewer/src/tfrecord-viewer# python3 ./tfviewer.py /datasets/imagenet2012/5.1.0/imagenet2012-train.tfrecord-00000-of-01024 --overlay classification
Pre-loading up to 200 examples..
2022-04-14 12:59:53.259380: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:936] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-04-14 12:59:53.264222: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:936] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-04-14 12:59:53.264642: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:936] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-04-14 12:59:53.265321: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-04-14 12:59:53.265464: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:936] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-04-14 12:59:53.265895: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:936] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-04-14 12:59:53.266267: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:936] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-04-14 12:59:53.719396: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:936] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-04-14 12:59:53.719827: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:936] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-04-14 12:59:53.720189: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:936] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-04-14 12:59:53.720539: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 6664 MB memory: -> device: 0, name: NVIDIA GeForce RTX 2070 SUPER, pci bus id: 0000:06:00.0, compute capability: 7.5
Filename: /datasets/imagenet2012/5.1.0/imagenet2012-train.tfrecord-00000-of-01024
Traceback (most recent call last):
File "./tfviewer.py", line 192, in
count = preload_images(args.max_images)
File "./tfviewer.py", line 116, in preload_images
image_bytes = example.features.feature[args.image_key].bytes_list.value[0]
IndexError: list index (0) out of range

How to increase line thickness?

Hello,
I have a tfrecord file which contains bounding boxes of planes.
But my image size is quite large (4800 x 2703). So when I visualize them, bounding boxes look thin.
Therefore, my question is that if there is a way to increase the line thickness of bounding boxes.
I guess it is somewhere in detection_overlay.py but I wasn't able to point it out.

Thank you!

Wrapper for tfrecord viewer

First I really want to thank you a lot for this project. It saved me tons of time. Just wanted to let you know that I've written a wrapper around this project to make it more user-friendly with selection feature. You can see it here:
Wrapper for tfrecord viewer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.