Update app.py
Browse files
app.py
CHANGED
|
@@ -64,7 +64,6 @@ def get_predictions(y_prediction_encoded):
|
|
| 64 |
return predicted_label_indices
|
| 65 |
|
| 66 |
def predict(image):
|
| 67 |
-
|
| 68 |
# Steps to get prediction
|
| 69 |
sample_image_resized = resize_image(image)
|
| 70 |
y_pred = ensemble_predict(sample_image_resized)
|
|
@@ -74,14 +73,19 @@ def predict(image):
|
|
| 74 |
colors = ['cyan', 'yellow', 'magenta', 'green', 'blue', 'black', 'white']
|
| 75 |
# Create a ListedColormap
|
| 76 |
cmap = ListedColormap(colors)
|
| 77 |
-
# Create colorbar and set ticks and ticklabels
|
| 78 |
-
cbar = plt.colorbar(ticks=np.arange(1, 8))
|
| 79 |
-
cbar.set_ticklabels(['Urban', 'Agriculture', 'Range Land', 'Forest', 'Water', 'Barren', 'Unknown'])
|
| 80 |
|
| 81 |
-
|
| 82 |
-
# Create a figure without saving it to a file
|
| 83 |
fig, ax = plt.subplots()
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
# Convert the figure to a PIL Image
|
| 87 |
image_buffer = io.BytesIO()
|
|
|
|
| 64 |
return predicted_label_indices
|
| 65 |
|
| 66 |
def predict(image):
|
|
|
|
| 67 |
# Steps to get prediction
|
| 68 |
sample_image_resized = resize_image(image)
|
| 69 |
y_pred = ensemble_predict(sample_image_resized)
|
|
|
|
| 73 |
colors = ['cyan', 'yellow', 'magenta', 'green', 'blue', 'black', 'white']
|
| 74 |
# Create a ListedColormap
|
| 75 |
cmap = ListedColormap(colors)
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
# Create a figure
|
|
|
|
| 78 |
fig, ax = plt.subplots()
|
| 79 |
+
|
| 80 |
+
# Display the image
|
| 81 |
+
ax.imshow(sample_image_resized)
|
| 82 |
+
|
| 83 |
+
# Display the predictions using the specified colormap
|
| 84 |
+
cax = ax.imshow(y_pred, cmap=cmap, vmin=1, vmax=7, alpha=0.5)
|
| 85 |
+
|
| 86 |
+
# Create colorbar and set ticks and ticklabels
|
| 87 |
+
cbar = plt.colorbar(cax, ticks=np.arange(1, 8))
|
| 88 |
+
cbar.set_ticklabels(['Urban', 'Agriculture', 'Range Land', 'Forest', 'Water', 'Barren', 'Unknown'])
|
| 89 |
|
| 90 |
# Convert the figure to a PIL Image
|
| 91 |
image_buffer = io.BytesIO()
|