Skip to content
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.

Debug changes #210

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions retinanet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ def forward(self, inputs):
transformed_anchors = self.regressBoxes(anchors, regression)
transformed_anchors = self.clipBoxes(transformed_anchors, img_batch)

finalResult = [[], [], []]

finalScores = torch.Tensor([])
finalAnchorBoxesIndexes = torch.Tensor([]).long()
finalAnchorBoxesCoordinates = torch.Tensor([])
Expand All @@ -282,10 +280,6 @@ def forward(self, inputs):
anchorBoxes = anchorBoxes[scores_over_thresh]
anchors_nms_idx = nms(anchorBoxes, scores, 0.5)

finalResult[0].extend(scores[anchors_nms_idx])
finalResult[1].extend(torch.tensor([i] * anchors_nms_idx.shape[0]))
finalResult[2].extend(anchorBoxes[anchors_nms_idx])

finalScores = torch.cat((finalScores, scores[anchors_nms_idx]))
finalAnchorBoxesIndexesValue = torch.tensor([i] * anchors_nms_idx.shape[0])
if torch.cuda.is_available():
Expand Down
6 changes: 4 additions & 2 deletions visualize_single_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def detect_image(image_path, model_path, class_list):
for img_name in os.listdir(image_path):

image = cv2.imread(os.path.join(image_path, img_name))
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

if image is None:
continue
image_orig = image.copy()
Expand Down Expand Up @@ -96,7 +98,7 @@ def detect_image(image_path, model_path, class_list):

st = time.time()
print(image.shape, image_orig.shape, scale)
scores, classification, transformed_anchors = model(image.cuda().float())
scores, classification, transformed_anchors = model(image.float())
print('Elapsed time: {}'.format(time.time() - st))
idxs = np.where(scores.cpu() > 0.5)

Expand All @@ -109,7 +111,7 @@ def detect_image(image_path, model_path, class_list):
y2 = int(bbox[3] / scale)
label_name = labels[int(classification[idxs[0][j]])]
print(bbox, classification.shape)
score = scores[j]
score = scores[idxs[0][j]]
caption = '{} {:.3f}'.format(label_name, score)
# draw_caption(img, (x1, y1, x2, y2), label_name)
draw_caption(image_orig, (x1, y1, x2, y2), caption)
Expand Down