Skip to content
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

DetecNet live inference without confidence in bounding box #1903

Open
wannn-one opened this issue Oct 14, 2024 · 0 comments
Open

DetecNet live inference without confidence in bounding box #1903

wannn-one opened this issue Oct 14, 2024 · 0 comments

Comments

@wannn-one
Copy link

Hi everyone,

I’m working on a live inference project using DetectNet with a custom SSD-MobileNet model on a Jetson device. My goal is to perform object detection and display bounding boxes without showing the confidence score within the bounding boxes.

Here’s what I’ve done so far:

  • I’m using jetson-inference to load the model and detect objects.
  • I tried using OverlayText to label the detected objects, but it always shows the confidence score, which I don't need.
  • I also tried directly drawing bounding boxes without any text, but I still want to label the detected classes (like "helmet", "no_helmet", etc.) without the extra confidence information.

Here’s a simplified version of my code:

from jetson_inference import detectNet
from jetson_utils import videoSource, videoOutput

# Load the model
net = detectNet(model="model/ssd-mobilenet-300e.onnx", labels="model/labels.txt", 
                 input_blob="input_0", output_cvg="scores", output_bbox="boxes", 
                 threshold=0.5)

# Initialize video source and display
camera = videoSource("/dev/video0")  # For real-time camera input
display = videoOutput("display://0") # For display output

while display.IsStreaming():
    img = camera.Capture()

    if img is None:  # Capture timeout
        continue

    # Detect objects
    detections = net.Detect(img)
    
    # Reset counts for this frame
    frame_counts = {
        "helmet": 0,
        "no_helmet": 0,
        "vest": 0,
        "no_vest": 0
    }
    
    # Count objects in the current frame
    for detection in detections:
        class_id = detection.ClassID
        if class_id in class_labels:
            label = class_labels[class_id]
            frame_counts[label] += 1
    
    display.Render(img)
    display.SetStatus(f"Detection | FPS: {net.GetNetworkFPS()}")

I also tried to change output_cvg to "coverage" and an error just occured

[TRT]    3: Cannot find binding of given name: coverage
[TRT]    failed to find requested output layer coverage in network
[TRT]    device GPU, failed to create resources for CUDA engine
[TRT]    failed to create TensorRT engine for model/ssd-mobilenet-300e.onnx, device GPU
[TRT]    detectNet -- failed to initialize.

Could anyone guide me on how to:

  • Draw bounding boxes with just class labels (e.g., "helmet") without the confidence score?
  • Avoid using OverlayText if it forces confidence display or any alternative solution to this?
    Any help or suggestions would be greatly appreciated!

Thanks in advance!

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

No branches or pull requests

1 participant