Skip to content

Commit 5b71b14

Browse files
No public description
PiperOrigin-RevId: 865720092
1 parent d79eeff commit 5b71b14

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

official/projects/waste_identification_ml/Deploy/detr_cloud_deployment/client/inference_pipeline.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def main(_) -> None:
135135

136136
# Perform Inference
137137
try:
138-
139138
results = model_manager.predict(
140139
image_path=image_path,
141140
confidence_threshold=PREDICTION_THRESHOLD.value,
@@ -154,14 +153,17 @@ def main(_) -> None:
154153
)
155154

156155
# Save the image with bounding boxes & masks
156+
if not results["class_names"].any():
157+
logger.info(f"No objects detected in {os.path.basename(image_path)}")
158+
continue
159+
157160
try:
158-
if results["class_names"].any():
159-
pil_image = Image.fromarray(image_for_saving)
160-
save_path = os.path.join(
161-
prediction_folder, os.path.basename(image_path)
162-
)
163-
utils.draw_detections_and_save_image(pil_image, results, save_path)
164-
logger.info("Image with bounding box saved")
161+
pil_image = Image.fromarray(image_for_saving)
162+
save_path = os.path.join(
163+
prediction_folder, os.path.basename(image_path)
164+
)
165+
utils.draw_detections_and_save_image(pil_image, results, save_path)
166+
logger.info("Image with bounding box saved")
165167
except (KeyError, IndexError, TypeError, ValueError) as e:
166168
logger.info(
167169
f"Issue in saving visualization of results, due to error : {e}"

0 commit comments

Comments
 (0)