Update app.py
Browse files
app.py
CHANGED
|
@@ -104,12 +104,6 @@ def get_model(ctx, model_path):
|
|
| 104 |
|
| 105 |
# Download test image
|
| 106 |
mx.test_utils.download('https://s3.amazonaws.com/onnx-model-zoo/duc/city1.png')
|
| 107 |
-
# read image as rgb
|
| 108 |
-
im = cv.imread('city1.png')[:, :, ::-1]
|
| 109 |
-
# set output shape (same as input shape)
|
| 110 |
-
result_shape = [im.shape[0],im.shape[1]]
|
| 111 |
-
# set rgb mean of input image (used in mean subtraction)
|
| 112 |
-
rgb_mean = cv.mean(im)
|
| 113 |
|
| 114 |
|
| 115 |
# Download ONNX model
|
|
@@ -125,8 +119,15 @@ else:
|
|
| 125 |
mod = get_model(ctx, 'ResNet101_DUC_HDC.onnx')
|
| 126 |
|
| 127 |
def inference(im):
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
-
|
|
|
|
|
|
| 104 |
|
| 105 |
# Download test image
|
| 106 |
mx.test_utils.download('https://s3.amazonaws.com/onnx-model-zoo/duc/city1.png')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
|
| 109 |
# Download ONNX model
|
|
|
|
| 119 |
mod = get_model(ctx, 'ResNet101_DUC_HDC.onnx')
|
| 120 |
|
| 121 |
def inference(im):
|
| 122 |
+
# read image as rgb
|
| 123 |
+
im = cv.imread(im)[:, :, ::-1]
|
| 124 |
+
# set output shape (same as input shape)
|
| 125 |
+
result_shape = [im.shape[0],im.shape[1]]
|
| 126 |
+
# set rgb mean of input image (used in mean subtraction)
|
| 127 |
+
rgb_mean = cv.mean(im)
|
| 128 |
+
pre = preprocess(im)
|
| 129 |
+
conf,result_img,blended_img,raw = predict(pre)
|
| 130 |
+
return blended_img
|
| 131 |
|
| 132 |
+
examples=[['city1.png']]
|
| 133 |
+
gr.Interface(inference,gr.inputs.Image(type="filepath"),gr.outputs.Image(type="pil"),examples=examples).launch()
|