Skip to content

[Bug fix & New feature] support non square sized input #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

developer0hye
Copy link

@developer0hye developer0hye commented Apr 16, 2025

Description

Support non square sized input

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

For a test, it needs some modification for test. But I didn't include these parts. I will submit PR for training, export and validation code for non square sized rf-detr.

import io
import requests
import supervision as sv
from PIL import Image
from rfdetr import RFDETRBase

model = RFDETRBase(resolution=(616, 560))
CLASS_NAMES = model.class_names

url = "https://media.roboflow.com/notebooks/examples/dog-2.jpeg"

image = Image.open(io.BytesIO(requests.get(url).content))
detections = model.predict(image, threshold=0.5)

labels = [
    f"{CLASS_NAMES[class_id]} {confidence:.2f}"
    for class_id, confidence
    in zip(detections.class_id, detections.confidence)
]

annotated_image = image.copy()
annotated_image = sv.BoxAnnotator().annotate(annotated_image, detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections, labels)

sv.plot_image(annotated_image)

image

image

image

It failed to detect the person at the center point, which I believe is due to the model being trained only on square-shaped images. Still, it worked! This update marks the first step toward supporting non-square shapes.

image

Any specific deployment considerations

For example, documentation changes, usability, usage/costs, secrets, etc.

Docs

  • Docs updated? What were the changes:
    Future works

@imerad
Copy link

imerad commented Apr 22, 2025

This could be a very useful PR but I only see one commit which doesn't seem to include the changes on the screenshots. Did you forget to commit and push them ?

@developer0hye
Copy link
Author

@imerad I think so. I didn't include other commits because I should implement the code for training to fully support non square inputs. But I think this commit will be the important point for supporting non square input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants