Files changed (4) hide show
  1. classes.json +1 -0
  2. example.py +22 -0
  3. image.jpg +0 -0
  4. model.onnx +3 -0
classes.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"train": 0, "seaplane": 1, "motorbus": 2, "airplane": 3, "stair": 4, "bicycle": 5, "bus": 6, "car": 7, "crosswalk": 8, "hydrant": 9, "motorcycle": 10, "mountain": 11, "stairs": 12, "tow truck": 13, "traffic light": 14, "traffic sign": 15, "truck": 16}
example.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # ONNX for image classification model
3
+
4
+ import onnxruntime as ort
5
+ import numpy
6
+ from PIL import Image
7
+
8
+ ort_sess = ort.InferenceSession('model.onnx')
9
+ classes = [ "train" , "seaplane" , "motorbus" , "airplane" , "stair" , "bicycle" , "bus" , "car" , "crosswalk" , "hydrant" , "motorcycle" , "mountain" , "stairs" , "tow truck" , "traffic light" , "traffic sign" , "truck" , ]
10
+
11
+ img = Image.open("image.jpg").convert('RGB')
12
+ img = img.resize((300, 300 * img.size[1] // img.size[0]), Image.ANTIALIAS)
13
+ inp_numpy = numpy.array(img)[None].astype('float32')
14
+
15
+
16
+ class_scores = ort_sess.run(None, {'input': inp_numpy})[0][0]
17
+
18
+
19
+
20
+ print("")
21
+ print("class_scores", class_scores)
22
+ print("Class : ", classes[class_scores.argmax()])
image.jpg ADDED
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75b984b8df7c427254966dfd08b057a96f11adc01894772a37109463449552f0
3
+ size 16196546