Skip to content

Commit 292c139

Browse files
committed
feat: multiple region test images for global model
1 parent c2c8be1 commit 292c139

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

trapdata/api/demo.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def predict(*img_paths, Classifier: typing.Type[MothClassifier]):
113113
from functools import partial
114114

115115

116-
def make_interface(Classifier: MothClassifier, example_images_subdir=""):
116+
def make_interface(Classifier: MothClassifier, example_images_subdirs: list[str]=[]):
117117
return gr.Interface(
118118
title=Classifier.name,
119119
description=Classifier.description,
@@ -124,19 +124,19 @@ def make_interface(Classifier: MothClassifier, example_images_subdir=""):
124124
gr.Gallery(label="Classified Crops"),
125125
],
126126
examples=[
127-
img.filepath for img in get_test_images(subdir=example_images_subdir)
127+
img.filepath for img in get_test_images(subdirs=example_images_subdirs)
128128
],
129129
)
130130

131131

132132
app = gr.TabbedInterface(
133133
[
134-
make_interface(MothClassifierPanama, "panama"), # type: ignore
135-
make_interface(MothClassifierPanama2024, "panama"), # type: ignore
136-
make_interface(MothClassifierUKDenmark, "denmark"), # type: ignore
137-
make_interface(MothClassifierQuebecVermont, "vermont"), # type: ignore
138-
make_interface(MothClassifierTuringCostaRica, "costarica"), # type: ignore
139-
make_interface(MothClassifierGlobal, "vermont"), # type: ignore
134+
make_interface(MothClassifierPanama, ["panama"]),
135+
make_interface(MothClassifierPanama2024, ["panama"]),
136+
make_interface(MothClassifierUKDenmark, ["denmark"]),
137+
make_interface(MothClassifierQuebecVermont, ["vermont"]),
138+
make_interface(MothClassifierTuringCostaRica, ["costarica"]),
139+
make_interface(MothClassifierGlobal, ["vermont", "panama", "denmark", "costarica"]),
140140
],
141141
[
142142
"Panama 2023",

trapdata/api/tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ def make_image():
6161
return f.name
6262

6363

64-
def get_test_images(subdir: str = "vermont") -> list[SourceImage]:
64+
def get_test_images(subdirs: list[str] = ["vermont", "panama"]) -> list[SourceImage]:
6565
return [
6666
SourceImage(id=str(img["path"].name), filepath=img["path"])
67+
for subdir in subdirs
6768
for img in find_images(pathlib.Path(TEST_IMAGES_BASE_PATH) / subdir)
6869
]
6970

0 commit comments

Comments
 (0)