-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[Fix] Fix demo scripts #1815
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 demo scripts #1815
Conversation
mmseg/apis/inference.py
Outdated
|
|
||
| from mmseg.datasets.transforms import Compose | ||
| from mmseg.models import build_segmentor | ||
| from mmseg.datasets.transforms.compose import Compose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| from mmseg.datasets.transforms.compose import Compose | |
| from mmengine.dataset import Compose |
| draw_gt: bool = True, | ||
| draw_pred: bool = True, | ||
| wait_time: float = 0, |
There was a problem hiding this comment.
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
mmseg/apis/inference.py
Outdated
|
|
||
|
|
||
| def inference_model(model, img): | ||
| def inference_model(model: BaseSegmentor, img): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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]: |
mmseg/apis/inference.py
Outdated
| data = scatter(data, [device])[0] | ||
| else: | ||
| data['img_metas'] = [i.data[0] for i in data['img_metas']] | ||
| data = _preprare_data(img, model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| data = _preprare_data(img, model) | |
| if isinstance(imgs, (list, tuple)): | |
| is_batch = True | |
| else: | |
| imgs = [imgs] | |
| is_batch = False | |
| data = _preprare_data(imgs, model) |
mmseg/apis/inference.py
Outdated
|
|
||
| return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return result | |
| if not is_batch: | |
| return results[0] | |
| else: | |
| return results |
* [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>
Motivation
Fix demo scripts
Modification
inference_model()API