当前位置:   article > 正文

自定义数据集 实例分割 MaskFormer+SOLOV2_mask2former 自定数据集

mask2former 自定数据集



facebookresearch/Mask2Former: Code release for "Masked-attention Mask Transformer for Universal Image Segmentation" (github.com

facebookresearch/Mask2Former: Code release for "Masked-attention Mask Transformer for Universal Image Segmentation" (github.com

WXinlong/SOLO:用于实例分割的 SOLO 和 SOLOv2,ECCV 2020 和 NeurIPS 2020。 (github.com)

1.MaskFormer

1.1 环境配置 Ubuntu20.04+cuda11.1

conda create --name mask2former python=3.8 -y
conda activate mask2former
conda install pytorch==1.9.0 torchvision==0.10.0 cudatoolkit=11.1 -c pytorch -c nvidia
pip install -U opencv-python
git clone git@github.com:facebookresearch/detectron2.git

上面这个git不好用的话就手动下载这个代码
cd detectron2
pip install -e .
pip install git+https://github.com/cocodataset/panopticapi.git
 

cd ..
git clone git@github.com:facebookresearch/Mask2Former.git

同理,可以手动下载这个源码
cd Mask2Former
pip install -r requirements.txt
cd mask2former/modeling/pixel_decoder/ops
sh make.sh

 上述内容就是完整的配置环境的过程

1.2 数据集预处理

1.2.1 划分为训练集和验证集

  1. import os
  2. import json
  3. import shutil
  4. from sklearn.model_selection import train_test_split
  5. # 文件夹路径
  6. img_folder = '/hy-tmp/pic'
  7. mask_folder = '/hy-tmp/cv2_mask'
  8. output_dir = '/hy-tmp/output'
  9. # 创建输出文件夹
  10. train_img_folder = os.path.join(output_dir, 'train2017')
  11. train_mask_folder = os.path.join(output_dir, 'train2017_masks')
  12. val_img_folder = os.path.join(output_dir, 'val2017')
  13. val_mask_folder = os.path.join(output_dir, 'val2017_masks')
  14. os.makedirs(train_img_folder, exist_ok=True)
  15. os.makedirs(train_mask_folder, exist_ok=True)
  16. os.makedirs(val_img_folder, exist_ok=True)
  17. os.makedirs(val_mask_folder, exist_ok=True)
  18. # 读取所有图像文件名
  19. img_files = [f for f in os.listdir(img_folder) if os.path.isfile(os.path.join(img_folder, f))]
  20. # 使用 train_test_split 划分数据集
  21. train_files, val_files = train_test_split(img_files, test_size=0.2, random_state=42)
  22. # 复制文件到相应的文件夹
  23. for img_filename in train_files:
  24. img_name, img_ext = os.path.splitext(img_filename)
  25. shutil.copy(os.path.join(img_folder, img_filename), os.path.join(train_img_folder, img_filename))
  26. shutil.copy(os.path.join(mask_folder, img_name + '.png'), os.path.join(train_mask_folder, img_name + '.png'))
  27. for img_filename in val_files:
  28. img_name, img_ext = os.path.splitext(img_filename)
  29. shutil.copy(os.path.join(img_folder, img_filename), os.path.join(val_img_folder, img_filename))
  30. shutil.copy(os.path.join(mask_folder, img_name + '.png'), os.path.join(val_mask_folder, img_name + '.png'))
  31. print("Dataset split completed.")

1.2.2 转换为json格式

  1. import os
  2. import json
  3. import cv2
  4. import numpy as np
  5. from pycocotools import mask as coco_mask
  6. from PIL import Image
  7. # 文件夹路径
  8. img_folder = '/hy-tmp/pic'
  9. mask_folder = '/hy-tmp/cv2_mask'
  10. output_dir = '/hy-tmp/1'
  11. train_img_folder = '/hy-tmp/output/train2017'
  12. train_mask_folder = '/hy-tmp/output/train2017_masks'
  13. val_img_folder = '/hy-tmp/output/val2017'
  14. val_mask_folder = '/hy-tmp/output/val2017_masks'
  15. # 初始化 COCO 格式字典
  16. def init_coco_format():
  17. return {
  18. "images": [],
  19. "annotations": [],
  20. "categories": [{"id": 1, "name": "object", "supercategory": "object"}]
  21. }
  22. def create_annotations(img_folder, mask_folder, output_json_path):
  23. coco_format = init_coco_format()
  24. annotation_id = 1
  25. image_id = 1
  26. for img_filename in os.listdir(img_folder):
  27. img_name, img_ext = os.path.splitext(img_filename)
  28. img_path = os.path.join(img_folder, img_filename)
  29. mask_path = os.path.join(mask_folder, img_name + '.png')
  30. if not os.path.exists(mask_path):
  31. continue
  32. # 读取图像
  33. img = Image.open(img_path)
  34. width, height = img.size
  35. # 生成图像信息
  36. image_info = {
  37. "id": image_id,
  38. "file_name": img_filename,
  39. "width": width,
  40. "height": height
  41. }
  42. coco_format["images"].append(image_info)
  43. # 读取掩码
  44. mask = Image.open(mask_path)
  45. mask = np.array(mask)
  46. # 寻找掩码的边界框
  47. contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
  48. for contour in contours:
  49. x, y, w, h = cv2.boundingRect(contour)
  50. bbox = [x, y, w, h]
  51. # 生成掩码的二进制格式
  52. binary_mask = np.zeros((height, width), dtype=np.uint8)
  53. cv2.drawContours(binary_mask, [contour], -1, 1, -1)
  54. encoded_mask = coco_mask.encode(np.asfortranarray(binary_mask))
  55. # 将 RLE 编码转换为可序列化的格式
  56. rle = {
  57. 'counts': encoded_mask['counts'].decode('utf-8'), # 转换为字符串
  58. 'size': encoded_mask['size']
  59. }
  60. annotation = {
  61. "id": annotation_id,
  62. "image_id": image_id,
  63. "category_id": 1,
  64. "segmentation": rle,
  65. "area": float(coco_mask.area(encoded_mask)),
  66. "bbox": bbox,
  67. "iscrowd": 0
  68. }
  69. coco_format["annotations"].append(annotation)
  70. annotation_id += 1
  71. image_id += 1
  72. # 保存到JSON文件
  73. with open(output_json_path, 'w') as f:
  74. json.dump(coco_format, f)
  75. print(f"COCO format annotation file created at {output_json_path}.")
  76. # 创建注释文件
  77. create_annotations(train_img_folder, train_mask_folder, os.path.join(output_dir, 'annotations/instances_train2017.json'))
  78. create_annotations(val_img_folder, val_mask_folder, os.path.join(output_dir, 'annotations/instances_val2017.json'))

1.2.3 实例分割数据集

  1. import os
  2. import json
  3. import cv2
  4. import numpy as np
  5. from pycocotools import mask as coco_mask
  6. from PIL import Image
  7. from sklearn.model_selection import train_test_split
  8. import shutil
  9. # 文件夹路径
  10. img_folder = '/hy-tmp/pic'
  11. mask_folder = '/hy-tmp/cv2_mask'
  12. output_dir = '/hy-tmp/json'
  13. # 创建输出文件夹
  14. train_img_folder = os.path.join(output_dir, 'train2017')
  15. train_mask_folder = os.path.join(output_dir, 'train2017_masks')
  16. val_img_folder = os.path.join(output_dir, 'val2017')
  17. val_mask_folder = os.path.join(output_dir, 'val2017_masks')
  18. os.makedirs(train_img_folder, exist_ok=True)
  19. os.makedirs(train_mask_folder, exist_ok=True)
  20. os.makedirs(val_img_folder, exist_ok=True)
  21. os.makedirs(val_mask_folder, exist_ok=True)
  22. # 读取所有图像文件名
  23. img_files = [f for f in os.listdir(img_folder) if os.path.isfile(os.path.join(img_folder, f))]
  24. # 使用 train_test_split 划分数据集
  25. train_files, val_files = train_test_split(img_files, test_size=0.2, random_state=42)
  26. # 复制文件到相应的文件夹
  27. for img_filename in train_files:
  28. img_name, img_ext = os.path.splitext(img_filename)
  29. shutil.copy(os.path.join(img_folder, img_filename), os.path.join(train_img_folder, img_filename))
  30. shutil.copy(os.path.join(mask_folder, img_name + '.png'), os.path.join(train_mask_folder, img_name + '.png'))
  31. for img_filename in val_files:
  32. img_name, img_ext = os.path.splitext(img_filename)
  33. shutil.copy(os.path.join(img_folder, img_filename), os.path.join(val_img_folder, img_filename))
  34. shutil.copy(os.path.join(mask_folder, img_name + '.png'), os.path.join(val_mask_folder, img_name + '.png'))
  35. print("Dataset split completed.")
  36. # 初始化 COCO 格式字典
  37. def init_coco_format():
  38. return {
  39. "images": [],
  40. "annotations": [],
  41. "categories": [{"id": 1, "name": "object", "supercategory": "object"}]
  42. }
  43. def create_instance_annotations(img_folder, mask_folder, output_json_path):
  44. coco_format = init_coco_format()
  45. annotation_id = 1
  46. image_id = 1
  47. for img_filename in os.listdir(img_folder):
  48. img_name, img_ext = os.path.splitext(img_filename)
  49. img_path = os.path.join(img_folder, img_filename)
  50. mask_path = os.path.join(mask_folder, img_name + '.png')
  51. if not os.path.exists(mask_path):
  52. continue
  53. # 读取图像
  54. img = Image.open(img_path)
  55. width, height = img.size
  56. # 生成图像信息
  57. image_info = {
  58. "id": image_id,
  59. "file_name": img_filename,
  60. "width": width,
  61. "height": height
  62. }
  63. coco_format["images"].append(image_info)
  64. # 读取掩码
  65. mask = Image.open(mask_path)
  66. mask = np.array(mask)
  67. # 寻找掩码的边界框
  68. contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
  69. for contour in contours:
  70. x, y, w, h = cv2.boundingRect(contour)
  71. bbox = [x, y, w, h]
  72. # 生成掩码的二进制格式
  73. binary_mask = np.zeros((height, width), dtype=np.uint8)
  74. cv2.drawContours(binary_mask, [contour], -1, 1, -1)
  75. encoded_mask = coco_mask.encode(np.asfortranarray(binary_mask))
  76. # 将 RLE 编码转换为可序列化的格式
  77. rle = {
  78. 'counts': encoded_mask['counts'].decode('utf-8'), # 转换为字符串
  79. 'size': encoded_mask['size']
  80. }
  81. annotation = {
  82. "id": annotation_id,
  83. "image_id": image_id,
  84. "category_id": 1,
  85. "segmentation": rle,
  86. "area": float(coco_mask.area(encoded_mask)),
  87. "bbox": bbox,
  88. "iscrowd": 0
  89. }
  90. coco_format["annotations"].append(annotation)
  91. annotation_id += 1
  92. image_id += 1
  93. # 保存到JSON文件
  94. with open(output_json_path, 'w') as f:
  95. json.dump(coco_format, f)
  96. print(f"COCO format instance annotation file created at {output_json_path}.")
  97. # 创建实例分割注释文件
  98. create_instance_annotations(train_img_folder, train_mask_folder, os.path.join(output_dir, 'annotations/instances_train2017.json'))
  99. create_instance_annotations(val_img_folder, val_mask_folder, os.path.join(output_dir, 'annotations/instances_val2017.json'))

1.2.4 全景分割数据集

  1. import os
  2. import json
  3. import cv2
  4. import numpy as np
  5. from pycocotools import mask as coco_mask
  6. from PIL import Image
  7. # 初始化 COCO 格式字典
  8. def init_coco_format():
  9. return {
  10. "images": [],
  11. "annotations": [],
  12. "categories": [{"id": 1, "name": "object", "supercategory": "object"}],
  13. "licenses": [],
  14. "info": {
  15. "year": 2023,
  16. "version": "1.0",
  17. "description": "COCO Panoptic Dataset",
  18. "contributor": "",
  19. "url": "",
  20. "date_created": "2023-01-01"
  21. }
  22. }
  23. def create_panoptic_annotations(img_folder, mask_folder, output_json_path):
  24. coco_format = init_coco_format()
  25. panoptic_annotations = []
  26. annotation_id = 1
  27. image_id = 1
  28. for img_filename in os.listdir(img_folder):
  29. img_name, img_ext = os.path.splitext(img_filename)
  30. img_path = os.path.join(img_folder, img_filename)
  31. mask_path = os.path.join(mask_folder, img_name + '.png')
  32. if not os.path.exists(mask_path):
  33. continue
  34. # 读取图像
  35. img = Image.open(img_path)
  36. width, height = img.size
  37. # 生成图像信息
  38. image_info = {
  39. "id": image_id,
  40. "file_name": img_filename,
  41. "width": width,
  42. "height": height
  43. }
  44. coco_format["images"].append(image_info)
  45. # 读取掩码
  46. mask = Image.open(mask_path)
  47. mask = np.array(mask)
  48. # 生成全景注释信息
  49. panoptic_annotation = {
  50. "image_id": image_id,
  51. "file_name": img_filename.replace('.jpg', '.png'),
  52. "segments_info": []
  53. }
  54. # 寻找掩码的边界框
  55. contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
  56. for contour in contours:
  57. x, y, w, h = cv2.boundingRect(contour)
  58. bbox = [x, y, w, h]
  59. # 生成掩码的二进制格式
  60. binary_mask = np.zeros((height, width), dtype=np.uint8)
  61. cv2.drawContours(binary_mask, [contour], -1, 1, -1)
  62. encoded_mask = coco_mask.encode(np.asfortranarray(binary_mask))
  63. # 将 RLE 编码转换为可序列化的格式
  64. rle = {
  65. 'counts': encoded_mask['counts'].decode('utf-8'), # 转换为字符串
  66. 'size': encoded_mask['size']
  67. }
  68. segment_info = {
  69. "id": annotation_id,
  70. "category_id": 1,
  71. "iscrowd": 0,
  72. "bbox": bbox,
  73. "area": float(coco_mask.area(encoded_mask)),
  74. "segmentation": rle
  75. }
  76. panoptic_annotation["segments_info"].append(segment_info)
  77. annotation_id += 1
  78. panoptic_annotations.append(panoptic_annotation)
  79. image_id += 1
  80. # 保存到JSON文件
  81. os.makedirs(os.path.dirname(output_json_path), exist_ok=True)
  82. with open(output_json_path, 'w') as f:
  83. json.dump({
  84. "images": coco_format["images"],
  85. "annotations": panoptic_annotations,
  86. "categories": coco_format["categories"],
  87. "licenses": coco_format["licenses"],
  88. "info": coco_format["info"]
  89. }, f)
  90. print(f"COCO format panoptic annotation file created at {output_json_path}.")
  91. # 创建全景注释文件
  92. create_panoptic_annotations(train_img_folder, train_mask_folder, os.path.join(output_dir, 'annotations/panoptic_train2017.json'))
  93. create_panoptic_annotations(val_img_folder, val_mask_folder, os.path.join(output_dir, 'annotations/panoptic_val2017.json'))

1.2.5 全景分割数据集找到对应的图片(.png格式)

  1. import json
  2. import os
  3. import shutil
  4. # 定义文件路径
  5. json_path = 'path/to/panoptic_train2017.json'
  6. img_dir = 'path/to/img'
  7. output_dir = 'path/to/output_folder'
  8. # 如果输出文件夹不存在,则创建
  9. if not os.path.exists(output_dir):
  10. os.makedirs(output_dir)
  11. # 加载 JSON 文件
  12. with open(json_path, 'r', encoding='utf-8') as f:
  13. data = json.load(f)
  14. # 假设 JSON 文件中有一个键 "images",其中包含每个图像的相关信息
  15. image_info_list = data.get('images', [])
  16. # 遍历每个图像信息并复制对应的图片到输出文件夹
  17. for image_info in image_info_list:
  18. # 假设每个图像信息包含 "file_name"
  19. file_name = image_info.get('file_name')
  20. if file_name:
  21. # 构建原始图片路径
  22. img_path = os.path.join(img_dir, file_name)
  23. # 构建目标图片路径
  24. output_path = os.path.join(output_dir, file_name)
  25. # 检查文件是否存在并复制
  26. if os.path.isfile(img_path):
  27. shutil.copy(img_path, output_path)
  28. print(f"图片 {file_name} 已复制到 {output_path}")
  29. else:
  30. print(f"图片 {file_name} 不存在于路径 {img_path}")
  31. else:
  32. print("图像信息中缺少 'file_name' 键")

1.3训练过程

单卡训练太慢了,需要好几天,选择多卡训练

单卡训练的代码

  1. python train_net.py \
  2. --config-file configs/coco/panoptic-segmentation/maskformer2_R50_bs16_50ep.yaml \
  3. --num-gpus 1 SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.00025

下图为正式运行的过程

多卡训练的代码

遇到的小插曲

报错

TypeError: init() got an unexpected keyword argument 'dtype'

修改events.py文件以及

from packaging.version import parse as LooseVersion

1.4测试过程

2. SOLOV2

2.1 环境配置

2.1.1选择pytorch版本

torch                     1.5.0+cu101              pypi_0    pypi

2.1.2 编译

git clone https://github.com/WXinlong/SOLO.git
cd SOLO

 pip install -r requirements/build.txt
pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"
pip install -v -e .  # or "python setup.py develop"

 2.2 数据集预处理

将数据集转换为coco数据集格式

2.2.1 把img以及对应的mask转换为train_2017.json以及val_2017.json格式

代码如下

  1. import os
  2. import json
  3. import cv2
  4. import numpy as np
  5. from pycocotools import mask as coco_mask
  6. from PIL import Image
  7. from sklearn.model_selection import train_test_split
  8. # 文件夹路径
  9. img_folder = '/hy-tmp/pic'
  10. mask_folder = '/hy-tmp/cv2_mask'
  11. output_train_json_path = '/hy-tmp/coco/annotations/instances_train2017.json'
  12. output_val_json_path = '/hy-tmp/coco/annotations/instances_val2017.json'
  13. # 初始化 COCO 格式字典
  14. def init_coco_format():
  15. return {
  16. "images": [],
  17. "annotations": [],
  18. "categories": [{"id": 1, "name": "object", "supercategory": "object"}]
  19. }
  20. # 读取文件名
  21. img_files = [f for f in os.listdir(img_folder) if os.path.isfile(os.path.join(img_folder, f))]
  22. train_files, val_files = train_test_split(img_files, test_size=0.2, random_state=42)
  23. def create_annotations(files, coco_format, start_image_id=1, start_annotation_id=1):
  24. image_id = start_image_id
  25. annotation_id = start_annotation_id
  26. for img_filename in files:
  27. img_name, img_ext = os.path.splitext(img_filename)
  28. img_path = os.path.join(img_folder, img_filename)
  29. mask_path = os.path.join(mask_folder, img_name + '.png') # 假设掩码是 .png 格式
  30. if not os.path.exists(mask_path):
  31. continue
  32. # 读取图像
  33. img = Image.open(img_path)
  34. width, height = img.size
  35. # 生成图像信息
  36. image_info = {
  37. "id": image_id,
  38. "file_name": img_filename,
  39. "width": width,
  40. "height": height
  41. }
  42. coco_format["images"].append(image_info)
  43. # 读取掩码
  44. mask = Image.open(mask_path)
  45. mask = np.array(mask)
  46. # 寻找掩码的边界框
  47. contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
  48. for contour in contours:
  49. x, y, w, h = cv2.boundingRect(contour)
  50. bbox = [x, y, w, h]
  51. # 生成掩码的二进制格式
  52. binary_mask = np.zeros((height, width), dtype=np.uint8)
  53. cv2.drawContours(binary_mask, [contour], -1, 1, -1)
  54. encoded_mask = coco_mask.encode(np.asfortranarray(binary_mask))
  55. # 将 RLE 编码转换为可序列化的格式
  56. rle = {
  57. 'counts': encoded_mask['counts'].decode('utf-8'), # 转换为字符串
  58. 'size': encoded_mask['size']
  59. }
  60. annotation = {
  61. "id": annotation_id,
  62. "image_id": image_id,
  63. "category_id": 1,
  64. "segmentation": rle,
  65. "area": float(coco_mask.area(encoded_mask)),
  66. "bbox": bbox,
  67. "iscrowd": 0
  68. }
  69. coco_format["annotations"].append(annotation)
  70. annotation_id += 1
  71. image_id += 1
  72. return coco_format, image_id, annotation_id
  73. # 初始化 COCO 格式字典
  74. coco_train_format = init_coco_format()
  75. coco_val_format = init_coco_format()
  76. # 创建训练集注释
  77. coco_train_format, train_image_id, train_annotation_id = create_annotations(train_files, coco_train_format)
  78. # 创建验证集注释
  79. coco_val_format, _, _ = create_annotations(val_files, coco_val_format, start_image_id=train_image_id, start_annotation_id=train_annotation_id)
  80. # 保存训练集注释到JSON文件
  81. with open(output_train_json_path, 'w') as f:
  82. json.dump(coco_train_format, f)
  83. # 保存验证集注释到JSON文件
  84. with open(output_val_json_path, 'w') as f:
  85. json.dump(coco_val_format, f)
  86. print("COCO format annotation files created.")

2.2.2 把数据集划分为train和val

  1. import os
  2. import json
  3. import shutil
  4. # 文件夹路径
  5. img_folder = '/hy-tmp/pic'
  6. val_img_folder = '/hy-tmp/coco/train2017'
  7. val_json_path = '/hy-tmp/coco/annotations/instances_train2017.json'
  8. # 创建 val2017 文件夹,如果不存在
  9. os.makedirs(val_img_folder, exist_ok=True)
  10. # 读取 val2017.json 文件
  11. with open(val_json_path, 'r') as f:
  12. val_data = json.load(f)
  13. # 获取 val2017.json 中所有图片文件名
  14. val_img_files = [img_info['file_name'] for img_info in val_data['images']]
  15. # 复制图片到 val2017 文件夹
  16. for img_filename in val_img_files:
  17. src_path = os.path.join(img_folder, img_filename)
  18. dst_path = os.path.join(val_img_folder, img_filename)
  19. if os.path.exists(src_path):
  20. shutil.copy2(src_path, dst_path)
  21. print(f"Copied: {src_path} to {dst_path}")
  22. else:
  23. print(f"File not found: {src_path}")
  24. print("All val2017 images have been copied.")

2.2.3 如果img和mask不是成对数据

首先运行下面的代码,然后在运行2.2.1以及2.2.2

  1. import os
  2. # 文件夹路径
  3. img_folder = '/hy-tmp/pic'
  4. mask_folder = '/hy-tmp/cv2_mask'
  5. # 获取文件夹中所有文件名(不包括扩展名)
  6. img_files = {os.path.splitext(f)[0] for f in os.listdir(img_folder) if os.path.isfile(os.path.join(img_folder, f))}
  7. mask_files = {os.path.splitext(f)[0] for f in os.listdir(mask_folder) if os.path.isfile(os.path.join(mask_folder, f))}
  8. # 找出在img文件夹中但不在mask文件夹中的文件
  9. img_files_to_delete = img_files - mask_files
  10. # 找出在mask文件夹中但不在img文件夹中的文件
  11. mask_files_to_delete = mask_files - img_files
  12. # 删除img文件夹中的不对应文件
  13. for file in img_files_to_delete:
  14. file_path = os.path.join(img_folder, file + '.jpg') # 假设文件扩展名是.jpg,根据实际情况修改
  15. if os.path.exists(file_path):
  16. os.remove(file_path)
  17. print(f"Deleted from img: {file_path}")
  18. # 删除mask文件夹中的不对应文件
  19. for file in mask_files_to_delete:
  20. file_path = os.path.join(mask_folder, file + '.png') # 假设文件扩展名是.png,根据实际情况修改
  21. if os.path.exists(file_path):
  22. os.remove(file_path)
  23. print(f"Deleted from mask: {file_path}")
  24. print("Deletion completed.")

2.3 使用单卡进行训练

python tools/train.py configs/solov2/solov2_r50_fpn_8gpu_1x.py 

成功运行界面如下图所示,目前官方给的epoch是12个,未修改

2.4 使用单卡进行测试

python tools/test_ins.py configs/solov2/solov2_r50_fpn_8gpu_1x.py /hy-tmp/SOLO/work_dirs/solov2_release_r50_fpn_8gpu_1x/latest.pth --show --out results_solo.pkl --eval segm

结果如下图

2.5 使用单卡进行可视化

python tools/test_ins_vis.py configs/solov2/solov2_r50_fpn_8gpu_1x.py  /hy-tmp/SOLO/work_dirs/solov2_release_r50_fpn_8gpu_1x/latest.pth --show --save_dir  work_dirs/vis_solo

结果在work_dirs/vis_solo文件夹下面

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/949200
推荐阅读
相关标签
  

闽ICP备14008679号