Code Monkey home page Code Monkey logo

Comments (2)

zldrobit avatar zldrobit commented on July 24, 2024

These lines of code is basically building output from previous convolutions, which is part of the yolov5 Detect module.

a = torch.tensor(anchors).float().view(nl, -1, 2).to(device)
anchor_grid = a.clone().view(nl, 1, -1, 1, 2)  # shape(nl,1,na,1,2)

builds anchors, which read from yaml files (I will change it to read from *.pt weights ultralytics/yolov5#1127 (comment)).

    _, _, ny_nx, _ = x[i].shape
    r = imgsz[0] / imgsz[1]
    nx = int(np.sqrt(ny_nx / r))
    ny = int(r * nx)

gets the output shape ny (vertical) and nx (horizontal) of the i-th yolo head.

    grid[i] = _make_grid(nx, ny).to(x[i].device)

creates meshgrid from the shape ny and nx.

    y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + grid[i].to(x[i].device)) * stride  # xy
    y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * anchor_grid[i]  # wh

are the equations to output center coordinates xy and, width and height of the output bounding boxes.

Or you could post your question on the PRs:
ultralytics/yolov5#959
ultralytics/yolov5#1127

from onnx_tflite_yolov3.

zldrobit avatar zldrobit commented on July 24, 2024

Close this issue due to there're other suitable places for this issue (ultralytics/yolov5#959, ultralytics/yolov5#1127).

from onnx_tflite_yolov3.

Related Issues (12)

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.