Skip to content

Commit

Permalink
Update preprocess_sentinel2_files.py
Browse files Browse the repository at this point in the history
  • Loading branch information
alanent authored Sep 30, 2023
1 parent 50d88cb commit 9d55545
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions scripts/preprocess_sentinel2_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,6 @@ def list_items(path, filter):
return dict_train



config_path = "./data/flair-2-config.yml" # Change to yours
with open(config_path, "r") as f:
config = yaml.safe_load(f)


# Creation of the train, val and test dictionnaries with the data file paths
d_train = load_data(config)


images = d_train["PATH_IMG"]
labels = d_train["PATH_LABELS"]
sentinel_images = d_train["PATH_SP_DATA"]
sentinel_masks = d_train["PATH_SP_MASKS"] # Cloud masks
sentinel_products = d_train["PATH_SP_DATES"] # Needed to get the dates of the sentinel images
centroids = d_train["SP_COORDS"] # Position of the aerial image in the sentinel super area

def filter_dates(img, mask, clouds:bool=2, area_threshold:float=0.2, proba_threshold:int=20):
""" Mask : array T*2*H*W
Clouds : 1 if filter on cloud cover, 0 if filter on snow cover, 2 if filter on both
Expand Down Expand Up @@ -136,6 +119,28 @@ def read_dates(txt_file: str) -> np.array:
dates_arr.append(datetime.datetime(2021, int(file[15:19][:2]), int(file[15:19][2:])))
return np.array(dates_arr)


####################################################################################################################################"
#GET DATA LOCATION

config_path = "./data/flair-2-config.yml" # Change to yours
with open(config_path, "r") as f:
config = yaml.safe_load(f)


# Creation of the train, val and test dictionnaries with the data file paths
d_train = load_data(config)


images = d_train["PATH_IMG"]
labels = d_train["PATH_LABELS"]
sentinel_images = d_train["PATH_SP_DATA"]
sentinel_masks = d_train["PATH_SP_MASKS"] # Cloud masks
sentinel_products = d_train["PATH_SP_DATES"] # Needed to get the dates of the sentinel images
centroids = d_train["SP_COORDS"] # Position of the aerial image in the sentinel super area



indices= range (0, len(images))

# data = { 'MEAN': [], 'STD': [], }
Expand Down

0 comments on commit 9d55545

Please sign in to comment.