def modelscope_models_to_cpu():
    """Load models to cpu to free VRAM."""
    ms_models = [
        scripts.easyphoto_infer.retinaface_detection,
        scripts.easyphoto_infer.image_face_fusion,
        scripts.easyphoto_infer.skin_retouching,
        scripts.easyphoto_infer.portrait_enhancement,
        scripts.easyphoto_infer.face_skin,
        scripts.easyphoto_infer.face_recognition,
        scripts.easyphoto_infer.psgan_inference,
    ]
    for ms_model in ms_models:
        move_to_cpu(ms_model)
        # if hasattr(ms_model, "__dict__"):
        #     for key in ms_model.__dict__.keys():
        #         try:
        #             if hasattr(getattr(ms_model, key), "cpu"):
        #                 getattr(ms_model, key).cpu()
        #         except Exception as e:
        #             traceback.print_exc()
        #             ep_logger.info(f"{str(ms_model)}.{key} has no cpu(), detailed error infor is {e}")

    gc.collect()
    torch.cuda.empty_cache()
    torch.cuda.ipc_collect()
Load models to cpu to free VRAM.
scripts/easyphoto_utils/common_utils.py