pycocotools
pip install git+git:\\github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
RuntimeError: cublas runtime error : the GPU program failed to execute at C:/a/w/1/s/tmp_conda_3.6_061433/conda/conda-bld/pytorch_1544163532679/work/aten/src/THC/THCBlas.cu:258
原因:pytorch与cuda版本与cuda不匹配
demo 运行代码 python demo.py --dataset pascal_voc --net vgg16 --load_dir models --checksession 1 --checkepoch 100 --checkpoint 124 --image_dir images --cuda --bs 1
resize图片
import os
from PIL import Image
def image_processing():
# 待处理图片路径下的所有文件名字
all_file_names = os.listdir('F:\crack500-1\JEPGImages')
for file_name in all_file_names:
# 待处理图片路径
img_path = Image.open(f'F:\crack500-1\JEPGImages\{file_name}')
# resize图片大小,入口参数为一个tuple,新的图片的大小
img_size = img_path.resize((500, 333))
# 处理图片后存储路径,以及存储格式
img_size.save(f'F:\crack500-1\JEPGImages1\{file_name}', 'JPEG')
if __name__ == '__main__':
image_processing()
windows创建软连接
格式 mklink 文件类型 被连接地址 连接源地址
mklink /D D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\insurance-mall\upload D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\insurance-web\upload
裁剪检测好的图片
import os
import cv2
import math
picture_path='F:/11.27/faster-rcnn.pytorch-pytorch-1.0/data/VOCdevkit2007/VOC2007/JPEGImages'###检测图片的路径
txt_path='F:/11.27/faster-rcnn.pytorch-pytorch-1.0/data/VOCdevkit2007/results/VOC2007/Main/comp4_det_test_c.txt'###生成检测图片目标预测值的文本文件,
# 该文件每一行代表一个缺陷,依次是:图片名称 置信度 x1 y1 x2 y2
thresh=0.7###阈值,只有当置信度阈值达到一定设置值才进行裁剪
ms=open(txt_path)
data=[]
for eachline in ms:
eachline=eachline.strip('\n')
data.append(eachline)
print(data)#将文本文件每一行存储到data列表中
# print(data[0][13:])
for filename in os.listdir(picture_path):#循环读取待测试图片的名
for i in range(len(data)):#循环读取data列表中列表的元素个数
resize_picture = data[i].split(" ")
print(resize_picture)
if resize_picture[0]+'.jpg'==filename and float(resize_picture[1])>thresh:
#只有当检测图片名称和列表中图片名称一样,且置信度大于阈值时进行选择
print(resize_picture[0]+'.jpg')
path=picture_path+'/'+filename
print(path)
img = cv2.imread(path)
print(img)
x1=resize_picture[2]
y1=resize_picture[3]
x2=resize_picture[4]
y2=resize_picture[5]
a=math.ceil(float(x1))
b=math.ceil(float(y1))
c=math.ceil(float(x2))
d=math.ceil(float(y2))
print(b,d,a,c)
cropped = img[b:d, a:c] # 裁剪坐标为[y1:y2, x1:x2]
cv2.imwrite("F:/11.27/faster-rcnn.pytorch-pytorch-1.0/resault/"+filename, cropped)
2万+



被折叠的 条评论
为什么被折叠?



