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

[Fix] Fix mmseg.api.inference inference_segmentor #1849

Merged
merged 5 commits into from
Sep 13, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
Update mmseg/apis/inference.py
Co-authored-by: Hakjin Lee <[email protected]>
  • Loading branch information
jinwonkim93 and nijkah committed Aug 12, 2022
commit 2f6c08a811824c00d4f66225b563c0592f2ec7c2
18 changes: 7 additions & 11 deletions mmseg/apis/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,13 @@ def inference_segmentor(model, imgs):
test_pipeline = [LoadImage()] + cfg.data.test.pipeline[1:]
test_pipeline = Compose(test_pipeline)
# prepare data
if isinstance(imgs, list):
data = []
for img in imgs:
img_data = dict(img=img)
img_data = test_pipeline(img_data)
data.append(img_data)
data = collate(data, samples_per_gpu=len(imgs))
else:
data = dict(img=imgs)
data = test_pipeline(data)
data = collate([data], samples_per_gpu=1)
data = []
imgs = imgs if isinstance(imgs, list) else [imgs]
for img in imgs:
img_data = dict(img=img)
img_data = test_pipeline(img_data)
data.append(img_data)
data = collate(data, samples_per_gpu=len(imgs))
if next(model.parameters()).is_cuda:
# scatter to specified GPU
data = scatter(data, [device])[0]
Expand Down