#!/usr/bin/env python3 import os, sys, importlib.util, re # ——— Monkey-patch mmdet to remove its mmcv-version assertion ——— spec = importlib.util.find_spec('mmdet') if spec and spec.origin: src = open(spec.origin, encoding='utf-8').read() # strip out the mmcv_minimum_version…assert… block up to __all__ patched = re.sub(r'(?ms)^[ \t]*mmcv_minimum_version.*?^__all__', '__all__', src) m = importlib.util.module_from_spec(spec) m.__loader__ = spec.loader m.__file__ = spec.origin m.__path__ = spec.submodule_search_locations sys.modules['mmdet'] = m exec(compile(patched, spec.origin, 'exec'), m.__dict__) # ——— Configuration: set your image & output folder here ——— IMAGE_PATH = "000000197388.jpg" VIS_OUT_DIR = "vis_results" POSE2D = "rtmo" # hard-code the RTMO 2D model alias DEVICE = None # e.g. "cuda:0" or None to auto-select # ——— Inference ——— from mmpose.apis.inferencers import MMPoseInferencer # create output folder os.makedirs(VIS_OUT_DIR, exist_ok=True) # instantiate the inferencer inferencer = MMPoseInferencer( pose2d=POSE2D, scope="mmpose", device=DEVICE, det_cat_ids=[0], # you can override any other init args here… ) # run on our single image, with the RTMO-specific defaults, # iterating the generator so that visualization actually happens: for result in inferencer( inputs=IMAGE_PATH, bbox_thr=0.1, nms_thr=0.65, pose_based_nms=True, show=False, vis_out_dir=VIS_OUT_DIR, ): # result is a dict with keys "visualization" and "predictions" # you can inspect it here if you like, e.g.: # print(result['predictions']) pass print(f"Visualized results saved to {VIS_OUT_DIR}/")