Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion vla/benchmarks/block_type_classification/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class LabelType(str, Enum):
class ConfigPaths:
path_to_raw_data = None
feature_store_path = "./precomputed"
generalization_set_folder = ""
train_json = "train_los_dataset.json"
test_json = "test_los_dataset.json"

class TrainConfig:
learning_rate = 1e-3
Expand All @@ -18,6 +21,7 @@ class TrainConfig:
layers_sizes = [512]

def construct_configs(path_to_raw_data=None, feature_store_path=None,
generalization_set_folder="", train_json="train_los_dataset.json", test_json="test_los_dataset.json",
learning_rate=1e-3, momentum=0.9, epochs=10, output_activation="none", num_layers=1, layers_sizes=[512]):
TrainConfig.learning_rate = learning_rate
TrainConfig.momentum = momentum
Expand All @@ -33,4 +37,7 @@ def construct_configs(path_to_raw_data=None, feature_store_path=None,
warnings.warn("Feature store path is not set by config. If benchmark will be ran with use_precomputed_features "
"default folder ./precomputed will be used to store features")
else:
ConfigPaths.feature_store_path = feature_store_path
ConfigPaths.feature_store_path = feature_store_path
ConfigPaths.generalization_set_folder = generalization_set_folder
ConfigPaths.train_json = train_json
ConfigPaths.test_json = test_json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import json
from manager import DatasetManager
from config import LabelType
from config import LabelType, ConfigPaths, construct_configs


if __name__ == "__main__":
with open("example_config.json", 'r') as f:
config_dict = json.load(f)
construct_configs(**config_dict)

manager = DatasetManager(
directory="./2025_LOS/Day_clear/",
directory=ConfigPaths.path_to_raw_data,
label_type=LabelType.DISTANCE,
dataset_size=200,
train_split=0.25,
Expand Down
3 changes: 3 additions & 0 deletions vla/benchmarks/block_type_classification/example_config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"path_to_raw_data" : "./2025_LOS",
"feature_store_path" : "./precomputed",
"generalization_set_folder" : "./2025_LOS/Night_clear/Mountain_Range",
"train_json" : "train_los_dataset.json",
"test_json" : "test_los_dataset.json",
"learning_rate" : 1e-3,
"momentum" : 0.9,
"epochs" : 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
preprocessor,
label_type=LabelType.DISTANCE,
random_seed=10,
generalization_set_folder="./2025_LOS/Night_clear/Mountain_Range",
config_path="example_config.json"
)
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def encode(self, x):
benchmark(
ModelWrapper(),
preprocess,
label_type=LabelType.DISTANCE, #LabelType.TYPE_CLASSIFICATION, #
label_type=LabelType.DISTANCE,
random_seed=10,
generalization_set_folder="./2025_LOS/Night_clear/Mountain_Range",
config_path="example_config.json"
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ def encode(self, x):
benchmark(
ModelWrapper(),
preprocess,
label_type=LabelType.TYPE_CLASSIFICATION, #LabelType.DISTANCE,
label_type=LabelType.TYPE_CLASSIFICATION,
random_seed=10,
generalization_set_folder="./2025_LOS/Night_clear/Mountain_Range",
config_path="example_config.json"
)

15 changes: 7 additions & 8 deletions vla/benchmarks/block_type_classification/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ def score(model, classifier, loader, label_type: LabelType, device):
raise ValueError(f"Unsupported label type {label_type}")


def benchmark(model, preprocessor, train_json="train_los_dataset.json", test_json="test_los_dataset.json",
label_type=LabelType.DISTANCE, use_precomputed_features=True, random_seed=None,
generalization_set_folder="", config_path="example_config.json"):
def benchmark(model, preprocessor, label_type=LabelType.DISTANCE,
use_precomputed_features=True, random_seed=None, config_path="example_config.json"):

with open(config_path, 'r') as file:
config_dict = json.load(file)
Expand All @@ -166,18 +165,18 @@ def benchmark(model, preprocessor, train_json="train_los_dataset.json", test_jso
dataset_manager = DatasetManager(ConfigPaths.path_to_raw_data, label_type, random_seed=random_seed)

generalization_dataset_manager = None
if generalization_set_folder != "":
generalization_dataset_manager = DatasetManager(generalization_set_folder, label_type, random_seed=random_seed,
full_folder=True)
if ConfigPaths.generalization_set_folder:
generalization_dataset_manager = DatasetManager(ConfigPaths.generalization_set_folder, label_type,
random_seed=random_seed, full_folder=True)

store = FeatureStore(ConfigPaths.feature_store_path)

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

train_loader, test_loader, score_loader, generalization_loader, num_classes = \
make_dataloaders(
train_json,
test_json,
ConfigPaths.train_json,
ConfigPaths.test_json,
label_type,
preprocessor,
feature_store=(store if use_precomputed_features else None),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
class ConfigPaths:
path_to_raw_data = None
feature_store_path = "./precomputed"
generalization_set_folder = ""
train_json = "train_los_dataset.json"
test_json = "test_los_dataset.json"

class TrainConfig:
learning_rate = 1e-3
Expand All @@ -14,6 +17,7 @@ class TrainConfig:
layers_sizes = [512]

def construct_configs(path_to_raw_data=None, feature_store_path=None,
generalization_set_folder="", train_json="train_los_dataset.json", test_json="test_los_dataset.json",
learning_rate=1e-3, momentum=0.9, epochs=10, output_activation="none", num_layers=1, layers_sizes=[512]):
TrainConfig.learning_rate = learning_rate
TrainConfig.momentum = momentum
Expand All @@ -29,4 +33,7 @@ def construct_configs(path_to_raw_data=None, feature_store_path=None,
warnings.warn("Feature store path is not set by config. If benchmark will be ran with use_precomputed_features "
"default folder ./precomputed will be used to store features")
else:
ConfigPaths.feature_store_path = feature_store_path
ConfigPaths.feature_store_path = feature_store_path
ConfigPaths.generalization_set_folder = generalization_set_folder
ConfigPaths.train_json = train_json
ConfigPaths.test_json = test_json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"path_to_raw_data" : "./2026_LOS_SEGM",
"feature_store_path" : "./precomputed",
"generalization_set_folder" : "./2026_LOS_SEGM/Night_clear/Mountain_Range",
"train_json" : "train_los_dataset.json",
"test_json" : "test_los_dataset.json",
"learning_rate" : 1e-3,
"momentum" : 0.9,
"epochs" : 20,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# This file is used to convert segmented images to npy files which contains class distribution
import json
import numpy as np
from pathlib import Path
from PIL import Image

with open("example_config.json", 'r') as f:
config = json.load(f)

paths = []
unique_colors_list = []
basepath = Path("./2026_LOS_SEGM")
basepath = Path(config["path_to_raw_data"])
segmentation_subfolders = list(basepath.rglob("segmentation"))

stub = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Dinov2Features_full(),
preprocessor,
random_seed=10,
generalization_set_folder="./2026_LOS_SEGM/Night_clear/Mountain_Range",
config_path="example_config.json",
use_precomputed_features=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def encode(self, x):
ModelWrapper(),
preprocess,
random_seed=10,
generalization_set_folder="./2026_LOS_SEGM/Night_clear/Mountain_Range",
config_path="example_config.json",
use_precomputed_features=False
)
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def encode(self, x):
ModelWrapper(),
preprocess,
random_seed=10,
generalization_set_folder="./2026_LOS_SEGM/Night_clear/Mountain_Range",
config_path="example_config.json",
use_precomputed_features=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def encode(self, x):
ResnetWrapper(),
preprocess,
random_seed=10,
generalization_set_folder="./2026_LOS_SEGM/Night_clear/Mountain_Range",
config_path="example_config.json",
use_precomputed_features=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def encode(self, x):
SiglipWrapper(),
preprocess,
random_seed=10,
generalization_set_folder="./2026_LOS_SEGM/Night_clear/Mountain_Range",
config_path="example_config.json",
use_precomputed_features=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def encode(self, x):
Yolo11Wrapper(),
preprocess,
random_seed=10,
generalization_set_folder="./2026_LOS_SEGM/Night_clear/Mountain_Range",
config_path="example_config.json",
use_precomputed_features=True
)
13 changes: 6 additions & 7 deletions vla/benchmarks/class_distribution_using_segmentation/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ def train_classifier(

return classifier

def benchmark(model, preprocessor, train_json="train_los_dataset.json", test_json="test_los_dataset.json",
use_precomputed_features=True, random_seed=None,
generalization_set_folder="", config_path="example_config.json"):
def benchmark(model, preprocessor, use_precomputed_features=True, random_seed=None,
config_path="example_config.json"):

with open(config_path, 'r') as file:
config_dict = json.load(file)
Expand All @@ -127,8 +126,8 @@ def benchmark(model, preprocessor, train_json="train_los_dataset.json", test_jso
dataset_manager = DatasetManager(ConfigPaths.path_to_raw_data, random_seed=random_seed)

generalization_dataset_manager = None
if generalization_set_folder != "":
generalization_dataset_manager = DatasetManager(generalization_set_folder, random_seed=random_seed,
if ConfigPaths.generalization_set_folder:
generalization_dataset_manager = DatasetManager(ConfigPaths.generalization_set_folder, random_seed=random_seed,
full_folder=True)

store = FeatureStore(os.path.join(ConfigPaths.feature_store_path, type(model).__name__))
Expand All @@ -137,8 +136,8 @@ def benchmark(model, preprocessor, train_json="train_los_dataset.json", test_jso

train_loader, test_loader, score_loader, generalization_loader, num_classes = \
make_dataloaders(
train_json,
test_json,
ConfigPaths.train_json,
ConfigPaths.test_json,
preprocessor,
feature_store=(store if use_precomputed_features else None),
workers=8,
Expand Down