Skip to content

Commit

Permalink
Merge pull request #40 from MortenTabaka/fix/Adding-path-must-be-insi…
Browse files Browse the repository at this point in the history
…de-prediction-script #patch

Fix/adding project root to the path must be inside prediction script
  • Loading branch information
MortenTabaka committed Oct 28, 2023
2 parents 78217ff + d2a0228 commit bf8aee5
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 33 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ All credits for the dataset go to the original author and contributors.**

After installing the necessary dependencies, execute the following scripts.

Add project root to the Python path:
```commandline
python3 models/scripts/add_project_root_to_the_python_path.py
```

Run prediction on images in `models/custom_data/input`:
```commandline
python3 models/scripts/run_prediction_on_folder.py
Expand Down
14 changes: 7 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
master_doc = "index"

# General information about the project.
project = u"Improving_IoU_for_roads_semantic_segmentation_in_LandCover.ai_dataset"
project = "Improving_IoU_for_roads_semantic_segmentation_in_LandCover.ai_dataset"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -184,8 +184,8 @@
(
"index",
"roads_semantic_segmentation_in_LandCover.ai_dataset.tex",
u"Improving_IoU_for_roads_semantic_segmentation_in_LandCover.ai_dataset Documentation",
u"Marcin Tabaka",
"Improving_IoU_for_roads_semantic_segmentation_in_LandCover.ai_dataset Documentation",
"Marcin Tabaka",
"manual",
),
]
Expand Down Expand Up @@ -219,8 +219,8 @@
(
"index",
"roads_semantic_segmentation_in_LandCover.ai_dataset",
u"Improving_IoU_for_roads_semantic_segmentation_in_LandCover.ai_dataset Documentation",
[u"Marcin Tabaka"],
"Improving_IoU_for_roads_semantic_segmentation_in_LandCover.ai_dataset Documentation",
["Marcin Tabaka"],
1,
)
]
Expand All @@ -238,8 +238,8 @@
(
"index",
"roads_semantic_segmentation_in_LandCover.ai_dataset",
u"Improving_IoU_for_roads_semantic_segmentation_in_LandCover.ai_dataset Documentation",
u"Marcin Tabaka",
"Improving_IoU_for_roads_semantic_segmentation_in_LandCover.ai_dataset Documentation",
"Marcin Tabaka",
"Improving_IoU_for_roads_semantic_segmentation_in_LandCover.ai_dataset",
"Project will focus on tryingsemantic segmentation algorithms which may improve IoU for roads specifically. Dataset authors obtaied IoU=68.74% for roads, which was lowest score among all classes. ",
"Miscellaneous",
Expand Down
14 changes: 0 additions & 14 deletions models/scripts/add_project_root_to_the_python_path.py

This file was deleted.

9 changes: 9 additions & 0 deletions models/scripts/run_prediction_on_folder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
from enum import Enum
from pathlib import Path

import os
import typer
import sys


project_root = os.path.abspath(os.curdir)
while not os.path.isfile(os.path.join(project_root, "README.md")):
current_dir = os.path.abspath(os.path.join(project_root, os.pardir))
sys.path.insert(0, project_root)


from src.features.utils import get_absolute_path_to_project_location
from src.pipelines.prediction_processor import PredictionPipeline
Expand Down
1 change: 0 additions & 1 deletion src/data/image_postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def __get_all_base_names_from_list_of_tiles(
def __get_tiles_according_its_base_name(
self, base_names: List[str], tiles: List[str]
) -> List[List[str]]:

split_tiles_according_to_base_name = []

for base_name in base_names:
Expand Down
1 change: 0 additions & 1 deletion src/data/image_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def split_custom_images_before_prediction(
target_size: int,
path_to_output_folder: Union[Path, str],
):

img_paths = glob.glob(
os.path.join(self.path_to_folder_with_input_images, "*.tiff")
)
Expand Down
1 change: 0 additions & 1 deletion src/data/move_data_according_to_subsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def move_data(raw_data_path, processed_data_path):
dataSplit = ["train", "val", "test"]

for whichSplit in dataSplit:

tilesFolder = raw_data_path + "/tiles"
moveToSubset = processed_data_path + "/" + whichSplit

Expand Down
1 change: 0 additions & 1 deletion src/data/scripts/create_directories_for_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


def create_dir(path_list):

for path in path_list:
if not os.path.exists(path):
os.makedirs(path)
Expand Down
1 change: 0 additions & 1 deletion src/features/evaluation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def get_dataframe(self) -> pd.DataFrame:
)

for single_batch in self.dataset:

y_true, y_pred = self.get_predictions_and_labels(single_batch)

matrix = tf.math.confusion_matrix(
Expand Down
2 changes: 1 addition & 1 deletion src/features/loss_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def weighted_cross_entropy_loss(self, y_true, y_pred):

def focal_loss_with_logits(self, logits, targets, alpha, gamma, y_pred):
weight_a = alpha * (1 - y_pred) ** gamma * targets
weight_b = (1 - alpha) * y_pred ** gamma * (1 - targets)
weight_b = (1 - alpha) * y_pred**gamma * (1 - targets)

return (tf.math.log1p(tf.exp(-tf.abs(logits))) + tf.nn.relu(-logits)) * (
weight_a + weight_b
Expand Down
1 change: 1 addition & 0 deletions src/features/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class CustomMeanIoU(tf.keras.metrics.MeanIoU):
"""
Source: https://github.com/tensorflow/tensorflow/issues/32875#issuecomment-707316950
"""

def __init__(self, num_classes=None, name=None, dtype=None):
super(CustomMeanIoU, self).__init__(
num_classes=num_classes, name=name, dtype=dtype
Expand Down
1 change: 0 additions & 1 deletion src/pipelines/prediction_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ def __get_image_for_prediction(self, filepath: str):
def __postprocess_tiles_borders_in_concatenated_prediction(
self, raw_image, raw_mask, base_name: str
):

height = tf.shape(raw_mask)[1]
width = tf.shape(raw_mask)[2]

Expand Down

0 comments on commit bf8aee5

Please sign in to comment.