Skip to content

Commit

Permalink
demo checks fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
arzamnik committed Jun 8, 2022
1 parent 390ad11 commit 2b21994
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
26 changes: 16 additions & 10 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,24 @@ def convert_preds_to_sly_annotation(
raise ValueError(f"Prediction does not contain class name. Prediction dict: {prediction}")
box = prediction["bbox"]
sly_rect = sly.Rectangle(box[0], box[1], box[2], box[3])
try:
sly_obj_class = model_meta.get_obj_class(prediction["class"])
except KeyError as e:
raise ValueError("Predicted class name was not added to \
get_classes_and_tags(). Please add this class and try again.")

if "confidence" in prediction.keys():
if model_meta is not None:
try:
sly_tag_meta = model_meta.get_tag_meta("confidence")
sly_obj_class = model_meta.get_obj_class(prediction["class"])
except KeyError as e:
raise ValueError("Predicted confidence tag name was not added to \
get_classes_and_tags(). Please add this tag and try again.")
raise ValueError("Predicted class name was not added to \
get_classes_and_tags(). Please add this class and try again.")
else:
sly_obj_class = sly.ObjClass(prediction["class"], sly.Rectangle)

if "confidence" in prediction.keys():
if model_meta is not None:
try:
sly_tag_meta = model_meta.get_tag_meta("confidence")
except KeyError as e:
raise ValueError("Predicted confidence tag name was not added to \
get_classes_and_tags(). Please add this tag and try again.")
else:
sly_tag_meta = sly.TagMeta("confidence", sly.TagValueType.ANY_NUMBER)

if not isinstance(prediction["confidence"], float):
raise TypeError(f"Predicted confidence of type {type(prediction['confidence'])} \
Expand Down
1 change: 0 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def get_session_info() -> Dict:


def inference(image_path: str) -> List[Dict]:
global my_model
image = sly.image.read(path=image_path) # shape: [H, W, 3], RGB

#########################
Expand Down

0 comments on commit 2b21994

Please sign in to comment.