I use efficientdet_test.py and get the result. It is so slow, but I don't know the reason.
the code is here. I don't change too much code. I test the most time spent on the backbonenet to extract the features.
"""
Simple Inference Script of EfficientDet-Pytorch
"""
import time
import torch
from torch.backends import cudnn
from matplotlib import colors
from backbone import EfficientDetBackbone
import cv2
import numpy as np
from efficientdet.utils import BBoxTransform, ClipBoxes
from utils.utils import preprocess, invert_affine, postprocess, STANDARD_COLORS, standard_to_bgr, get_index_label, plot_one_box
import glob
compound_coef = 0
force_input_size =None # set None to use default size
img_path = 'test/img.png'
replace this part with your project's anchor config
I use efficientdet_test.py and get the result. It is so slow, but I don't know the reason. the code is here. I don't change too much code. I test the most time spent on the backbonenet to extract the features. """ Simple Inference Script of EfficientDet-Pytorch """ import time import torch from torch.backends import cudnn from matplotlib import colors
from backbone import EfficientDetBackbone import cv2 import numpy as np
from efficientdet.utils import BBoxTransform, ClipBoxes from utils.utils import preprocess, invert_affine, postprocess, STANDARD_COLORS, standard_to_bgr, get_index_label, plot_one_box import glob
compound_coef = 0 force_input_size =None # set None to use default size img_path = 'test/img.png'
replace this part with your project's anchor config
anchor_ratios = [(1.0, 1.0), (1.4, 0.7), (0.7, 1.4)] anchor_scales = [2 0, 2 (1.0 / 3.0), 2 ** (2.0 / 3.0)]
threshold = 0.5 iou_threshold = 0.5
use_cuda = True use_float16 = False cudnn.fastest = True cudnn.benchmark = True
def display(preds, imgs, imshow=True, imwrite=False): for i in range(len(imgs)): if len(preds[i]['rois']) == 0: continue
obj_list = ['circle']
color_list = standard_to_bgr(STANDARD_COLORS)
tf bilinear interpolation is different from any other's, just make do
input_sizes = [512, 640, 768, 896, 1024, 1280, 1280, 1536, 1536] input_size = input_sizes[compound_coef] if force_input_size is None else force_input_size
ori_imgs, framed_imgs, framed_metas = preprocess(img_path, max_size=input_size)
if use_cuda:
x = torch.stack([torch.from_numpy(fi).cuda() for fi in framed_imgs], 0)
else:
x = torch.stack([torch.from_numpy(fi) for fi in framed_imgs], 0)
i=0 for fi in framed_imgs: if use_cuda: