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

RuntimeError: stack expects each tensor to be equal size, but got [1, 64, 15, 9] at entry 0 and [1, 64, 16, 10] at entry 1 #1129

Open
balavenkatesh3322 opened this issue Aug 10, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@balavenkatesh3322
Copy link

While running the application i get the below error in the application. Please guide me to solve it.

RuntimeError: stack expects each tensor to be equal size, but got [1, 64, 15, 9] at entry 0 and [1, 64, 16, 10] at entry 1

The exact error happening in the below line

prediction = model_type.end2end_detect(image, valid_tfms, model, class_map=class_map, detection_threshold=0.5)

Complete traceback code

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2095, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2080, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 271, in error_router
    return original_handler(e)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1525, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 271, in error_router
    return original_handler(e)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/flask_apispec/annotations.py", line 122, in wrapped
    return wrapper(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/flask_apispec/wrapper.py", line 29, in __call__
    response = self.call_view(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/flask_apispec/wrapper.py", line 52, in call_view
    return self.func(*args, **kwargs)
  File "/app/crop_doctor/resource.py", line 90, in post
    cropped_image_path, Is_detected , before_crop_image_path, object_detection_label = object_detection(image_path,file_name)
  File "/app/crop_doctor/crop_object_detection.py", line 37, in object_detection
    prediction  = model_type.end2end_detect(image, valid_tfms, model, class_map=class_map, detection_threshold=0.5)
  File "/usr/local/lib/python3.7/site-packages/icevision/imports.py", line 88, in __call__
    return self._partial(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/icevision/models/inference.py", line 65, in _end2end_detect
    pred = predict_fn(model, infer_ds, detection_threshold=detection_threshold)[0]
  File "/usr/local/lib/python3.7/site-packages/icevision/models/ross/efficientdet/prediction.py", line 58, in predict
    device=device,
  File "/usr/local/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/icevision/models/ross/efficientdet/prediction.py", line 31, in _predict_batch
    raw_preds = bench(x=imgs, img_info=img_info)
  File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/effdet/bench.py", line 92, in forward
    class_out, box_out = self.model(x)
  File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/effdet/efficientdet.py", line 617, in forward
    x = self.fpn(x)
  File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/effdet/efficientdet.py", line 360, in forward
    x = self.cell(x)
  File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/effdet/efficientdet.py", line 34, in forward
    x = module(x)
  File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/effdet/efficientdet.py", line 295, in forward
    x.append(fn(x))
  File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/effdet/efficientdet.py", line 254, in forward
    return self.after_combine(self.combine(x))
  File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/effdet/efficientdet.py", line 235, in forward
    [(nodes[i] * edge_weights[i]) / (weights_sum + 0.0001) for i in range(len(nodes))], dim=-1)
    RuntimeError: stack expects each tensor to be equal size, but got [1, 64, 15, 9] at entry 0 and [1, 64, 16, 10] at entry 1
@balavenkatesh3322 balavenkatesh3322 added the bug Something isn't working label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant