Skip to content

Commit

Permalink
[FIX] delete unwanted classes (1, 1.)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCretois committed Oct 16, 2024
1 parent bddcfa9 commit 0ee39bf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dataset/rasterize_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def rasterize_masks(
gdf = gpd.read_file(geojson_path)

# Factorize the text labels to get numeric labels
gdf = gdf[gdf["labelTekst"] != "1"]
gdf = gdf[gdf["labelTekst"] != "1."]
gdf["label_encoded"], _ = pd.factorize(gdf[label_column])
gdf["label_encoded"] = gdf["label_encoded"]

Expand Down Expand Up @@ -91,9 +93,7 @@ def rasterize_masks(

# Save the mask as .tif to ensure saving of negative values
mask_filename = f"mask_{image_id}.tif"
mask_img = Image.fromarray(
mask.astype(np.int16)
) # Ensure it's int16 for -1 values
mask_img = Image.fromarray(mask.astype(np.int16))
mask_img.save(os.path.join(output_mask_dir, mask_filename))

print(f"Saved mask: {mask_filename}")
Expand Down

0 comments on commit 0ee39bf

Please sign in to comment.