OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Delete everything outside of bounding boxes detectron2

  • Thread starter Thread starter Dennis
  • Start date Start date
D

Dennis

Guest
I have trained a detectron2 model with one class. Now I want to set everything that is not inside of a bbox to the color white and keep the rest as it is. There can be multiple bboxes on one picture and they can overlay.

I read the docs of detectron2 as well as cv2 but I was not able to find a solution to my problem.

This is my code for the predictions:

Code:
from detectron2 import model_zoo
from detectron2.config import get_cfg
from detectron2.engine import DefaultPredictor
import cv2

cfg = get_cfg()
cfg.merge_from_file(model_zoo.get_config_file('COCO-Detection/tmp'))
cfg.MODEL.WEIGHTS = 'tmp'

predictor = DefaultPredictor(cfg)

img = cv2.imread('tmp')

out = predictor(img)
<p>I have trained a <code>detectron2</code> model with one class. Now I want to set everything that is not inside of a bbox to the color white and keep the rest as it is. There can be multiple bboxes on one picture and they can overlay.</p>
<p>I read the <a href="https://detectron2.readthedocs.io/en/latest/" rel="nofollow noreferrer">docs of detectron2</a> as well as <a href="https://docs.opencv.org/4.x/" rel="nofollow noreferrer">cv2</a> but I was not able to find a solution to my problem.</p>
<p>This is my code for the predictions:</p>
<pre><code>from detectron2 import model_zoo
from detectron2.config import get_cfg
from detectron2.engine import DefaultPredictor
import cv2

cfg = get_cfg()
cfg.merge_from_file(model_zoo.get_config_file('COCO-Detection/tmp'))
cfg.MODEL.WEIGHTS = 'tmp'

predictor = DefaultPredictor(cfg)

img = cv2.imread('tmp')

out = predictor(img)
</code></pre>
 

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top