GithubHelp home page GithubHelp logo

Comments (3)

glenn-jocher avatar glenn-jocher commented on June 16, 2024

Hello!

It looks like you've done a good job implementing your custom module and integrating it with the YOLOv8 architecture. The error you're facing suggests that the mymodule isn't receiving the second required input input2 during the forward pass.

In your tasks.py file, make sure that when you call mymodule, both input tensors are passed correctly. From your description, it seems you want to fetch outputs from two layers for use as inputs. Here's how you can adjust that:

elif m is mymodule:
    args = [ch[-1], ch[10]]  # This will pass the outputs from layers indexed at -1 and 10

Make sure that the indices -1 and 10 correctly refer to the outputs from the specific layers you intend to use as inputs.

After adjusting this in tasks.py, your module should receive both inputs as expected. Please try this modification, and I hope your training runs smoothly! Let me know if you encounter any further issues.

from ultralytics.

N0lanakis avatar N0lanakis commented on June 16, 2024

Thanks for the answer. @glenn-jocher

i tried to fix that but it still dont work.

i add

elif m is mymodule: #temporary dependancy
args = [ch[-1],ch[10]]

File "/usr/src/ultralytics/myutils/train.py", line 9, in
model = YOLO('/usr/src/ultralytics/myutils/yolov8l-seg-test.yaml')
File "/usr/src/ultralytics/ultralytics/models/yolo/model.py", line 23, in init
super().init(model=model, task=task, verbose=verbose)
File "/usr/src/ultralytics/ultralytics/engine/model.py", line 140, in init
self._new(model, task=task, verbose=verbose)
File "/usr/src/ultralytics/ultralytics/engine/model.py", line 211, in _new
self.model = (model or self._smart_load("model"))(cfg_dict, verbose=verbose and RANK == -1) # build model
File "/usr/src/ultralytics/ultralytics/nn/tasks.py", line 369, in init
super().init(cfg=cfg, ch=ch, nc=nc, verbose=verbose)
File "/usr/src/ultralytics/ultralytics/nn/tasks.py", line 299, in init
m.stride = torch.tensor([s / x.shape[-2] for x in forward(torch.zeros(1, ch, s, s))]) # forward
File "/usr/src/ultralytics/ultralytics/nn/tasks.py", line 298, in
forward = lambda x: self.forward(x)[0] if isinstance(m, (Segment, Pose, OBB)) else self.forward(x)
File "/usr/src/ultralytics/ultralytics/nn/tasks.py", line 91, in forward
return self.predict(x, *args, **kwargs)
File "/usr/src/ultralytics/ultralytics/nn/tasks.py", line 109, in predict
return self._predict_once(x, profile, visualize, embed)
File "/usr/src/ultralytics/ultralytics/nn/tasks.py", line 130, in _predict_once
x = m(x) # run
File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
return forward_call(*args, **kwargs)
TypeError: mymodule.forward() missing 1 required positional argument: 'input2'

also if i fix this problem i want to be able to change the inputs to this block becaues it will be used more times. so pushing args = [ch[-1], ch[10]] makes me not able to changed them later?

from ultralytics.

glenn-jocher avatar glenn-jocher commented on June 16, 2024

@N0lanakis hey,

Thanks for the update! It appears that the issue lies with how the inputs are passed to your custom module in the forward pass. In your tasks.py, ensure that you are actually passing both required inputs when you call your mymodule. Based on the details you've provided, instead of setting args directly in the conditional block, you should modify how mymodule is invoked with these inputs:

x = m(x, args[0], args[1]) if isinstance(m, mymodule) else m(x)

For greater flexibility in changing the inputs dynamically, consider managing the inputs outside the static indices directly in your configuration or setup logic, allowing you to modify which layers are connected without changing the code every time.

Give these adjustments a try, and let me know how it goes! 🚀

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.