Skip to content

Commit d8b9d6a

Browse files
committed
Pass all tests by the added binary segmentation exameple
1 parent f27134f commit d8b9d6a

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

Makefile

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
1-
.PHONY: test
1+
.PHONY: test # Declare the 'test' target as phony to avoid conflicts with files named 'test'
22

3+
# Variables to store the paths of the python, pip, pytest, and ruff executables
4+
PYTHON := $(shell which python)
5+
PIP := $(shell which pip)
6+
PYTEST := $(shell which pytest)
7+
RUFF := $(shell which ruff)
8+
9+
# Target to create a Python virtual environment
310
.venv:
4-
python3 -m venv .venv
11+
$(PYTHON) -m venv $(shell dirname $(PYTHON))
512

13+
# Target to install development dependencies in the virtual environment
614
install_dev: .venv
7-
.venv/bin/pip install -e ".[test]"
15+
$(PIP) install -e ".[test]"
816

17+
# Target to run tests with pytest, using 2 parallel processes and only non-marked tests
918
test: .venv
10-
.venv/bin/pytest -v -rsx -n 2 tests/ --non-marked-only
19+
$(PYTEST) -v -rsx -n 2 tests/ --non-marked-only
1120

21+
# Target to run all tests with pytest, including slow tests, using 2 parallel processes
1222
test_all: .venv
13-
RUN_SLOW=1 .venv/bin/pytest -v -rsx -n 2 tests/
23+
RUN_SLOW=1 $(PYTEST) -v -rsx -n 2 tests/
1424

25+
# Target to generate a table by running a Python script
1526
table:
16-
.venv/bin/python misc/generate_table.py
27+
$(PYTHON) misc/generate_table.py
1728

29+
# Target to generate a table for timm by running a Python script
1830
table_timm:
19-
.venv/bin/python misc/generate_table_timm.py
31+
$(PYTHON) misc/generate_table_timm.py
2032

33+
# Target to fix and format code using ruff
2134
fixup:
22-
.venv/bin/ruff check --fix
23-
.venv/bin/ruff format
35+
$(RUFF) check --fix
36+
$(RUFF) format
2437

38+
# Target to run code formatting and tests
2539
all: fixup test
26-

examples/binary_segmentation_buildings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@
7272
# ----------------------------
7373
# Download the CamVid dataset, if needed
7474
# ----------------------------
75-
main_dir = "./examples/binary_segmentation_data/" # Change this to your desired directory
75+
main_dir = (
76+
"./examples/binary_segmentation_data/" # Change this to your desired directory
77+
)
7678

7779
data_dir = os.path.join(main_dir, "dataset")
7880
if not os.path.exists(data_dir):
@@ -246,7 +248,6 @@ def visualize(output_dir, image_filename, **images):
246248
def train_and_evaluate_one_epoch(
247249
model, train_dataloader, valid_dataloader, optimizer, scheduler, loss_fn, device
248250
):
249-
250251
# Set the model to training mode
251252
model.train()
252253
train_loss = 0
@@ -321,7 +322,6 @@ def train_model(
321322

322323

323324
def test_model(model, output_dir, test_dataloader, loss_fn, device):
324-
325325
# Set the model to evaluation mode
326326
model.eval()
327327
test_loss = 0

0 commit comments

Comments
 (0)