3 阚英凡

学生身份

我要认证

暂无相关简介

等级
TA的排名 56w+

Pthon:读取文件名写入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

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

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

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

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

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

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

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

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
勋章 我的勋章
  • 持之以恒
    持之以恒
    授予每个自然月内发布4篇或4篇以上原创或翻译IT博文的用户。不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!
  • 勤写标兵Lv3
    勤写标兵Lv3
    授予每个自然周发布7篇到8篇原创IT博文的用户。本勋章将于次周周三上午根据用户上周的博文发布情况由系统自动颁发。