Davida23 commited on
Commit
e005d01
1 Parent(s): 808f4c3

Upload 14 files

Browse files
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import cv2
3
+ import gradio as gr
4
+ import numpy as np
5
+ # from configs.config import Configuration
6
+ from scripts.charExtraction import CharExtraction
7
+ from scripts.bboxAnnotator import BBOXAnnotator
8
+
9
+ wPathPlat = "licence_plat.pt"
10
+ wPathChar = "licence_character.pt"
11
+ classList = np.array(['A','B','C','D','E','F','G','H','I','J','K','L','M',
12
+ 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
13
+ '0','1','2','3','4','5','6','7','8','9'])
14
+ sizePlat = (416,200)
15
+ # imageSample = Configuration['imageSample']
16
+
17
+
18
+ extractor = CharExtraction(wPlatePath=wPathPlat, wCharacterPath=wPathChar, classList=classList,
19
+ sizePlate=sizePlat, conf=0.5)
20
+ annotator = BBOXAnnotator()
21
+
22
+ def getAnnotatedImage(frame, conf):
23
+ bbox, plateNum, confidence = extractor.predict(image=frame, conf=conf)
24
+ annotateImg, plateNum = annotator.draw_bbox(frame, bbox, plateNum)
25
+ prob_dict = {key: value for key, value in zip(plateNum, confidence)}
26
+
27
+ # pathOu = os.path.join(os.path.abspath(''), "output/sample.jpg")
28
+ # cv2.imwrite(pathOu, annotateImg)
29
+
30
+ return annotateImg, prob_dict
31
+
32
+ def video_identity(frame, conf=0.45):
33
+ image, plateNumber = getAnnotatedImage(frame, conf)
34
+
35
+ return image, plateNumber
36
+
37
+
38
+ demo = gr.Interface(fn=video_identity,
39
+ inputs=[gr.Image(label='Input image'), gr.Slider(minimum=0.1, maximum=1.0, label='Conf value')],
40
+ outputs=[gr.Image(label='Result'), gr.Label(label='Plate Number Detected')],
41
+ examples = [["sample_image2.jpg"], ["sample_image3.jpg"], ["sample_image5.jpg"], ["sample_image6.jpg"]],
42
+ cache_examples=True)
43
+
44
+ if __name__ == "__main__":
45
+ demo.queue()
46
+ demo.launch()
configs/__pycache__/config.cpython-39.pyc ADDED
Binary file (616 Bytes). View file
 
configs/config.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import numpy as np
3
+
4
+ current_dir = os.getcwd()
5
+ # print('current direc: ', current_dir)
6
+ Configuration = {
7
+ 'sizePlat': (416,200),
8
+ 'weightPlatDir': os.path.join(current_dir, "weights\licence_plat.pt"),
9
+ 'weightCharDir': os.path.join(current_dir, "weights\licence_character.pt"),
10
+ # 'imageSample': os.path.join(current_dir, "samples\mobil_2.jpg"),
11
+ # 'outputFile': os.path.join(current_dir, "runs\detect"),
12
+ 'classListCharacter': np.array(['A','B','C','D','E','F','G','H','I','J','K','L','M',
13
+ 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
14
+ '0','1','2','3','4','5','6','7','8','9'])
15
+ }
licence_character.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84025e3a1af9d88f9dee0320a139b7ee05a9adfbdeae02532094cdba6781fe32
3
+ size 87648392
licence_plat.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3d6ae8c01ce44cbed9cb40cda72da699c45b08520156fe558c936cfdb989b209
3
+ size 87605512
output/sample.jpg ADDED
output/sample.mp4 ADDED
Binary file (44 Bytes). View file
 
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ python3-opencv
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ opencv-python
3
+ ultralytics
sample/video/sample_video.mp4 ADDED
Binary file (852 kB). View file
 
sample_image2.jpg ADDED
sample_image3.jpg ADDED
sample_image5.jpg ADDED
sample_image6.jpg ADDED