Ai
1 Star 0 Fork 0

Felix/batch-annotator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test.py 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
import os
import torch
import cv2
import argparse
from tqdm import tqdm
from annotators import annotate, annotators, cleanup_annotators, add_annotators_to_arg_parser
def main():
parser = argparse.ArgumentParser(
description="Converts an image to all annotations"
)
parser.add_argument("input_img", help="input image")
parser.add_argument("--res", type=int, default=512,
help="Resolution to process at. -1 for original size (be careful for large images!)")
add_annotators_to_arg_parser(parser)
args = parser.parse_args()
img = cv2.imread(args.input_img)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
for annotator in tqdm(annotators):
with torch.no_grad():
args.annotator = annotator.slug
# append annotator to output filename
file_path_without_ext, ext = os.path.splitext(args.input_img)
out_path = file_path_without_ext + "_" + annotator.slug + ext
output = annotate(img, args)
output = output.astype('uint8')
output = cv2.cvtColor(output, cv2.COLOR_RGB2BGR)
cv2.imwrite(out_path, output)
annotator.cleanup()
print("FIN")
if __name__ == "__main__":
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/dwhnicholas/batch-annotator.git
git@gitee.com:dwhnicholas/batch-annotator.git
dwhnicholas
batch-annotator
batch-annotator
main

搜索帮助