question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird artifacts from instance segmentation prediction from a panoptic model on a Raspberry Pi 4

See original GitHub issue

I ran a R50-FPN on a image from the coco dataset using demo.py on the Raspberry Pi 4 (cpu) and got some weird visual artifacts.

prediction

Here is the original image, predictions on the Pi vs a PC for reference.

Original Image Model Prediction on Raspberry Pi 4 (cpu) Model Prediction on a PC (cpu)
input1 prediction prediction

While looking into the Raspberry Pi 4 model outputs, I found that the problem is in the instance mask predictions portion of the panoptic model (for example, here is the binary mask model prediction for the horse instance object).

predictions = self.predictor(image)
bin_mask = predictions["instances"][0].to("cpu").pred_masks.numpy()[0,:,:] # Plotted this using plt.imsave
Model Prediction on Raspberry Pi 4 (cpu) Model Prediction on a PC (cpu)
test_correct test_correct_2

The code runs normally on a Ubuntu 20.04 PC workstation, but not when I run it on the Raspberry Pi 4. Could this be due to a difference in architecture? (e.g. ARM vs x86) If so, is there any work arounds for this issue?

Edit: I have tried running the same code on the Jetson Nano and it works fine, so I’m not sure what’s going on.

Any help would be greatly appreciated!

Instructions To Reproduce the Issue:

On a raspberry pi 4

  1. Install raspberry pi 4 image with torch 1.8 preinstalled (https://github.com/Qengineering/RPi-image)
  2. Install Detectron2 using command below according to installation instructions
python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.8/index.html
  1. Download detectron2 repo git clone https://github.com/facebookresearch/detectron2.git
  2. cd to detectron2/demo
  3. (download image)[https://user-images.githubusercontent.com/31523812/115605116-2003dd00-a2b0-11eb-8365-de375e8bce82.jpg] and rename as input1.jpg
  4. Run the command:
python demo.py --config-file ../configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.yaml \
  --input input1.jpg --opts MODEL.WEIGHTS detectron2://COCO-PanopticSegmentation/panoptic_fpn_R_50_1x/139514544/model_final_dbfeb4.pkl

Expected behavior:

Expected Behaviour Model Prediction on Raspberry Pi 4 (what I get)
prediction prediction

Environment:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
fapbatistacommented, Jun 8, 2021

@juan57 I got a similar problem on a custom model trained on a custom dataset. What we have in Common is three things: RPi 4 + PyTorch + the QEngineering Guide to install PyTorch and Torchvision (I had a clean Ubuntu Desktop install and installed in miniconda using their wheels)

0reactions
sourabmaitycommented, Aug 21, 2022

@juan57 are you running your model in Gpu or in Cpu
I am using detectron2 but in CPU so its predicting so slow (like 15 s per prediction) so how can I use GPU in raspberry Pi 4 8gb ram

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detectron2 Panoptic Segmentation Project - YouTube
Detectron2 #PanopticSegmentation #InstanceSegmentation #ComputerVision #ObjectDetection # RaspberryPi #GoPro #AI #MachineLearning #Tutorial ...
Read more >
70-Page Report on the COCO Dataset and Object Detection ...
This dataset is used to set benchmarks for the following tasks: object detection, panoptic semantic segmentation, keypoint detection, ...
Read more >
Guide to Panoptic Segmentation - A Semantic + Instance ...
Panoptic segmentation is an image segmentation method used for Computer Vision tasks. It unifies two distinct concepts used to segment ...
Read more >
Semantic segmentation with OpenCV and deep learning
In this tutorial, you will learn how to perform semantic segmentation using OpenCV, deep learning, and the ENet architecture.
Read more >
INSTANCE SEGMENTATION FOR FEATURES ...
In particular, the use of state-of-the-art. Convolutional Neural Networks (CNNs) performing object detection and im- age segmentation is proposed and its ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found