Further small improvements.
This commit is contained in:
@ -148,7 +148,7 @@ class LetterBox:
|
||||
resized_img = cv2.resize(
|
||||
image,
|
||||
(new_w, new_h),
|
||||
interpolation=cv2.INTER_LINEAR,
|
||||
interpolation=cv2.INTER_NEAREST,
|
||||
)
|
||||
|
||||
# Optionally pad the image
|
||||
@ -273,7 +273,7 @@ class BoxCrop:
|
||||
resized_img = cv2.resize(
|
||||
cropped_img,
|
||||
(new_w, new_h),
|
||||
interpolation=cv2.INTER_LINEAR,
|
||||
interpolation=cv2.INTER_NEAREST,
|
||||
)
|
||||
|
||||
# Optionally pad the image
|
||||
@ -309,6 +309,10 @@ class RTMDet(BaseModel):
|
||||
self.conf_threshold = conf_threshold
|
||||
self.letterbox = LetterBox(self.target_size, fill_value=114)
|
||||
|
||||
min_area_scale = 0.025 * 0.025
|
||||
img_area = self.target_size[0] * self.target_size[1]
|
||||
self.min_area = img_area * min_area_scale
|
||||
|
||||
def preprocess(self, image: np.ndarray):
|
||||
image = self.letterbox.resize_image(image)
|
||||
tensor = np.asarray(image).astype(self.input_types[0], copy=False)
|
||||
@ -326,6 +330,11 @@ class RTMDet(BaseModel):
|
||||
keep = boxes[:, 4] > self.conf_threshold
|
||||
boxes = boxes[keep]
|
||||
|
||||
# Drop boxes with too small area
|
||||
areas = (boxes[:, 2] - boxes[:, 0]) * (boxes[:, 3] - boxes[:, 1])
|
||||
keep = areas >= self.min_area
|
||||
boxes = boxes[keep]
|
||||
|
||||
paddings, scale, _ = self.letterbox.calc_params(image.shape)
|
||||
|
||||
boxes[:, 0] -= paddings[0]
|
||||
|
||||
Reference in New Issue
Block a user