Skip to content
New issue

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

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

Already on GitHub? # to your account

Unable to run inference #12

Open
raghavzns opened this issue Aug 3, 2023 · 2 comments
Open

Unable to run inference #12

raghavzns opened this issue Aug 3, 2023 · 2 comments

Comments

@raghavzns
Copy link

rgrg/src$ python ./full_model/generate_reports_for_images.py
Traceback (most recent call last):
File "/media/Win11/rgrg/src/./full_model/generate_reports_for_images.py", line 20, in
from src.full_model.report_generation_model import ReportGenerationModel
ModuleNotFoundError: No module named 'src'

@raghavzns
Copy link
Author

Fixed above issues. Now Im getting this error

python ./src/full_model/generate_reports_for_images.py
Model instantiated.
  0%|                                                                                                                                              | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/media/test/Win11/rgrg/./src/full_model/generate_reports_for_images.py", line 202, in <module>
    main()
  File "/media/test/Win11/rgrg/./src/full_model/generate_reports_for_images.py", line 195, in main
    generated_report = get_report_for_image(model, image_tensor, tokenizer, bert_score, sentence_tokenizer)
  File "/media/test/Win11/rgrg/./src/full_model/generate_reports_for_images.py", line 110, in get_report_for_image
    output = model.generate(
  File "/home/test/.local/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/media/test/Win11/rgrg/src/full_model/report_generation_model.py", line 244, in generate
    _, detections, top_region_features, class_detected = self.object_detector(images)
  File "/home/test/.local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/media/test/Win11/rgrg/src/object_detector/object_detector.py", line 219, in forward
    features = self.backbone(images)
  File "/home/test/.local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/test/.local/lib/python3.9/site-packages/torch/nn/modules/container.py", line 217, in forward
    input = module(input)
  File "/home/test/.local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/test/.local/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 463, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/home/test/.local/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Given groups=1, weight of size [64, 1, 7, 7], expected input[1, 3, 512, 512] to have 1 channels, but got 3 channels instead

@vvuonghn
Copy link

To fix that, you need to fix the input model is (1,1,512,512)

image_tensor = get_image_tensor(image_path)  # shape (1, 1, 512, 512)
image_tensor = image_tensor[:,0:1,:,:]

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

No branches or pull requests

2 participants