DETR类环境快速搭建

news2024/10/7 6:49:32

DINO下载地址:

git clone https://github.com/IDEA-Research/DINO.git
conda create -n detr python=3.8 -y

修改写入权限

 sudo chmod a+w /home/ubuntu/.conda/

激活环境

source activate detr

安装pytorch

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch

随后切换到DINO目录,安装所需包,记得将requirements.txt 中的git clone下载删掉

 pip install -r requirements.txt 
 -i https://mirrors.bfsu.edu.cn/pypi/web/simple/

随后安装pycocotools

pip install pycocotools

配置CUDA算子

cd models/dino/ops
python setup.py build install
python test.py

随后修改pycocotools中配置使其输出多个类别的AP值
文件所在路径:

/home/ubuntu/.conda/envs/detr/lib/python3.8/site-packages/pycocotools/

在这里插入图片描述
修改coco.py:

def __init__(self, annotation_file=None):
    """
    Constructor of Microsoft COCO helper class for reading and visualizing annotations.
    :param annotation_file (str): location of annotation file
    :param image_folder (str): location to the folder that hosts images.
    :return:
    """
    # load dataset
    self.dataset,self.anns,self.cats,self.imgs = dict(),dict(),dict(),dict()
    self.imgToAnns, self.catToImgs = defaultdict(list), defaultdict(list)
    if not annotation_file == None:
        print('loading annotations into memory...')
        tic = time.time()
        with open(annotation_file, 'r') as f:
            dataset = json.load(f)
        assert type(dataset)==dict, 'annotation file format {} not supported'.format(type(dataset))
        print('Done (t={:0.2f}s)'.format(time.time()- tic))
        print(
            "category names: {}".format([e["name"] for e in sorted(dataset["categories"], key=lambda x: x["id"])]))
        self.dataset = dataset
        self.createIndex()

修改cocoeval.py:

def summarize(self):
        '''
        Compute and display summary metrics for evaluation results.
        Note this functin can *only* be applied on the default parameter setting
        '''
        def _summarize( ap=1, iouThr=None, areaRng='all', maxDets=100 ):
            p = self.params
            iStr = ' {:<18} {} @[ IoU={:<9} | area={:>6s} | maxDets={:>3d} ] = {:0.3f}'
            titleStr = 'Average Precision' if ap == 1 else 'Average Recall'
            typeStr = '(AP)' if ap==1 else '(AR)'
            iouStr = '{:0.2f}:{:0.2f}'.format(p.iouThrs[0], p.iouThrs[-1]) \
                if iouThr is None else '{:0.2f}'.format(iouThr)
 
            aind = [i for i, aRng in enumerate(p.areaRngLbl) if aRng == areaRng]
            mind = [i for i, mDet in enumerate(p.maxDets) if mDet == maxDets]
            if ap == 1:
                # dimension of precision: [TxRxKxAxM]
                s = self.eval['precision']
                # IoU
                if iouThr is not None:
                    t = np.where(iouThr == p.iouThrs)[0]
                    s = s[t]
                s = s[:,:,:,aind,mind]
            else:
                # dimension of recall: [TxKxAxM]
                s = self.eval['recall']
                if iouThr is not None:
                    t = np.where(iouThr == p.iouThrs)[0]
                    s = s[t]
                s = s[:,:,aind,mind]
            if len(s[s>-1])==0:
                mean_s = -1
            else:
                mean_s = np.mean(s[s>-1])
            #print(iStr.format(titleStr, typeStr, iouStr, areaRng, maxDets, mean_s))
            category_dimension = 1 + int(ap)
            if s.shape[category_dimension] > 1:
 
                iStr += ", per category = {}"
                mean_axis = (0,)
                if ap == 1:
                    mean_axis = (0, 1)
                per_category_mean_s = np.mean(s, axis=mean_axis).flatten()
                with np.printoptions(precision=3, suppress=True, sign=" ", floatmode="fixed"):
                    print(iStr.format(titleStr, typeStr, iouStr, areaRng, maxDets, mean_s, per_category_mean_s))
            else:
                print(iStr.format(titleStr, typeStr, iouStr, areaRng, maxDets, mean_s, ""))
            return mean_s

博主使用的是DINO-DETR,在第一次运行时会报错:

File “E:\graduate\programsnew\DINO_OTA\DINO-main\DINO-main\util\slconfig.py”, line 87, in _file2dict
osp.join(temp_config_dir, temp_config_name))
with open(dst, ‘wb’) as fdst: PermissionError: [Errno 13] Permission
denied:
‘C:\Users\PENGXI~1\AppData\Local\Temp\tmpimf43tng\tmp2gd8c8_8.py’

提示我们拒绝访问,解决方法:找到E:\graduate\programsnew\DINO_OTA\DINO-main\DINO-main\util\slconfig.py文件

if filename.lower().endswith('.py'):
    with tempfile.TemporaryDirectory() as temp_config_dir:
        temp_config_file = tempfile.NamedTemporaryFile(
            dir=temp_config_dir, suffix='.py')
        temp_config_file.close()#添加这行代码
        temp_config_name = osp.basename(temp_config_file.name)

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

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

相关文章

OpenHarmony Docker移植实践

Docker简介 从操作系统诞生之日起&#xff0c;虚拟化技术就不断的演进与发展&#xff0c;结合目前云原生的发展态势&#xff0c;容器无疑是其中的重要一环。 Docker是一个开源的软件项目&#xff0c;可以在Linux操作系统上提供一层额外的抽象&#xff0c;让用户程序部署在一个相…

React面试题汇总 ---1

1.React的严格模式如何使用&#xff0c;有什么用处&#xff1f; React中StrictMode严格模式_react.strictmode_前端精髓的博客-CSDN博客当我们使用 npx create-react-app my-app 创建一个项目的时候。项目中有一段如下所示的代码&#xff1a;ReactDOM.render( <React.Stric…

SCADA数据采集与监控系统在制药生产过程中的应用

01 应用背景 制药行业关乎大众生命健康&#xff0c;在生产过程中各方面都要求遵循质量规范。制药行业虽然是一种流程化行业&#xff0c;但是和石油、化工等流程行业不同&#xff0c;行业特点决定了它的特殊性。根据质量规范要求&#xff0c;制药行业的SCADA需要满足国内GMP、欧…

David Silver Lecture 8: Integrating Learning and Planning

1 Introduction 1.1 Model based Reinforcement Learning 1.2 model based and model free RL 2 Model-Based Reinforcement Learning 2.1 outline 2.2 Learning a model 2.2.1 what is a model model主要是指&#xff0c;state transitions和相应的reward。 2.2.2 Model…

Fabric 超级账本学习【12】Hyperledger Fabric 2.4+Gin框架+Gateway 读取/写入账本数据 (Go版本)

文章目录 Fabric2.4Gin框架Gateway 读取/写入账本数据Gin框架优点Fabric-GatewayGateway搭建客户端我们需要准备哪些文件Gateway Client 为什么整个过程没有指定过背书节点?&#xff08;请求背书原理&#xff09;安装Gin前提条件成功部署Fabric2.4&#xff08;或其他版本的&am…

Qt 自定义窗口的标题栏,重写鼠标事件实现,隐藏窗口,最大化/最小化窗口,关闭窗口

Qt 自定义窗口的标题栏&#xff0c;重写鼠标事件实现&#xff0c;隐藏窗口&#xff0c;最大化/最小化窗口&#xff0c;关闭窗口 1、main.cpp #include "widget.h"#include <QApplication>int main(int argc, char *argv[]) {QApplication a(argc, argv);Widg…

ArcGis教程-画一幅城市的shp地图

怎样使用ArcGis10.6得到这么一幅shp地图呢&#xff1f; 首先打开ArcGis10.6&#xff0c;点击带黄底的小加号&#xff0c;添加底图。 可以选择中国地图彩色版&#xff0c;然后双击&#xff0c;转动鼠标滑轮找到属于自己的城市。 点击-目录&#xff0c;在新建的文件夹里右击-新建…

TS:如何判断联合类型变量的具体类型?

一 表示一个值可以是几种类型之一&#xff1a;联合类型 在TS中我们常会遇到这样一个问题。 一个变量&#xff0c;即可能是这种类型&#xff0c;也可能是那种类型&#xff0c;然后根据传入的类型的不同进行不同的操作。 比如下面这种情况&#xff1a; if (pet.name fish) {p…

三种灰狼优化算法(Grey Wolf Optimization)及仿真实验——附代码Matalb

目录 摘要&#xff1a; 灰狼算法原理&#xff1a; 灰狼算法流程&#xff1a; 改进的灰狼算法&#xff1a; 多目标的灰狼算法&#xff1a; 三种灰狼算法运行效果&#xff1a; &#xff08;1&#xff09;GWO &#xff08;2&#xff09;I-GWO &#xff08;3&#xff09;M…

Windows Server 2016 中文版、英文版下载 (updated May 2023)

Windows Server 2016 中文版、英文版下载 (updated May 2023) Windows Server 2016 Version 1607&#xff0c;2023 年 5 月更新 请访问原文链接&#xff1a;https://sysin.org/blog/windows-server-2016/&#xff0c;查看最新版。原创作品&#xff0c;转载请保留出处。 作者…

4.7 树的实现(上)

树 树&#xff08;Tree&#xff09;是n&#xff08;n≥0&#xff09;个节点的有限集合T&#xff0c;它满足两个条件 &#xff1a; 有且仅有一个特定的称为根&#xff08;Root&#xff09;的节点&#xff1b; 其余的节点可以分为m&#xff08;m≥0&#xff09;个互不相交的有…

电子企业WMS仓储管理系统解决方案

随着科技的飞速发展&#xff0c;电子制造行业对仓储管理系统的需求也越来越高。电子企业需要一种能够规划、执行和优化仓库货物流通的IT解决方案&#xff0c;以实现自动化操作和提高效率。本文将探讨电子企业WMS仓储管理系统解决方案&#xff0c;从需求分析、系统设计、实施与运…

在Windows系统中安装Wireshark(图文)

1.打开Wireshark官网后&#xff0c;点Get Acquainted->Download后进入到下载界面&#xff0c;在Stable Release中选择下载Windows 64位的安装包&#xff0c;单击Windows Installer(64-bit) 下载。 2.双击下载的安装包&#xff0c;如下图&#xff0c;点击Next。 3.点Noted&am…

ELK的安装部署与使用

ELK的安装与使用 安装部署 部署环境&#xff1a;Elasticsearch-7.17.3 Logstash-7.17.3 Kibana-7.17.3 一、安装部署Elasticsearch 解压目录&#xff0c;进入conf目录下编辑elasticsearch.yml文件&#xff0c;输入以下内容并保存 network.host: 127.0.0.1 http.port: 9200…

基于相似加权自组装框架的低质量少样本MRI脑卒中病变分割

文章目录 Stroke Lesion Segmentation from Low-Quality and Few-Shot MRIs via Similarity-Weighted Self-ensembling Framework摘要本文方法Soft Distribution-aware Updating (SDU) 实验结果 Stroke Lesion Segmentation from Low-Quality and Few-Shot MRIs via Similarity…

蓝桥杯模块学习5——按键

第一章 硬件部分 1.1 电路的组成部分 1.1.1 按键电路 原理图&#xff1a; 功能&#xff1a; &#xff08;1&#xff09; J5&#xff1a;当1和2相接&#xff0c;电路就变成一个4*4的矩阵键盘电路&#xff1b;当2和3相接时&#xff0c;电路变成了一个S4-S7的独立按键&#xf…

平板触控笔要原装的吗?苹果平替笔性价比高的推荐

与苹果的电容笔不同&#xff0c;市场上的电容笔只会给人一种倾斜的压感&#xff0c;并不会像苹果的电容笔那样&#xff0c;可以给人一种重力的压感。不过&#xff0c;如果你不一定要画画&#xff0c;那你就不用花很多钱去买一支苹果的原装电容笔了&#xff0c;只需一支平替电容…

ss命令使用详解

ss是Socket Statistics的缩写。顾名思义&#xff0c;ss命令可以用来获取socket统计信息&#xff0c;它可以显示和netstat类似的内容。ss的优势在于它能够显示更多更详细的有关TCP和连接状态的信息&#xff0c;而且比netstat更快速更高效。 当服务器的socket连接数量变得非常大…

从小白到专家:如何在营销中利用 AI 的力量

欢迎来到营销的未来&#xff0c;时至今日人工智能和人类专业知识以前所未有的方式结合在一起。 认识ChatGPT&#xff0c;这是改变游戏规则的革命性工具。 借助ChatGPT&#xff0c;你最终将能够利用AI的力量做出明智的、数据驱动的决策来满足你的受众需求。 但ChatGPT不仅仅是…

[高光谱]高光谱数据的获取与展示

一、环境准备 需要安装spectral包&#xff0c;这个包专门用于高光谱数据展示。 pip install spectral 二、数据加载 要预先准备原始高光谱的.mat数据和分类数据gt.mat(ground-turth)&#xff1b;然后使用scipy.io中的loadmat(.)将其读入程序。 from scipy.io import loadmat…