Spaces:
Runtime error
Runtime error
adding second model to app
Browse files
app.py
CHANGED
|
@@ -91,6 +91,24 @@ def process_image(session, img, colors, mosaic=False):
|
|
| 91 |
return overlay
|
| 92 |
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
# set cuda = true if you have an NVIDIA GPU
|
| 95 |
cuda = torch.cuda.is_available()
|
| 96 |
|
|
@@ -98,7 +116,10 @@ if cuda:
|
|
| 98 |
print("We have a GPU!")
|
| 99 |
providers = ['CUDAExecutionProvider'] if cuda else ['CPUExecutionProvider']
|
| 100 |
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
|
| 104 |
# Define colors for classes 0, 122 and 244
|
|
@@ -113,11 +134,6 @@ def load_image(uploaded_file):
|
|
| 113 |
return None
|
| 114 |
|
| 115 |
|
| 116 |
-
st.title("OpenLander ONNX app")
|
| 117 |
-
st.write("Upload an image to process with the ONNX OpenLander model!")
|
| 118 |
-
st.write("Bear in mind that this model is **much less refined** than the embedded models at the moment.")
|
| 119 |
-
|
| 120 |
-
|
| 121 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"])
|
| 122 |
if uploaded_file is not None:
|
| 123 |
img = load_image(uploaded_file)
|
|
|
|
| 91 |
return overlay
|
| 92 |
|
| 93 |
|
| 94 |
+
st.title("OpenLander ONNX app")
|
| 95 |
+
st.write("Upload an image to process with the ONNX OpenLander model!")
|
| 96 |
+
st.write("Bear in mind that this model is **much less refined** than the embedded models at the moment.")
|
| 97 |
+
|
| 98 |
+
models = {
|
| 99 |
+
"Embedded model short trained: DeeplabV3+, MobilenetV2, 416px resolution": "end2end.onnx",
|
| 100 |
+
"Embedded model better trained: DeeplabV3+, MobilenetV2, 416px resolution": "20230608_onnx_416_mbnv2_dl3/end2end.onnx"
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
# Create a Streamlit radio button to select the desired model
|
| 108 |
+
selected_model = st.radio("Select a model", list(models.keys()))
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
|
| 112 |
# set cuda = true if you have an NVIDIA GPU
|
| 113 |
cuda = torch.cuda.is_available()
|
| 114 |
|
|
|
|
| 116 |
print("We have a GPU!")
|
| 117 |
providers = ['CUDAExecutionProvider'] if cuda else ['CPUExecutionProvider']
|
| 118 |
|
| 119 |
+
# Get the selected model's path
|
| 120 |
+
model_path = models[selected_model]
|
| 121 |
+
|
| 122 |
+
session = ort.InferenceSession(model_path, providers=providers)
|
| 123 |
|
| 124 |
|
| 125 |
# Define colors for classes 0, 122 and 244
|
|
|
|
| 134 |
return None
|
| 135 |
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"])
|
| 138 |
if uploaded_file is not None:
|
| 139 |
img = load_image(uploaded_file)
|