How to make inference on multiple images? #4142
-
i have trained the model, now i would like to use it to detect objects in many images. I saw that the defaultpredictor allows you to detect only on an image, what can I do? I need to make something like this: cfg.MODEL.WEIGHTS = os.path.join("/kaggle/working/detectron2/output", "model_final.pth") # path to the model we trained |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Solved in this way %cd /kaggle/working/detectron2 |
Beta Was this translation helpful? Give feedback.
Solved in this way
%cd /kaggle/working/detectron2
import glob
cfg.MODEL.WEIGHTS = os.path.join("/kaggle/working/detectron2/output", "model_final.pth") # path to the model we trained
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.0001 # set a testing threshold
pred = DefaultPredictor(cfg)
for img in glob.glob('/kaggle/working/detectron2/images/*.jpg'): #path to the images
inputs = cv2.imread(img)
outputs = pred(inputs)
print(outputs)