摘要: pytorch网络输入图像的格式为(C, H, W),而numpy中的图像的shape为(H,W,C) 所以一般需要变换通道,将numpy中的shape变换为torch中的shape。 方法如下: # A是numpy数据类型A = A.transpose(0,1,2) # 没有改变:(h,w,c) 阅读全文
posted @ 2019-12-06 11:24 青牛梦旅行 阅读(4424) 评论(0) 推荐(0)
摘要: import os,shutil def getfilelist(filepath): filelist = os.listdir(filepath) # 获取filepath文件夹下的所有的文件 # files = [] for i in range(len(filelist)): child = 阅读全文
posted @ 2019-11-22 22:17 青牛梦旅行 阅读(368) 评论(0) 推荐(0)
摘要: import numpy as np ''' 目标检测中常用到NMS,在faster R-CNN中,每一个bounding box都有一个打分,NMS实现逻辑是: 1,按打分最高到最低将BBox排序 ,例如:A B C D E F 2,A的分数最高,保留。从B-E与A分别求重叠率IoU,假设B、D与A的IoU大于阈值,那么B和D可以认为是重复标记去除 3,余下C E F,重复前面两步。 ''' d 阅读全文
posted @ 2019-08-22 09:08 青牛梦旅行 阅读(2835) 评论(0) 推荐(0)
摘要: def compute_iou(rec1, rec2): """ computing IoU :param rec1: (y0, x0, y1, x1), which reflects (top, left, bottom, right) :param rec2: (y0, x0, y1, x1) :return: scala value of IoU """ # computing area o 阅读全文
posted @ 2019-08-22 09:07 青牛梦旅行 阅读(4369) 评论(0) 推荐(0)
摘要: import sys h, w = input().strip().split() h = int(h) w = int(w) img = [] for i in range(h): line = sys.stdin.readline().strip() line = list(map(int, line.split(' '))) img.append(line) kernel = [] m = 阅读全文
posted @ 2019-08-22 09:05 青牛梦旅行 阅读(1050) 评论(0) 推荐(0)
摘要: # 给一个字符串,按如下规则把它翻译成字符串:1翻译成a,2翻译成b,...25翻译成z;一个数可以有多种翻译方式,比如122可以翻译成abb和kb还可以翻译成aw即3种翻译方式。计算一个数字有几种翻译方式class Solution(object): def numDecodings(self, s): """ :type s: str :rtype: int """ s = str(s) di 阅读全文
posted @ 2019-08-22 09:03 青牛梦旅行 阅读(263) 评论(0) 推荐(0)
摘要: 链接:https://pan.baidu.com/s/1EyTJdTkUIapQ_BTwubH_Dg 提取码:a4mj 阅读全文
posted @ 2019-08-14 14:17 青牛梦旅行 阅读(1652) 评论(0) 推荐(0)
摘要: 时间复杂度:: 平均:O(nlog(n)) 最坏:O(nlog(n)) 最好:O(nlog(n)) 空间复杂度:O(n) 稳定性:稳定 阅读全文
posted @ 2019-08-12 17:05 青牛梦旅行 阅读(139) 评论(0) 推荐(0)
摘要: 简单选择排序的改进:快速排序 时间复杂度:: 平均:O(nlog(n)) 最坏:O(n^2) # 有序 最好:O(nlog(n)) 空间复杂度:O(log(n)) ,最坏的情况O(n) 稳定性:不稳定(选择排序都是不稳定的) 阅读全文
posted @ 2019-08-12 16:53 青牛梦旅行 阅读(148) 评论(0) 推荐(0)
摘要: 时间复杂度:: 平均:O(n^2) 最坏:O(n^2) 最好:O(n^2) 空间复杂度:O(1) 稳定性:不稳定(三个简单排序中唯一一个不稳定的算法,也是最好最坏情况一样复杂的一个,其他两个最优情况都是O(n)) 阅读全文
posted @ 2019-08-12 16:49 青牛梦旅行 阅读(170) 评论(0) 推荐(0)