Skip to content

Conversation

@xiexinch
Copy link
Collaborator

Motivation

Fix demo scripts

Modification

  • apply 2.0 methods to inference APIs
  • Refactored the inference_model() API


from mmseg.datasets.transforms import Compose
from mmseg.models import build_segmentor
from mmseg.datasets.transforms.compose import Compose
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from mmseg.datasets.transforms.compose import Compose
from mmengine.dataset import Compose

Comment on lines +102 to +104
draw_gt: bool = True,
draw_pred: bool = True,
wait_time: float = 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might add draw_gt, draw_pred, and wait_time in docstring



def inference_model(model, img):
def inference_model(model: BaseSegmentor, img):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def inference_model(model: BaseSegmentor, img):
ImagesType = Union[str, np.ndarray, Sequence[str], Sequence[np.ndarray]]
def inference_model(model: BaseSegmentor, img: ImagesType)->Union[SegDataSample, DataSample]:

data = scatter(data, [device])[0]
else:
data['img_metas'] = [i.data[0] for i in data['img_metas']]
data = _preprare_data(img, model)
Copy link
Collaborator

@MeowZheng MeowZheng Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data = _preprare_data(img, model)
if isinstance(imgs, (list, tuple)):
is_batch = True
else:
imgs = [imgs]
is_batch = False
data = _preprare_data(imgs, model)

Comment on lines 93 to 94

return result
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return result
if not is_batch:
return results[0]
else:
return results

@MeowZheng MeowZheng merged commit 5d96508 into open-mmlab:dev-1.x Jul 29, 2022
wjkim81 pushed a commit to wjkim81/mmsegmentation that referenced this pull request Dec 3, 2023
nahidnazifi87 pushed a commit to nahidnazifi87/mmsegmentation_playground that referenced this pull request Apr 5, 2024
* [Feature] Add SegVisualizer

* change name to visualizer_example

* fix inference api

* fix video demo and refine inference api

* fix

* mmseg compose

* set default device to cuda:0

* fix import

* update dir

* rm engine/visualizer ut

* refine inference api and docs

* rename

Co-authored-by: MengzhangLI <mcmong@pku.edu.cn>
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

Successfully merging this pull request may close these issues.

3 participants