Skip to content

Commit 1c54f5d

Browse files
authored
- fixes a small bug with detection_filter so that instance methods (#308)
should work...so hypothetically one could create a detection filter like: ```python class DetectionFilter(): def init(self, data): self.data = data def __call__(self, box, mask, logit, phrase, i): return phrase == self.data sam.predict(..., detection_filter=DetectionFilter(data='mystring')) ```
1 parent 409953a commit 1c54f5d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

samgeo/text_sam.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def predict(
257257
save_args (dict, optional): Save arguments for the prediction. Defaults to {}.
258258
return_results (bool, optional): Whether to return the results. Defaults to False.
259259
detection_filter (callable, optional):
260-
Callable which with box, mask, logit, phrase, and index args returns a boolean.
260+
Callable with box, mask, logit, phrase, and index args returns a boolean.
261261
If provided, the function will be called for each detected object.
262262
Defaults to None.
263263
@@ -325,8 +325,7 @@ def predict(
325325
if not callable(detection_filter):
326326
raise ValueError("detection_filter must be callable.")
327327

328-
req_nargs = 6 if inspect.ismethod(detection_filter) else 5
329-
if not len(inspect.signature(detection_filter).parameters) == req_nargs:
328+
if not len(inspect.signature(detection_filter).parameters) == 5:
330329
raise ValueError(
331330
"detection_filter required args: "
332331
"box, mask, logit, phrase, and index."

0 commit comments

Comments
 (0)