Skip to content

Commit

Permalink
add error raise option to skip because sometimes there is an issue on…
Browse files Browse the repository at this point in the history
… the image URL (#360)
  • Loading branch information
baslia authored Nov 18, 2024
1 parent 6cb8814 commit b310445
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ml_utils/ml_utils_cli/cli/apps/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ def add_prediction(
help="Launch in dry run mode, without uploading annotations to Label Studio"
),
] = False,
error_raise: Annotated[
bool,
typer.Option(
help="Raise an error if image download fails"
),
] = True,
):
"""Add predictions as pre-annotations to Label Studio tasks,
for an object detection model running on Triton Inference Server."""
Expand Down Expand Up @@ -245,7 +251,10 @@ def add_prediction(
threshold = 0.1

model = YOLO(model_name)
model.set_classes(labels)
if hasattr(model, "set_classes"):
model.set_classes(labels)
else:
logger.warning("The model does not support setting classes directly.")
elif backend == PredictorBackend.triton:
if triton_uri is None:
raise typer.BadParameter("Triton URI is required for Triton backend")
Expand All @@ -262,7 +271,7 @@ def add_prediction(
image_url = task.data["image_url"]
image = typing.cast(
Image.Image,
get_image_from_url(image_url, error_raise=True),
get_image_from_url(image_url, error_raise=error_raise),
)
if backend == PredictorBackend.ultralytics:
results = model.predict(
Expand Down

0 comments on commit b310445

Please sign in to comment.