Skip to content

Commit

Permalink
add data augmentation notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
sfmig committed Mar 27, 2024
1 parent f2c481f commit c392410
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions notebooks/notebook_data_augm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# %%
import yaml # type: ignore

from crabs.detection_tracking.datamodules import CrabsDataModule
from crabs.detection_tracking.visualization import plot_sample

# %%%%%%%%%%%%%%%%%%%
# Input data
IMG_DIR = "/Users/sofia/arc/project_Zoo_crabs/sep2023-full/frames"
ANNOT_FILE = "/Users/sofia/arc/project_Zoo_crabs/sep2023-full/annotations/VIA_JSON_combined_coco_gen.json"
CONFIG = "/Users/sofia/arc/project_Zoo_crabs/restructure/crabs-exploration/crabs/detection_tracking/config/faster_rcnn.yaml"
SPLIT_SEED = 42

# %%%%%%%%%%%%%%%%%%%%
# Read config as dict
with open(CONFIG, "r") as f:
config_dict = yaml.safe_load(f)

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Create datamodule for the input data
dm = CrabsDataModule(
[IMG_DIR],
[ANNOT_FILE],
config_dict,
SPLIT_SEED,
)
# %%%%%%%%%%%%%%%%%%%%%%%%
# Setup for train / test
dm.prepare_data()
dm.setup("fit")


# %%%%%%%%%%%%%%%%%%%%%%%%%%%
# after this: dm.train_dataset should have transforms, (but not dm.test_dataset)
print(dm.train_transform)
print(dm.val_transform)
print(dm.test_transform)

# %%
train_dataset = dm.train_dataset
train_sample = train_dataset[0]
plot_sample([train_sample])

# %%

0 comments on commit c392410

Please sign in to comment.