Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,12 +22,9 @@ model_path = 'densenet-9.onnx'
|
|
| 22 |
model = onnx.load(model_path)
|
| 23 |
session = ort.InferenceSession(model.SerializeToString())
|
| 24 |
|
| 25 |
-
def get_image(path
|
| 26 |
with Image.open(path) as img:
|
| 27 |
img = np.array(img.convert('RGB'))
|
| 28 |
-
if show:
|
| 29 |
-
plt.imshow(img)
|
| 30 |
-
plt.axis('off')
|
| 31 |
return img
|
| 32 |
|
| 33 |
def preprocess(img):
|
|
@@ -44,7 +41,7 @@ def preprocess(img):
|
|
| 44 |
return img
|
| 45 |
|
| 46 |
def predict(path):
|
| 47 |
-
img = get_image(path
|
| 48 |
img = preprocess(img)
|
| 49 |
ort_inputs = {session.get_inputs()[0].name: img}
|
| 50 |
preds = session.run(None, ort_inputs)[0]
|
|
|
|
| 22 |
model = onnx.load(model_path)
|
| 23 |
session = ort.InferenceSession(model.SerializeToString())
|
| 24 |
|
| 25 |
+
def get_image(path):
|
| 26 |
with Image.open(path) as img:
|
| 27 |
img = np.array(img.convert('RGB'))
|
|
|
|
|
|
|
|
|
|
| 28 |
return img
|
| 29 |
|
| 30 |
def preprocess(img):
|
|
|
|
| 41 |
return img
|
| 42 |
|
| 43 |
def predict(path):
|
| 44 |
+
img = get_image(path)
|
| 45 |
img = preprocess(img)
|
| 46 |
ort_inputs = {session.get_inputs()[0].name: img}
|
| 47 |
preds = session.run(None, ort_inputs)[0]
|