Skip to content

Commit

Permalink
bug:fixing bugs in recognition and segmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziad-Muhammed committed Sep 11, 2022
1 parent ea6ff59 commit 5f127b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def printChars(chars, segObj, count):
printChars(chars, segObject, countPlate)
countPlate += 1
rec = Recognition('vgg_model')
rec.test_data(['alpd/outputs/1/1.png', 'alpd/outputs/1/2.png',
'alpd/outputs/1/3.png', 'alpd/outputs/1/4.png', 'alpd/outputs/1/5.png', 'alpd/outputs/1/6.png'])
rec.test_data(['./outputs/1/1.png', './outputs/1/2.png',
'./outputs/1/3.png', './outputs/1/4.png', './outputs/1/5.png', './outputs/1/6.png'])
except SystemExit:
pass
12 changes: 6 additions & 6 deletions recognition/rec.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def __init__(self,model_name='resnet_model'):
vgg_model = models.vgg19_bn(pretrained=True)
vgg_model.classifier[6] = torch.nn.Linear(vgg_model.classifier[6].in_features,38)
if(self.use_cuda):
vgg_model.load_state_dict(torch.load('./vgg_model.pt'))
vgg_model.load_state_dict(torch.load('./recognition/vgg_model.pt'))
else:
vgg_model.load_state_dict(torch.load('./vgg_model.pt',map_location=torch.device('cpu')))
vgg_model.load_state_dict(torch.load('./recognition/vgg_model.pt',map_location=torch.device('cpu')))
vgg_model.eval()
self.model = vgg_model

Expand Down Expand Up @@ -107,7 +107,7 @@ def test_data(self,img_paths):
images.append(image)
self.predict_characters(images)

if __name__=="__main__":
print("Running")
rec = Recognition('vgg_model')
rec.test_data(['./data/15/177.jpg','./data/2/45.jpg','./data/19/21.jpg','./data/31/23.jpg','./data/36/106.jpg','./data/35/7014.jpg'])
# if __name__=="__main__":
# print("Running")
# rec = Recognition('vgg_model')
# rec.test_data(['./data/15/177.jpg','./data/2/45.jpg','./data/19/21.jpg','./data/31/23.jpg','./data/36/106.jpg','./data/35/7014.jpg'])
2 changes: 1 addition & 1 deletion segmentation/seg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def filtering(self):
def findContours(self, dimensions):

# Find all contours in the image
contours, _ = cv.findContours(self.image.copy(), cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
_,contours, _ = cv.findContours(self.image.copy(), cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)

# Retrieve potential dimensions
lowerWidth = dimensions[0]
Expand Down

0 comments on commit 5f127b6

Please sign in to comment.