Megvii-BaseDetection / YOLOX

YOLOX is a high-performance anchor-free YOLO, exceeding yolov3~v5 with MegEngine, ONNX, TensorRT, ncnn, and OpenVINO supported. Documentation: https://yolox.readthedocs.io/
Apache License 2.0
9.29k stars 2.18k forks source link

Find bounding box coordinates from checkpoint (best_ckpt.pth.tar) file #1143

Open RifatSanaullah opened 2 years ago

RifatSanaullah commented 2 years ago

I am trying to predict image and trying to find the bounding box coordinates and class name by loading the pretrained model, please help how to proceed to find the bounding box

i tried to find the result in that way, but showing error dic

import torch
model = torch.load('/content/drive/MyDrive/Violence_Gun_detection/YOLOX/YOLOX_outputs/yolox_voc_s/best_ckpt.pth.tar')

dir = 'https://github.com/ultralytics/yolov5/raw/master/data/images/'
imgs = [dir + f for f in ('zidane.jpg', 'bus.jpg')]  # batched list of images

results = model(imgs)
results.print()  
results.save()  # or .show()
print(results.xyxy[0])  # print img1 predictions (pixels)
FateScript commented 2 years ago

plz refer to this : https://github.com/Megvii-BaseDetection/YOLOX/blob/main/tools/demo.py#L132-L166 You could create a Predictor object and get inference result.