Metal3d commited on
Commit
a3ff9b2
1 Parent(s): ab7e819

Fixes the python example...

Browse files

I missed the onnx model loading, silly me

Files changed (1) hide show
  1. README.md +5 -0
README.md CHANGED
@@ -33,13 +33,18 @@ import onnxruntime
33
  import numpy as np
34
  from PIL import Image
35
 
 
 
36
  img = Image.open(sys.argv[1] if len(sys.argv) > 1 else "image.jpg")
37
  img = img.resize((512, 512))
38
  img = np.array(img).astype(np.float32) / 127.5 - 1
39
 
 
40
  input_name = model.get_inputs()[0].name
41
  output_name = model.get_outputs()[0].name
42
  result = model.run([output_name], {input_name: img})
 
 
43
  result = np.array(result[0])
44
  # argmax the classes, remove the batch size
45
  result = result.argmax(axis=3).squeeze(0)
 
33
  import numpy as np
34
  from PIL import Image
35
 
36
+ model = onnxruntime.InferenceSession("deeplabv3p-resnet50-human.onnx")
37
+
38
  img = Image.open(sys.argv[1] if len(sys.argv) > 1 else "image.jpg")
39
  img = img.resize((512, 512))
40
  img = np.array(img).astype(np.float32) / 127.5 - 1
41
 
42
+ # infer
43
  input_name = model.get_inputs()[0].name
44
  output_name = model.get_outputs()[0].name
45
  result = model.run([output_name], {input_name: img})
46
+
47
+ # squeeze, argmax...
48
  result = np.array(result[0])
49
  # argmax the classes, remove the batch size
50
  result = result.argmax(axis=3).squeeze(0)