实例分割-Yolact/Yolact++训练自己数据集

news2024/9/22 7:33:42

前言
本文主要用于记录实例分割模型yolact和yolact++的环境配置,以及成功训练自己数据集的整个过程~

注意:这里要重点提醒一下,DCNv2对RTX系列不友好,我第一次使用4090服务器,编译持续有问题,被迫放弃,这里使用2080TI进行操作!

源码地址:https://github.com/dbolya/yolact

目录

  • 一、Yolact环境配置
  • 二、训练准备
  • 三、yolact训练
  • 四、 数据集测试
  • 五、Yolact++环境配置

一、Yolact环境配置

基础环境:python=3.8、pytorch=1.7.0、cuda=11.0、ubuntu18.04

1、创建一个anaconda虚拟环境

conda create -n yolact python=3.8  //环境名为yolact ,python版本选择3.8
conda activate yolact              //激活yolact 环境

2.查看安装的:

nvcc --version #查看cuda版本

python     #查看pytorch
>>> import torch
>>> print(torch.cuda.is_available())
True
>>> print(torch.version.cuda)
11.0

3.安装所需要的依赖:

pip install cython
pip install opencv-python
pip install pillow
pip install pycocotools#用此方式:pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
pip install matplotlib 

二、训练准备

1、下载预训练权重

把权重文件放到yolact-master下的weights文件夹里

下载地址:https://github.com/dbolya/yolact

在这里插入图片描述

2、数据集文件夹结构

在这里插入图片描述
coco文件夹,里面包含annotations以及images。其中annotations包含instances_train2017.json以及instances_val2017.json; images中包含train2017以及val2017用于存放训练与验证数据集。

3、参数修改

(1)coco_classes与coco_label_map

修改数据加载的位置即可,具体来说,找到./data/config.py目录,为自己的数据集格式
在这里插入图片描述

(2)dataset_base地址

在这里插入图片描述

将训练数据集和验证数据集的加载地址切换为自己的数据集地址,注意此处只要修改了images的地址就可以

(3)修改coco2014_dataset或coco2017_dataset的信息,如下:

在这里插入图片描述

(4)修改coco_base_config

此处的max_iter并不是控制训练轮数的

在这里插入图片描述

(5)修改yolact_base_config
在这里插入图片描述

(6)其他的训练参数在train.py文件处修改

parser = argparse.ArgumentParser(
    description='Yolact Training Script')
parser.add_argument('--batch_size', default=8, type=int,
                    help='Batch size for training')
parser.add_argument('--resume', default=None, type=str,
                    help='Checkpoint state_dict file to resume training from. If this is "interrupt"'\
                         ', the model will resume training from the interrupt file.')
parser.add_argument('--start_iter', default=-1, type=int,
                    help='Resume training at this iter. If this is -1, the iteration will be'\
                         'determined from the file name.')
parser.add_argument('--num_workers', default=4, type=int,
                    help='Number of workers used in dataloading')
parser.add_argument('--cuda', default=True, type=str2bool,
                    help='Use CUDA to train model')
parser.add_argument('--lr', '--learning_rate', default=None, type=float,
                    help='Initial learning rate. Leave as None to read this from the config.')
parser.add_argument('--momentum', default=None, type=float,
                    help='Momentum for SGD. Leave as None to read this from the config.')
parser.add_argument('--decay', '--weight_decay', default=None, type=float,
                    help='Weight decay for SGD. Leave as None to read this from the config.')
parser.add_argument('--gamma', default=None, type=float,
                    help='For each lr step, what to multiply the lr by. Leave as None to read this from the config.')
parser.add_argument('--save_folder', default='weights/',
                    help='Directory for saving checkpoint models.')
parser.add_argument('--log_folder', default='logs/',
                    help='Directory for saving logs.')
parser.add_argument('--config', default=None,
                    help='The config object to use.')
parser.add_argument('--save_interval', default=10000, type=int,
                    help='The number of iterations between saving the model.')
parser.add_argument('--validation_size', default=5000, type=int,
                    help='The number of images to use for validation.')
parser.add_argument('--validation_epoch', default=2, type=int,
                    help='Output validation information every n iterations. If -1, do no validation.')
parser.add_argument('--keep_latest', dest='keep_latest', action='store_true',
                    help='Only keep the latest checkpoint instead of each one.')
parser.add_argument('--keep_latest_interval', default=100000, type=int,
                    help='When --keep_latest is on, don\'t delete the latest file at these intervals. This should be a multiple of save_interval or 0.')
parser.add_argument('--dataset', default=None, type=str,
                    help='If specified, override the dataset specified in the config with this one (example: coco2017_dataset).')
parser.add_argument('--no_log', dest='log', action='store_false',
                    help='Don\'t log per iteration information into log_folder.')
parser.add_argument('--log_gpu', dest='log_gpu', action='store_true',
                    help='Include GPU information in the logs. Nvidia-smi tends to be slow, so set this with caution.')
parser.add_argument('--no_interrupt', dest='interrupt', action='store_false',
                    help='Don\'t save an interrupt when KeyboardInterrupt is caught.')
parser.add_argument('--batch_alloc', default=None, type=str,
                    help='If using multiple GPUS, you can set this to be a comma separated list detailing which GPUs should get what local batch size (It should add up to your total batch size).')
parser.add_argument('--no_autoscale', dest='autoscale', action='store_false',
                    help='YOLACT will automatically scale the lr and the number of iterations depending on the batch size. Set this if you want to disable that.')

三、yolact训练

python train.py --config=yolact_base_config

训练如下:

在这里插入图片描述

四、 数据集测试

python eval.py --trained_model=weights/yolact_base_0_500.pth --benchmark --max_images=1000

效果如下:

在这里插入图片描述

五、Yolact++环境配置

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1972416.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C++|设计模式(八)|⭐️工厂模式?错!是工厂模式群!

本文内容全部来源于B站,仅做个人学习使用: 【工厂模式?错!是工厂模式群!】 在此之前,笔者曾经发过两篇关于工厂模式的博客: C|设计模式(二)|简单…

软件测试---Jmeter

一、简介 二、安装与启动 (1)安装 安装包:通过百度网盘分享的文件:jmeter环境.rar 链接:https://pan.baidu.com/s/1OB0IP3W7hqUjAGj_5F56sQ

vue3 自定义指令 自动获取节点的width 和 height

想写一个依赖库, 但是需要监听组件的width和height这些数据, 就找到了ResizeObserver这个方法,不想每次使用的时候都要创建和销毁 ResizeObserver, 索性就直接封装成为一个指令用来获取想要的信息, ResizeObserver对象上能够获取的信息还是非常多的, 除了width, height 还有 to…

一篇文章讲明白Ldraw(乐高模型)的格式文件说明

最好将文章内容保存下来 https://ldraw.org/article/218.html 乐高模型是非常有意思的模型,弄明白了它的模型构造,也就懂了三维模型的构造,原理都是相通的。

如何在行空板上运行 YOLOv10n?

YOLOv10介绍 YOLO(You Only Look Once)系列是当前最主流的端侧目标检测算法,由Joseph Redmon等人首次提出,并随着时间发展,已经推出了多个版本,每个版本“似乎”都在性能和速度上有所提升。 本文为大家介绍…

【前端编程小白】的HTML从零入门到实战

之前有高中毕业生读了博客,想让我帮他找一些前端入门的内容,他们报的计算机专业,想利用开学前夕学习一下,我给他推荐了一些菜鸟教程呀什么的。后来想,看来还是很多人需要一些更加入门的可成的,而且很多教程…

24年电赛——自动行驶小车(H题)基于 CCS Theia -陀螺仪 JY60 代码移植到 MSPM0G3507(附代码)

前言 只要搞懂 M0 的代码结构和 CCS 的图形化配置方法,代码移植就会变的很简单。因为本次电赛的需要,正好陀螺仪部分代码的移植是我完成的。(末尾附全部代码) 一、JY60 陀螺仪 JY60特点 1.模块集成高精度的陀螺仪、加速度计&…

APACHE安装与应用

💝💝💝欢迎来到我的博客,很高兴能够在这里和您见面!希望您在这里可以感受到一份轻松愉快的氛围,不仅可以获得有趣的内容和知识,也可以畅所欲言、分享您的想法和见解。 推荐:Linux运维老纪的首页…

24澳中博览会|2025非洲水协年会暨展览|2025山西水展

2024澳中博览会 2025非洲水协年会暨展览 2025年山西国际水展暨水利工程设计与施工、水处理技术设备、泵管阀、智慧水务及环保展 承办单位:山西泽嘉国际展览有限公司 上海泽嘉展览服务有限公司 战略合作伙伴 : 美国迈阿密水展 欧 洲 海 水 脱 盐 淡 化…

SD原班人马发布FLUX.1:打开AI绘画新世界

​ Black Forest Labs 旗下产品 AI 绘画工具如雨后春笋般涌现,让我们对创作的理解不断刷新。就在大家以为已经见识了 AI 绘画的天花板时,FLUX.1 出现了!这款由 Black Forest Labs 推出的 AI 绘画工具,不仅在性能上远超竞品&#x…

不好用你打我!2024你必须要会的AI神器

这篇文章,除了干货就是干货~ 今天给大家介绍一款2024年你必须要掌握的AI神器。 我可以肯定的说他是目前市面上第一款在这个领域出现的AI工具。 现在的AI工具,可以用来生成文字、图片、视频甚至音乐, 但是你听说过直接用AI生成APP的吗&…

【Spring】Spring框架的概念,以及Spring框架的简单使用。

目录 1. 概念 2. Spring的体系结构介绍(了解) 3. Spring框架的使用 3.1 环境准备 3.2 代码编写 1. 概念 总的来说就是一句话,Spring框架是一个轻量级的控制反转(IoC)和面向切面(AOP)编程的容…

Spring Boot+MyBatis+MySQL如何实现读写分离

​ 博客主页: 南来_北往 系列专栏:Spring Boot实战 背景 读写分离是数据库架构中的一种优化策略,它将读操作(查询)和写操作(更新、插入、删除)分开处理,通常通过将读请求和写请求分别发送…

2024年全国青少年信息素养大赛总决赛日赛程表

2024全国青少年信息素养大赛赛程表分赛场(浙江传媒学院桐乡校区、桐乡技师学院)日期地点时间赛项16日传媒学院8:00-9:00检录 9:00-10:30开赛图形化编程挑战赛(小学1-3年级)A组12:00-13:00检录 13:00-14:30开赛图形化编程挑战赛&am…

最新版Baby Audio Bundle,win和mac,持续更新,长期有效

一。Baby Audio Bundle.2024.07.WiN&MAC Baby Audio让您的混音听起来比以往任何时候都更大,更好,更有活力。这个捆绑包有七个独特的插件,涵盖了从延迟和混响效果(Spaced Out)到低保真声音(Super VHS&am…

MySQL(8.0)数据库安装和初始化以及管理

1.MySQL下载安装和初始化 1.下载安装包 下载地址:https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar 2.解压…

手把手使用 SVG + CSS 实现渐变进度环效果

效果 轨道 使用 svg 画个轨道 <svg viewBox"0 0 100 100"><circle cx"50" cy"50" r"40" fill"none" stroke-width"10" stroke"#333"></circle></svg>简单的说&#xff0c;就是…

shell脚本(自动化安装各种服务)

1、自动化配置DNS服务 [rootelemestatic ~]# vim dns.sh [rootelemestatic ~]# bash dns.sh 客户端测试&#xff1a; yum -y install bind-utils echo "nameserevr 192.168.8.161" > /etc/resolv.conf nslookup www.a.com 2、自动化配置rsync服务 [rootele…

如何用Python删除电脑中的重复文件?

在生活中&#xff0c;我们经常会遇到电脑中文件重复的情况。 在文件较少的情况下&#xff0c;这类情况还比较容易处理&#xff0c;最不济就是一个个手动对比删除&#xff1b; 而在重复文件很多的时候&#xff0c;我们很难保证把重复文件全部删完。 这里给大家带来了一个便捷…

《计算机组成原理》(第3版)第2章 计算机的发展及应用 复习笔记

第2章 计算机的发展及应用 一、计算机的产生和发展 &#xff08;一&#xff09;第一代电子管计算机 1943年&#xff0c;美国国防部批准了建造一台用电子管组成的电子数字积分机和计算机&#xff08;Electronic Numerica1 Integrator And Computer&#xff0c;ENIAC&#xff…