summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPseudozoid <sarathmadhavr@gmail.com>2024-04-21 13:03:50 +0530
committerPseudozoid <sarathmadhavr@gmail.com>2024-04-21 13:03:50 +0530
commitb08f804766e9bf6689424fec56633f5e81d96218 (patch)
tree84428fb730e020bcee671e9bbde9cfb3648e1212
parentae765911121bd4bb415237033f7a914a6b6536d5 (diff)
added json output for prediction
-rw-r--r--main.py18
-rw-r--r--syringe.jpgbin0 -> 259592 bytes
-rw-r--r--test.txt0
3 files changed, 18 insertions, 0 deletions
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..2b9922f
--- /dev/null
+++ b/main.py
@@ -0,0 +1,18 @@
+from roboflow import Roboflow
+import json
+rf = Roboflow(api_key="otKMUXAELXaU2XZsT77M")
+project = rf.workspace().project("biomedical-wastes")
+model = project.version(3).model
+
+# infer on a local image
+json_response = model.predict("./syringe.jpg", confidence=40, overlap=30).json()
+
+# 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
diff --git a/syringe.jpg b/syringe.jpg
new file mode 100644
index 0000000..83ddc67
--- /dev/null
+++ b/syringe.jpg
Binary files differ
diff --git a/test.txt b/test.txt
deleted file mode 100644
index e69de29..0000000
--- a/test.txt
+++ /dev/null