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

[Bug] image_demo can't output #1041

Open
3 tasks done
0Freeebaby opened this issue Jun 21, 2024 · 0 comments
Open
3 tasks done

[Bug] image_demo can't output #1041

0Freeebaby opened this issue Jun 21, 2024 · 0 comments

Comments

@0Freeebaby
Copy link

Prerequisite

Task

I'm using the official example scripts/configs for the officially supported tasks/models/datasets.

Branch

master branch https://github.com/open-mmlab/mmrotate

Environment

TorchVision: 0.15.0
OpenCV: 4.10.0
MMCV: 1.7.2
MMCV Compiler: GCC 9.3
MMCV CUDA Compiler: 11.8
MMRotate: 0.3.4+unknown

Reproduces the problem - code sample

Copyright (c) OpenMMLab. All rights reserved.

from argparse import ArgumentParser

from mmdet.apis import inference_detector, init_detector, show_result_pyplot

import mmrotate # noqa: F401

def parse_args():
parser = ArgumentParser()
parser.add_argument('img', help='Image file')
parser.add_argument('config', help='Config file')
parser.add_argument('checkpoint', help='Checkpoint file')
parser.add_argument('--out-file', default=None, help='Path to output file')
parser.add_argument(
'--device', default='cuda:0', help='Device used for inference')
parser.add_argument(
'--palette',
default='dota',
choices=['dota', 'sar', 'hrsc', 'hrsc_classwise', 'random'],
help='Color palette used for visualization')
parser.add_argument(
'--score-thr', type=float, default=0.3, help='bbox score threshold')
args = parser.parse_args()
return args

def main(args):
# build the model from a config file and a checkpoint file
model = init_detector(args.config, args.checkpoint, device=args.device)
# test a single image
result = inference_detector(model, args.img)
# show the results
show_result_pyplot(
model,
args.img,
result,
palette=args.palette,
score_thr=args.score_thr,
out_file=args.out_file)

if name == 'main':
args = parse_args()
main(args)

Reproduces the problem - command or script

python demo/image_demo.py demo/demo.jpg oriented_rcnn_r50_fpn_1x_dota_le90.py oriented_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth --out-file result.jpg

Reproduces the problem - error message

/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/mmcv/init.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details.
warnings.warn(
/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/mmdet/models/dense_heads/anchor_head.py:116: UserWarning: DeprecationWarning: num_anchors is deprecated, for consistency or also use num_base_priors instead
warnings.warn('DeprecationWarning: num_anchors is deprecated, '
load checkpoint from local path: oriented_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth
/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/mmdet/models/dense_heads/anchor_head.py:123: UserWarning: DeprecationWarning: anchor_generator is deprecated, please use "prior_generator" instead
warnings.warn('DeprecationWarning: anchor_generator is deprecated, '
Traceback (most recent call last):
File "demo/image_demo.py", line 45, in
main(args)
File "demo/image_demo.py", line 34, in main
show_result_pyplot(
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/mmdet/apis/inference.py", line 247, in show_result_pyplot
model.show_result(
File "/home/abc/yuanruirui/mmrotate-main/mmrotate/models/detectors/base.py", line 87, in show_result
img = imshow_det_rbboxes(
File "/home/abc/yuanruirui/mmrotate-main/mmrotate/core/visualization/image.py", line 151, in imshow_det_rbboxes
fig = plt.figure(win_name, frameon=False)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/_api/deprecation.py", line 454, in wrapper
return func(*args, **kwargs)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/pyplot.py", line 840, in figure
manager = new_figure_manager(
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/pyplot.py", line 384, in new_figure_manager
return _get_backend_mod().new_figure_manager(*args, **kwargs)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 3574, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 3579, in new_figure_manager_given_figure
return cls.FigureCanvas.new_manager(figure, num)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 1742, in new_manager
return cls.manager_class.create_with_canvas(cls, figure, num)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/backends/_backend_tk.py", line 507, in create_with_canvas
manager = cls(canvas, num, window)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/backends/_backend_tk.py", line 457, in init
super().init(canvas, num)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 2832, in init
self.toolbar = self._toolbar2_class(self.canvas)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/backends/_backend_tk.py", line 630, in init
self._buttons[text] = button = self._Button(
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/backends/_backend_tk.py", line 834, in _Button
NavigationToolbar2Tk._set_image_for_button(self, b)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/matplotlib/backends/_backend_tk.py", line 770, in _set_image_for_button
image = ImageTk.PhotoImage(im.resize((size, size)), master=self)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/PIL/Image.py", line 1958, in resize
im = im.resize(size, resample, box)
File "/home/abc/.conda/envs/mmrotate/lib/python3.8/site-packages/PIL/Image.py", line 1980, in resize
return self._new(self.im.resize(size, resample, box))
ValueError: height and width must be > 0

Additional information

I used the initial test code ,but I still got an error.After reconfiguring the environment,there are still issues and I couldn't output anything.

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

1 participant