Weird artifacts from instance segmentation prediction from a panoptic model on a Raspberry Pi 4
See original GitHub issueI 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.
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) |
---|---|---|
![]() |
![]() |
![]() |
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) |
---|---|
![]() |
![]() |
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
- Install raspberry pi 4 image with torch 1.8 preinstalled (https://github.com/Qengineering/RPi-image)
- 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
- Download detectron2 repo
git clone https://github.com/facebookresearch/detectron2.git
- cd to detectron2/demo
- (download image)[https://user-images.githubusercontent.com/31523812/115605116-2003dd00-a2b0-11eb-8365-de375e8bce82.jpg] and rename as input1.jpg
- 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) |
---|---|
![]() |
![]() |
Environment:
- Raspberry Pi 4
- Image: https://github.com/Qengineering/RPi-image
- Installed Detectron2 via
python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.8/index.html
Issue Analytics
- State:
- Created 2 years ago
- Comments:11
@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)
@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