Coder Social home page Coder Social logo

location: "models/yolo_layer.py", line 438,error: obj_mask[b, a, j, i] = 1 IndexError: index 40 is out of bounds for dimension 0 with size 40 about pytorch_yolov3 HOT 3 CLOSED

dena avatar dena commented on July 16, 2024
location: "models/yolo_layer.py", line 438,error: obj_mask[b, a, j, i] = 1 IndexError: index 40 is out of bounds for dimension 0 with size 40

from pytorch_yolov3.

Comments (3)

BucolicWind avatar BucolicWind commented on July 16, 2024
        for ti in range(best_n.shape[0]):
            if best_n_mask[ti] == 1:
                i, j = truth_i[ti], truth_j[ti]
                a = best_n[ti]
                obj_mask[b, a, j, i] = 1
                tgt_mask[b, a, j, i, :] = 1
                target[b, a, j, i, 0] = truth_x_all[b, ti] - \
                    truth_x_all[b, ti].to(torch.int16).to(torch.float)
                target[b, a, j, i, 1] = truth_y_all[b, ti] - \
                    truth_y_all[b, ti].to(torch.int16).to(torch.float)
                target[b, a, j, i, 2] = torch.log(
                    truth_w_all[b, ti] / torch.Tensor(self.masked_anchors)[best_n[ti], 0] + 1e-16)
                target[b, a, j, i, 3] = torch.log(
                    truth_h_all[b, ti] / torch.Tensor(self.masked_anchors)[best_n[ti], 1] + 1e-16)
                target[b, a, j, i, 4] = 1
                target[b, a, j, i, 5 + labels[b, ti,
                                              0].to(torch.int16).numpy()] = 1
                tgt_scale[b, a, j, i, :] = torch.sqrt(
                    2 - truth_w_all[b, ti] * truth_h_all[b, ti] / fsize / fsize)

I try to change this code to train my data, error occurred during the code above.

from pytorch_yolov3.

hirotomusiker avatar hirotomusiker commented on July 16, 2024

Hi,
The dimension 0 of obj_mask should be batchsize and 'b' stands for the current batch number in the for loop.

        obj_mask = torch.ones(batchsize, self.n_anchors,
                              fsize, fsize).type(dtype)
        for b in range(batchsize):
...
                obj_mask[b, a, j, i] = 1

So b changes from 0 to 39 if your batchsize is 40.

Which part of yolo_layer.py have you changed?

from pytorch_yolov3.

hirotomusiker avatar hirotomusiker commented on July 16, 2024

@BucolicWind
Please put your reply on this thread.

Hi, I simply copy your code and run,but i will also meet this problem.i changed the bctchsize to 8 >when training in the visdrone dataset,

If you train on visdrone, you should have changed something - dataloader, config,.. and so on.

And

location: "models/yolo_layer.py", line 438

The original yolo_layer.py does not have 438th line. Please let us know if you customized the code.

Thank you.

from pytorch_yolov3.

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.