Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to write anchors of yolov4 tiny #57

Closed
aditdoshi333 opened this issue Feb 22, 2021 · 13 comments
Closed

Not able to write anchors of yolov4 tiny #57

aditdoshi333 opened this issue Feb 22, 2021 · 13 comments

Comments

@aditdoshi333
Copy link

Thank you for sharing such amazing work. I want to use Yolov4 Tiny with FastMot. But I am getting the following error

python3: yolo_layer.cu:118: virtual nvinfer1::Dims nvinfer1::YoloLayerPlugin::getOutputDimensions(int, const nvinfer1::Dims*, int): Assertion `inputs[0].d[0] == (mNumClasses + 5) * mNumAnchors' failed.
Aborted (core dumped)

class YOLOv4(YOLO):
ENGINE_PATH = Path(file).parent / 'yolo_drone.trt'
MODEL_PATH = Path(file).parent / 'yolo_drone.onnx'
NUM_CLASSES = 1
INPUT_SHAPE = (3, 768, 1024)
LAYER_FACTORS = [32,16]
SCALES = [1.05, 1.05]
ANCHORS = 9, 9, 24, 19, 81, 42, 149, 62, 196,103, 650,416

I am passing anchors as two sub-lists each containing 6 elements. I think I am not missing something while writing anchors.

Any help would be appreciated
Thank you

@GeekAlexis
Copy link
Owner

GeekAlexis commented Feb 23, 2021

@aditdoshi333 Is your YOLOv4-tiny trained for one class?

@aditdoshi333
Copy link
Author

Yes it is trained for one class.

@GeekAlexis
Copy link
Owner

GeekAlexis commented Feb 23, 2021

@aditdoshi333 Make sure you follow #23 for filling up the anchors.

@aditdoshi333
Copy link
Author

I added this in yolo.py.

class YOLOv4(YOLO):
ENGINE_PATH = Path(file).parent / 'yolo_drone.trt'
MODEL_PATH = Path(file).parent / 'yolo_drone.onnx'
NUM_CLASSES = 1
INPUT_SHAPE = (3, 768, 1024)
LAYER_FACTORS = [32, 16]
SCALES = [1.05, 1.05]
ANCHORS = [[149,62,196,103,650,416], [9,9,24,19,81,42]]

Yes, I saw that explanation but I am not able to understand where I am getting wrong. I have tried reverse order as suggested by you for tiny.

@GeekAlexis
Copy link
Owner

@aditdoshi333 How did you convert YOLO to ONNX?

@aditdoshi333
Copy link
Author

@GeekAlexis
Copy link
Owner

@aditdoshi333 Can you try this instead https://github.com/jkjung-avt/tensorrt_demos/blob/master/yolo/yolo_to_onnx.py. You may want to rename your weight and config to yolov4-tiny-1024x768.cfg and yolov4-tiny-1024x768.weight

@aditdoshi333
Copy link
Author

Hey, thanks now it is able to create tensorRT engine. But there is a problem I am not able to get any bounding box. I am getting the results when using the same tensorRT engine for inference using (https://github.com/jkjung-avt/tensorrt_demos). But it is not showing any results when using with FastMOT. Are there any processing changes I need to do for yolo 4 tiny?

Thank you for the help

@GeekAlexis
Copy link
Owner

GeekAlexis commented Feb 23, 2021 via email

@aditdoshi333
Copy link
Author

Thanks man! It is working. One more doubt in track.py you are getting the center of the bounding box from tlbr variable. That center x,y is with respect to which frame? Input or some other processing

@aditdoshi333
Copy link
Author

I asked this because sometimes I am getting log like

[INFO] Out: drone 4 at [-2658 -955]

I am not able to understand the negative values of x and y.
Even I am interested in the range of values of and x and y

@GeekAlexis
Copy link
Owner

The image size determines the range, which is indicated by size in mot.json. "Out" means the object is out of view. It is normal to have negative coordinates if the object is large and/or moves too fast.

@GeekAlexis
Copy link
Owner

Closing this now because the issue is resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants