1 Star 0 Fork 0

michaelowenliu/ritm_interactive_segmentation

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
demo.py 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
Konstantin Sofiiuk 提交于 2021-02-13 04:23 +08:00 . Init commit
import argparse
import tkinter as tk
import torch
from isegm.utils import exp
from isegm.inference import utils
from interactive_demo.app import InteractiveDemoApp
def main():
args, cfg = parse_args()
torch.backends.cudnn.deterministic = True
checkpoint_path = utils.find_checkpoint(cfg.INTERACTIVE_MODELS_PATH, args.checkpoint)
model = utils.load_is_model(checkpoint_path, args.device, cpu_dist_maps=True)
root = tk.Tk()
root.minsize(960, 480)
app = InteractiveDemoApp(root, args, model)
root.deiconify()
app.mainloop()
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--checkpoint', type=str, required=True,
help='The path to the checkpoint. '
'This can be a relative path (relative to cfg.INTERACTIVE_MODELS_PATH) '
'or an absolute path. The file extension can be omitted.')
parser.add_argument('--gpu', type=int, default=0,
help='Id of GPU to use.')
parser.add_argument('--cpu', action='store_true', default=False,
help='Use only CPU for inference.')
parser.add_argument('--limit-longest-size', type=int, default=800,
help='If the largest side of an image exceeds this value, '
'it is resized so that its largest side is equal to this value.')
parser.add_argument('--cfg', type=str, default="config.yml",
help='The path to the config file.')
args = parser.parse_args()
if args.cpu:
args.device =torch.device('cpu')
else:
args.device = torch.device(f'cuda:{args.gpu}')
cfg = exp.load_config_file(args.cfg, return_edict=True)
return args, cfg
if __name__ == '__main__':
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/michaelowenliu/ritm_interactive_segmentation.git
git@gitee.com:michaelowenliu/ritm_interactive_segmentation.git
michaelowenliu
ritm_interactive_segmentation
ritm_interactive_segmentation
master

搜索帮助