自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(9)
  • 收藏
  • 关注

转载 Python:读取文件名写入txt

import osfile_path = "Annotations"# os.listdir(file)会历遍文件夹内的文件并返回一个列表path_list = os.listdir(file_path)# print(path_list)# 定义一个空列表,我不需要path_list中的后缀名path_name=[]# 利用循环历遍path_list列表并且利用split去掉后缀名for i in path_list: path_name.append(i.split(".")[

2020-06-30 10:11:04 1112

原创 Python:裁剪文件夹中的所有照片

import cv2import osrootdir = r'./before/' # 指明被遍历的文件夹for parent, dirnames, filenames in os.walk(rootdir): for filename in filenames: currentPath = os.path.join(parent, filename) img = cv2.imread(currentPath) cropped = img[1920:3360, 0:1440] #

2020-06-30 08:38:31 471

原创 Matlab:png2mat

clc;clear;namelist = dir('F:\mat\*.png');len = length(namelist); for i = 1:len png_file = fullfile( 'F:\mat\', namelist(i).name ); I = imread( png_file); % path = 'F:\mat\' name = '001' ext = '.png' [ path , name , ext ] = filep

2020-06-29 10:39:02 228

原创 Python:将彩色标注图转变为灰度值标签图

import osfrom PIL import Imageimport cv2 as cvimport numpy as nplabel_dir = './label/'label_process_dir = './label_process/'if not os.path.exists(label_process_dir): os.makedirs(label_process_dir)for file in os.listdir(label_dir): label =

2020-06-29 10:36:29 1271

原创 Python:检验PS标注是否准确

import numpy as npimport osimport cv2 as cvlabel_dir = './png/'label_process_dir = './label_process/'for file in os.listdir(label_dir): label = label_dir + file if os.path.isfile(label): print(file) # 获得一张图片的所有种类的灰度值 l

2020-06-29 10:34:09 193

原创 Python:数据增强,水平翻转/亮度饱和度调整

from PIL import Imageimport numpy as npimport osimport os.pathimport cv2MAX_VALUE = 100'''### 图片左右对称 ===rootdir = r'F:\data\png_3' # 指明被遍历的文件夹for parent, dirnames, filenames in os.walk(rootdir): for filename in filenames: print('parent i

2020-06-29 10:32:04 1462

原创 Pytorch:One-hot编码

def mask2onehot(mask, num_classes): # mask为灰度图,(H,W)→(K,H,W) _mask = [mask == i for i in range(num_classes)] return np.array(_mask).astype(np.uint8)

2020-06-29 10:15:17 740

原创 Pytorch:使用visdom读取.mat文件

from visdom import Visdomimport scipy.io as ioimport numpy as np#python -m visdom.server #于cmd输入vis = Visdom()pred = io.loadmat(‘E:/abc/123.mat’)pred = pred[‘pred’].astype(np.uint8) #'pred’为自定义的.mat内部变量pred = 100 * pred #100为了拉大灰度值差异,可自定义vis.im

2020-06-29 09:56:33 3677

原创 Pytorch:MNIST十分类

import torchimport torch.nn as nnimport torchvision.datasets as normal_datasetsimport torchvision.transforms as transformsfrom torch.autograd import Variablenum_epochs = 5learning_rate = 0.001def get_variable(x): x = Variable(x) return x.cuda()

2020-06-09 23:36:59 565

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除