Update app.py
Browse files
app.py
CHANGED
|
@@ -48,20 +48,6 @@ def get_sample_images(image_folder, format=('.jpg', '.jpeg')):
|
|
| 48 |
|
| 49 |
return image_files
|
| 50 |
|
| 51 |
-
def get_sample_mask(image_folder, image):
|
| 52 |
-
|
| 53 |
-
# Get the filename of the original image
|
| 54 |
-
image_filename = os.path.basename(image.name)
|
| 55 |
-
|
| 56 |
-
# Construct the filename for the ground truth mask
|
| 57 |
-
mask_filename = image_filename.replace('_sat.jpg', '_mask.png')
|
| 58 |
-
|
| 59 |
-
# Load the ground truth mask
|
| 60 |
-
mask_path = os.path.join(image_folder, mask_filename)
|
| 61 |
-
ground_truth_mask = Image.open(mask_path)
|
| 62 |
-
|
| 63 |
-
return ground_truth_mask
|
| 64 |
-
|
| 65 |
def ensemble_predict(X_array):
|
| 66 |
#
|
| 67 |
# Call the predict methods of the unet_model and the vgg16_unet_model
|
|
@@ -92,8 +78,15 @@ def get_predictions(y_prediction_encoded):
|
|
| 92 |
|
| 93 |
def predict_on_train(image):
|
| 94 |
|
| 95 |
-
#
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
ground_truth_mask_pil = resize_image(ground_truth_mask)
|
| 98 |
|
| 99 |
# Steps to get prediction of the satellite image
|
|
|
|
| 48 |
|
| 49 |
return image_files
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
def ensemble_predict(X_array):
|
| 52 |
#
|
| 53 |
# Call the predict methods of the unet_model and the vgg16_unet_model
|
|
|
|
| 78 |
|
| 79 |
def predict_on_train(image):
|
| 80 |
|
| 81 |
+
# Extract filename from Gradio input
|
| 82 |
+
image_filename = gr.get_data()[0].name
|
| 83 |
+
# Construct the filename for the ground truth mask
|
| 84 |
+
mask_filename = image_filename.replace('_sat.jpg', '_mask.png')
|
| 85 |
+
|
| 86 |
+
# Load the ground truth mask
|
| 87 |
+
mask_path = os.path.join(TRAIN_FOLDER, mask_filename)
|
| 88 |
+
ground_truth_mask = Image.open(mask_path)
|
| 89 |
+
# Resize the mask image
|
| 90 |
ground_truth_mask_pil = resize_image(ground_truth_mask)
|
| 91 |
|
| 92 |
# Steps to get prediction of the satellite image
|