Spaces:
Runtime error
Runtime error
pratikshahp
commited on
Commit
•
d5348f1
1
Parent(s):
fcb3849
Update app.py
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ if submit:
|
|
46 |
image_data=input_image_setup(uploaded_file)
|
47 |
st.subheader("The response is..")
|
48 |
#process with model
|
49 |
-
inputs = processor(images=
|
50 |
outputs = model(**inputs)
|
51 |
|
52 |
# model predicts bounding boxes and corresponding COCO classes
|
@@ -56,8 +56,8 @@ if submit:
|
|
56 |
target_sizes = torch.tensor([image.size[::-1]])
|
57 |
results = image_processor.post_process_object_detection(outputs, threshold=0.9, target_sizes=target_sizes)[0]
|
58 |
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
46 |
image_data=input_image_setup(uploaded_file)
|
47 |
st.subheader("The response is..")
|
48 |
#process with model
|
49 |
+
inputs = processor(images=image_data, return_tensors="pt")
|
50 |
outputs = model(**inputs)
|
51 |
|
52 |
# model predicts bounding boxes and corresponding COCO classes
|
|
|
56 |
target_sizes = torch.tensor([image.size[::-1]])
|
57 |
results = image_processor.post_process_object_detection(outputs, threshold=0.9, target_sizes=target_sizes)[0]
|
58 |
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
59 |
+
box = [round(i, 2) for i in box.tolist()]
|
60 |
+
print(
|
61 |
+
f"Detected {model.config.id2label[label.item()]} with confidence "
|
62 |
+
f"{round(score.item(), 3)} at location {box}"
|
63 |
+
)
|