Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion perceptionmetrics/models/torch_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class DetectionModelWrapper(torch.nn.Module):
def __init__(self, model):
super().__init__()
self.inner_model = model

# Handle input precision, tuple extraction, and output precision
def forward(self, x):
out = self.inner_model(x)
Expand Down
10 changes: 3 additions & 7 deletions tabs/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,15 @@ def inference_tab():
with st.spinner("Running inference..."):
try:
image = Image.open(image_file).convert("RGB")
predictions, sample_tensor = st.session_state.detection_model.predict(
image, return_sample=True
)
from torchvision.transforms import v2 as transforms
predictions = st.session_state.detection_model.predict(image)

img_to_draw = transforms.ToPILImage()(sample_tensor[0])
label_map = getattr(
st.session_state.detection_model, "idx_to_class_name", None
)
result_img = draw_detections(img_to_draw, predictions, label_map)
result_img = draw_detections(image, predictions, label_map)

st.markdown("#### Detection Results")
st.image(result_img, caption="Detection Results", width="stretch")
st.image(result_img, caption="Detection Results", width="content")

# Display detection statistics
if (
Expand Down
Loading