Comments (3)
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.
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.
@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)
- using multi class segmentation dataset for lower number of class segmentation task? HOT 15
- About TensorRT speed test HOT 7
- Output shape of [1,5,2100] HOT 4
- RT-DETR model hyperparameters HOT 4
- cannot set tensor for ultralytics/examples/YOLOv8-OpenCV-int8-tflite-Python /main.py HOT 4
- Object tracking, where is the c++ example? HOT 1
- Auto annotation for specific labels HOT 4
- A question regarding the calculation of ProbIOU. HOT 1
- Labels problem with YoloV8 custom dataset HOT 4
- Joint training on images with bounding boxes and labels, and images with only labels (YOLO9000 style) HOT 4
- How to Convert YOLOv10 Model to TFLite with INT8 Quantization? HOT 2
- train a model with a new label HOT 4
- running bug on amd HOT 11
- About weight file HOT 3
- camera resolution for real time detection HOT 1
- The GPU utilization is limited when infering diffusion models with lora weights HOT 2
- segment result HOT 2
- bug to PyTorch. HOT 1
- Transfer weights from yolov8l-seg.pt to a new architecture HOT 3
- Accuracy Plot HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.