Skip to content

Commit e2ecbf2

Browse files
authored
Fix image detection inference viz in gui (#611)
* Fix image detection inference viz in gui * Remove unused variables
1 parent 38fe6ea commit e2ecbf2

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

perceptionmetrics/models/torch_detection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class DetectionModelWrapper(torch.nn.Module):
270270
def __init__(self, model):
271271
super().__init__()
272272
self.inner_model = model
273-
273+
274274
# Handle input precision, tuple extraction, and output precision
275275
def forward(self, x):
276276
out = self.inner_model(x)

tabs/inference.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,15 @@ def inference_tab():
7474
with st.spinner("Running inference..."):
7575
try:
7676
image = Image.open(image_file).convert("RGB")
77-
predictions, sample_tensor = st.session_state.detection_model.predict(
78-
image, return_sample=True
79-
)
80-
from torchvision.transforms import v2 as transforms
77+
predictions = st.session_state.detection_model.predict(image)
8178

82-
img_to_draw = transforms.ToPILImage()(sample_tensor[0])
8379
label_map = getattr(
8480
st.session_state.detection_model, "idx_to_class_name", None
8581
)
86-
result_img = draw_detections(img_to_draw, predictions, label_map)
82+
result_img = draw_detections(image, predictions, label_map)
8783

8884
st.markdown("#### Detection Results")
89-
st.image(result_img, caption="Detection Results", width="stretch")
85+
st.image(result_img, caption="Detection Results", width="content")
9086

9187
# Display detection statistics
9288
if (

0 commit comments

Comments
 (0)