summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPseudozoid <sarathmadhavr@gmail.com>2024-04-21 13:45:27 +0530
committerPseudozoid <sarathmadhavr@gmail.com>2024-04-21 13:45:27 +0530
commit7bfe5069163fc0475f9f9a51ddbc16143f064d3d (patch)
treec828133ddd8644115f18344d92a68d4a0e5672e8
parentb08f804766e9bf6689424fec56633f5e81d96218 (diff)
verbose detection message
-rw-r--r--main.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/main.py b/main.py
index 2b9922f..ec2a423 100644
--- a/main.py
+++ b/main.py
@@ -7,12 +7,14 @@ model = project.version(3).model
# infer on a local image
json_response = model.predict("./syringe.jpg", confidence=40, overlap=30).json()
+threshold = 0.8
+for prediction in json_response["predictions"]:
+ if prediction["confidence"] > threshold:
+ # Do something specific
+ print("Syringe detected!")
+ break;
+
# save the JSON response to a file
with open('output.json', 'w') as f:
json.dump(json_response, f)
-# visualize your prediction
-# model.predict("your_image.jpg", confidence=40, overlap=30).save("prediction.jpg")
-
-# infer on an image hosted elsewhere
-# print(model.predict("URL_OF_YOUR_IMAGE", hosted=True, confidence=40, overlap=30).json()) \ No newline at end of file