GithubHelp home page GithubHelp logo

Comments (7)

github-actions avatar github-actions commented on August 19, 2024

πŸ‘‹ Hello @AlessandroB1298, thank you for your interest in Ultralytics YOLOv8 πŸš€! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a πŸ› Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.

Install

Pip install the ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.

pip install ultralytics

Environments

YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

from ultralytics.

glenn-jocher avatar glenn-jocher commented on August 19, 2024

Hello!

Currently, TensorFlow.js does not natively support oriented bounding boxes (OBB) directly as part of its model operations. However, you can still use YOLOv8 models that output OBB by handling the orientation aspect in your post-processing logic after running the inference in TensorFlow.js.

You would need to export your YOLOv8 model to the TensorFlow.js format and then implement the logic to interpret the orientation data from the model's output in your application. This approach requires custom handling of the output tensors to manage the orientation.

For exporting YOLOv8 models to TensorFlow.js, you can follow the standard export procedure using the model.export(format='tfjs') method in Python.

If you need further guidance on handling the post-processing or any other specifics, feel free to ask!

from ultralytics.

AlessandroB1298 avatar AlessandroB1298 commented on August 19, 2024

from ultralytics.

glenn-jocher avatar glenn-jocher commented on August 19, 2024

Hello!

I'm glad to assist with the post-processing for OBB in TensorFlow.js! When you receive the output x, y, w, h, r from your model:

  • x and y are the center coordinates of the bounding box.
  • w and h are the width and height of the box.
  • r represents the rotation of the box in radians.

To translate these into a usable format in TensorFlow.js, you can create a function to calculate the corners of the rotated rectangle based on these parameters. Here's a basic example of how you might implement this:

function calculateCorners(x, y, w, h, r) {
    const angle = -r; // Adjust rotation direction if necessary
    const corners = [];
    const dx = [1, 1, -1, -1];
    const dy = [1, -1, -1, 1];

    for (let i = 0; i < 4; i++) {
        const cx = w * dx[i] / 2;
        const cy = h * dy[i] / 2;
        const cosA = Math.cos(angle);
        const sinA = Math.sin(angle);
        const nx = cx * cosA - cy * sinA;
        const ny = cx * sinA + cy * cosA;
        corners.push([x + nx, y + ny]);
    }
    return corners;
}

This function calculates the corners of the box which you can then use to draw or further process in your application. If you have any more questions or need further clarification, feel free to reach out! πŸš€

from ultralytics.

AlessandroB1298 avatar AlessandroB1298 commented on August 19, 2024

from ultralytics.

glenn-jocher avatar glenn-jocher commented on August 19, 2024

Hello!

I'm glad to hear that the previous information was helpful! Let's dive into your new question regarding processing the data with onnxruntime-web.

When you run inference and get 457 boxes, it means the model has detected multiple objects. The raw output from the model typically includes bounding box coordinates, confidence scores, and class probabilities. You'll need to parse this output to extract meaningful information.

Here's a step-by-step guide to process the output:

  1. Extract Bounding Boxes, Scores, and Classes:
    The output array contains the bounding box coordinates, confidence scores, and class probabilities. You need to reshape and interpret this data correctly.

  2. Filter by Confidence Score:
    To reduce the number of boxes, filter out those with low confidence scores.

  3. Non-Maximum Suppression (NMS):
    Apply NMS to eliminate redundant boxes that overlap significantly.

Here's an example of how you might implement this in JavaScript:

// Function to process the model output
const processOutput = (output, confidenceThreshold = 0.5, iouThreshold = 0.5) => {
    const boxes = [];
    const scores = [];
    const classes = [];

    // Assuming output is a flat array, reshape and extract data
    for (let i = 0; i < output.length; i += 6) {
        const score = output[i + 4];
        if (score > confidenceThreshold) {
            const x = output[i];
            const y = output[i + 1];
            const w = output[i + 2];
            const h = output[i + 3];
            const classId = output[i + 5];
            boxes.push([x, y, w, h]);
            scores.push(score);
            classes.push(classId);
        }
    }

    // Apply Non-Maximum Suppression (NMS)
    const nmsIndices = applyNMS(boxes, scores, iouThreshold);
    const finalBoxes = nmsIndices.map(index => boxes[index]);
    const finalScores = nmsIndices.map(index => scores[index]);
    const finalClasses = nmsIndices.map(index => classes[index]);

    return { boxes: finalBoxes, scores: finalScores, classes: finalClasses };
};

// Function to apply Non-Maximum Suppression (NMS)
const applyNMS = (boxes, scores, iouThreshold) => {
    // Implement NMS logic here
    // This is a placeholder for the actual NMS implementation
    return []; // Return indices of the boxes to keep
};

// Example usage
const runModel = async (input) => {
    input = new ort.Tensor(Float32Array.from(input), [1, 3, 640, 640]);
    const outputs = await model.run({ images: input });
    const rawOutput = outputs["output0"].data;
    const processedOutput = processOutput(rawOutput);

    console.log(processedOutput);
    return processedOutput;
};

In this example:

  • processOutput function filters boxes based on a confidence threshold and applies NMS.
  • applyNMS is a placeholder for the actual NMS implementation. You can use libraries like tf.image.nonMaxSuppression in TensorFlow.js or implement your own NMS logic.

Feel free to adjust the confidence and IoU thresholds as needed. If you have any more questions or need further assistance, don't hesitate to reach out! 😊

from ultralytics.

github-actions avatar github-actions commented on August 19, 2024

πŸ‘‹ Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO πŸš€ and Vision AI ⭐

from ultralytics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.