自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Huiyu Blog

Huiyu flipped for Sun

  • 博客(100)
  • 收藏
  • 关注

原创 Linux环境配置

Anaconda 安装(1) 下载 linux 版本 Anaconda ,如 Anaconda3 2019.07 Linux x86_64.sh(2) L inux 终端输入 sh Anacond 安装包路径(如 sh Anaconda3 2019.07 Linuxx86_64.sh(3) 安装时选择添加环境变量Pycharm 安装(1) 下载 linux 版本 Pycharm 安装包,如 pycharm-community-2021.2.3.tar.gz(2) 解压安装包 tar zxvf

2021-11-04 18:15:17 733

原创 Ubuntu设置 SSH 通过密钥登录

Step1:在本地机器制作密钥对参见:配置 SSH 密钥教程系统会产生两个文件,id_rsa 是密钥,id_rsa.pub 是公钥。Step2:在服务器上安装公钥cd .sshcat id_rsa.pub >> authorized_keys通过以上命令便完成了公钥的安装。为了确保连接成功,请保证以下文件权限正确:chmod 600 authorized_keyschmod 700 ~/.sshStep3: 设置 SSH,打开密钥登录功能编辑 vim /etc/ssh/

2020-07-26 12:21:36 1431

原创 Two different Python packages for distance transform: scipy and mahotas

scipy和mahotas都实现了distance transform,但从图示来看,计算结果还是稍微有所差别的,个人比较倾向于使用scipy。Codeimport SimpleITK as sitkimport numpy as npimport mahotasfrom scipy.ndimage import distance_transform_edtimport matplot...

2020-04-29 15:17:55 447

原创 Puddings收获

缘起:语义分割+形状先验,三个样本。我先想到的是level set,因为“形状先验”这个字眼;而后试了一下distance transform+watershed,因为我真的很喜欢dismap。But, 这两个方案都是非监督,无法handle语义分割,因为无法判别分割出来的某个部分是前景还是背景。而后溜达了一眼我的博客,因为那里有史上最全传统图像分割。我只有三个样本,还是自己造的,deep l...

2020-04-23 21:06:38 231

原创 好用的图像分割标注工具:Labelme

缘起:最近在找合适的读博院校,正在参与一个和人眼语义分割有关的小测验,需要从网上自己找数据,做标签,所以借此机会和大家推荐一下这款救我于火急之中的小工具Labelme。这里有详细的安装步骤:https://github.com/wkentaro/labelme这里是使用指南:https://github.com/wkentaro/labelmeMy ExperiencesInstall因...

2020-04-23 20:06:10 5050 1

原创 Ubuntu 18.04 修改静态ip

查看IP:ifconfig查看网关netstat -rn 或 route -n修改静态ip18.04上新采用的netplan命令。网卡信息配置在/etc/netplan/01-network-manager-all.yaml文件,需做如下配置:network: version: 2 #renderer: NetworkManager ethernets: enp...

2020-01-22 11:00:58 739

原创 Pytorch scatter_()

scatter_(input, dim, index, src)将src中数据根据index中的索引按照dim的方向填进input中。import torchimport numpy as npdef one_hot(labels): _labels = torch.zeros([2,2,4]) _labels.scatter_(dim=0, index=labels.lo...

2019-12-24 10:41:29 225

原创 scipy.ndimage.measurements.find_objects()

scipy.ndimage.measurements.find_objects()从标签数据,确切地说是从打上标签的连通成分中,输出各个连通成分的最小边界框。import numpy as npfrom scipy.ndimage.measurements import label,find_objectsseg_array = np.array([[[1, 1, 1, 1, 0, 0],...

2019-12-21 20:43:13 1106 1

原创 Python shuffle() 函数

描述shuffle() 方法将序列的所有元素随机排序。语法import randomrandom.shuffle (lst )注意:需要导入 random 模块,然后通过 random 静态对象调用该方法。shuffling 每次都能获得相同的结果使用随机模块的random.seed()方法,每次洗牌都可能产生相同的结果。import randomlist = [1,2,3,4...

2019-12-07 15:32:00 478

原创 ubuntu下查看CPU/GPU/内存/硬盘使用率

CPU内存监控top系统内存使用情况free -mGPU内存使用情况nvidia-smi系统硬盘使用情况df -hl

2019-12-06 08:31:09 645

原创 pytorch冻结部分参数训练另一部分

冻结参数仅需两行代码 for param in net.parameters(): param.requires_grad = False另外一个小技巧就是在nn.Module里冻结参数,这样前面的参数就是False,而后面的不变。class Net(nn.Module): def __init__(self): super(Net, self)._...

2019-12-04 22:27:46 1627

原创 四连通与八连通

本人经常把四连通与八连通的作用搞混,所以在此用demo做个笔记。from scipy.ndimage.measurements import labelfrom scipy.ndimage.morphology import generate_binary_structureimport numpy as npa = np.array([[0,0,1,1,0,0], ...

2019-11-28 19:00:52 1022

原创 github - 用hexo搭博客总是出现这样的错误

fatal: the remote end hung up unexpectedly此错误总是反反复复,不期而遇试过以下代码:git config --global http.postBuffer 524288000无效。成功的策略:删除博客根目录下的.deploy_git 文件夹,然后重新推送。...

2019-11-27 11:34:48 651 1

原创 matplotlib.pyplot复用figure

RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (matplotlib.pyplot.figure) are retained until explicitly closed and may consume too much memory. (To...

2019-11-26 08:29:22 2510

原创 L1 loss VS L2 loss; L1 regularization VS L2 regularization

L1 和L2 既可以作为 loss function 也可以作为 reguarizationL1 loss VS L2 loss公式比较鲁棒性:L1 更鲁棒,因为L2 的误差会平方增长。当存在离群点(outliers)的时候,这些点会占loss的主要组成部分, 使用梯度下降法求解的时候梯度很大,可能导致梯度爆炸.。稳定性(数据集的一个小的移动):L2 是比L1 具有更好的性质。收敛...

2019-11-22 19:59:31 693

原创 numpy数组拼接

numpy.concatenate((a1, a2, …), axis=0, out=None)Join a sequence of arrays along an existing axis.在已有的维度上进行拼接,能够一次完成多个数组的拼接.numpy.stack(arrays, axis=0, out=None)Join a sequence of arrays along a ne...

2019-11-20 21:16:16 200

原创 两个相反的通道无法求Distrance transform

场景:图像分割,一般会用将groud truth编码为背景通道和前景通道现对groud truth计算Distrance transformfrom scipy.ndimage import distance_transform_edtimport torchtemp1 = torch.from_numpy(seg_array == 2).view(1,DHW[0],DHW[1],DHW[...

2019-11-20 20:20:53 169

原创 解决GPU显存未释放问题

问题:误用Ctrl+z退出程序,结果程序退出了,显存未释放,nvidia-smi仍然可以看到进程。运行程序报错:pytorch RuntimeError: CUDA error: all CUDA-capable devices are busy or unavailablesudo kill id无法释放显存:解决办法:sudo -9 kill id解决GPU显存未释放问题...

2019-11-19 18:13:55 5482

原创 SimpleITK最多只能保存三维数据!!!

欲保存[2,48,256,256]大小的矩阵结果默认保存了前3维数据:解决方案:保存为numpy矩阵。np.save("filename.npy",a)b = np.load("filename.npy")

2019-11-18 22:39:21 482

原创 Ubuntu 18.04 NVIDIA驱动安装

NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.Step1:检测你的NVIDIA显卡型号和推荐的驱动程序的模型。$ ubuntu-drivers device...

2019-11-15 15:18:09 629

原创 TypeError: Object of type 'int64' is not JSON serializable

错误分析:1. python3中没有int64这个数据类型,所有的整型都是int解决方案:转换成python3内置数据类型即可,eg.float(size_z)Note:错误的转换方式size_z.astype(np.float32)原因:json不支持numpy数据类型...

2019-11-12 11:15:10 916

原创 python列表之list.append(obj),list.extend(seq)

list.append(obj) 在列表末尾添加新的对象list.extend(seq) 用新列表扩展原来的列表list = []list.extend('extend0')# not intendedlist.extend(['extend1'])list.append('extend2')print(list)Output:[‘e’, ‘x’, ‘t’, ‘e’, ‘n’, ...

2019-11-12 09:54:44 456

原创 Pytroch网络参数的快速增删改查(实例讲解)

Relu>Prelu网络模型代码class TumorNet(nn.Module): def __init__(self): super(TumorNet, self).__init__() self. nff = [1, 8]#NumFeature # forward1 self.forward1 = nn.Sequential( nn.Conv3d(self....

2019-11-11 21:10:05 262

原创 Python计算并绘制灰度直方图

灰度直方图灰度直方图是关于灰度级分布的函数,将数字图像中的所有像素,按照灰度值的大小,统计其出现的频率。其中,横坐标是灰度级,纵坐标是该灰度级出现的频率。如果将图像总像素亮度(灰度级别)看成是一个随机变量,则其分布情况就反映了图像的统计特性,这可用probability density function (PDF)来刻画和描述,表现为灰度直方图。OpenCV计算并绘制直方图import c...

2019-11-09 21:49:27 15934

原创 Python glob 递归遍历匹配文件;os.makedirs()递归创建目录

简约版在python中,glob模块用来查找匹配文件常用的匹配规则:: 匹配所所有? : 匹配一个字符如果没有匹配的,glob.glob(path)将返回一个空的list:[]from glob import globfile_path = "/home/lihuiyu/Code/results_S2_W20040/*/*.pth"print(glob(file_...

2019-11-08 22:45:25 1572

原创 visdom [Errno 110] Connection timed out while downloading https://cdn.plot.ly/plotly-latest.min.js

ERROR:root:Error [Errno 110] Connection timed out while downloading https://cdn.plot.ly/plotly-latest.min.jsERROR:tornado.general:Could not open static file ‘/usr/local/lib/python3.6/dist-packages/vi...

2019-11-07 22:19:42 2478 3

原创 Code Pieces OnGoing

进度条from tqdm import tqdmpbar = tqdm(total=total_iter) # Initialisepbar.update(1)pbar.set_description("%s" % outer_name+'-'+inter_name)pbar.close()时间显示import timestart_time = time.time()p...

2019-11-06 23:07:59 194

原创 CT图像之Hu值变换与窗宽窗位调整

医学影像“调窗”(window-leveling)的算法B. Window-leveling 算法: W/L 是专门为 CT 设计的。原理很简单:CT 图像里不同组织的密度 (用 Hounsfield 单位) 是在固定的值域, 与具体设备和成像软件没有关系。因此,要看头颅时, 我们只需将头颅的值域转换到 0-255 就行了。CT W/L 不讲头颅值域的 min 和 max, 而说 max - ...

2019-11-05 23:14:02 21417 17

原创 Ubuntu下安装Opencv(cv2)

报错:E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?安装方法一(不推荐)sudo apt-get install python-opencv解决方案sudo pip3 install opencv-pythonUbuntu下apt-get与pip安装命令的区别...

2019-11-03 15:39:42 6453 2

原创 有趣的tqdm进度条库让python进度可视化

tqdm官网地址:https://pypi.org/project/tqdm/Github地址:https://github.com/tqdm/tqdmimport timefrom tqdm import tqdmfrom tqdm._tqdm import trangefor i in trange(1000):# trange(i) 是对tqdm(range(i)) 特殊优化过的...

2019-11-03 11:39:59 372

原创 Ubuntu查看硬盘信息

lsscsi包默认是不安装的,可以使用以下命令安装lsscsi。sudo apt-get install lsscsilsscsi命令(lsscsi -t -L)能很方便的看出哪些是固态硬盘(SSD),哪些是SATA盘,哪些是FC盘。sudo lsscsi[0:2:0:0] disk AVAGO MR9361-8i 4.68 /dev/sda[0:2:...

2019-10-31 11:09:37 9126

原创 python数据类型转换——矩阵float转int

1、查看数据类型array.dtype2、转换数据类型array = array.astype(np.uint8)参考:NumPy 数据类型

2019-10-26 21:11:13 25420 2

原创 python复制文件到指定目录

主要函数:shutil.copyfile(srcFilePath,dstFilePath)import osimport shutiloldseg_path = "/media/lihuiyu/sda4/LITS/Training_dataset/"newseg_path = "/media/lihuiyu/sda3/LiTS/Valid_seg/"for i in range(9):...

2019-10-26 17:55:16 3048

原创 ubuntu查看所有正在运行的进程

查看所有运行中的进程ps aux | less查看非root运行的进程ps -U root -u root -N通过PID查看用户ll /proc/PID参考:ubuntu查看所有正在运行的进程

2019-10-25 12:10:28 35954

原创 CT图像预处理之重采样

CT图像的预处理操作一般包括以下几步:step1: spacing interpolationstep2: window transformstep3: get mask effective rangestep4: generate subimage配套代码各步骤意义:step1: spacing interpolation。用插值(interpolation)一词可能不太准确,...

2019-10-13 14:09:34 12845 26

原创 我多想时光都可以典当,你回来带我赎回过往

Good morning, everyone! My name is lihuiyu, I’m very glad to be here for this conference. My topic today is DSFPSO: An Improved Particle Swarm Optimization with Dynamic Scale-free Network for Detect...

2019-10-09 03:04:11 449

原创 word 两端对齐 过长的单词中加分隔符

本文旨在解决word两端对齐排版中,某些行字符间距过大的问题,如下图所示。方案一:布局>断字>自动(推荐)方案二:开始>段落>允许西文在单词中间换行但此方法不会在断词中间自动添加连接符,不推荐。...

2019-10-06 09:37:46 5369 1

原创 nibabel和SimpleITK对NIFTI文件的读取和保存

ITKsnap的读取原始图片:KiTS dataLiTS dataimport nibabel as nib#nib.save(img, os.path.join('output', 'test.nii.gz')import SimpleITK as sitkimport oskits_ct = "../case_00000/imaging.nii.gz"kits_seg = "...

2019-09-26 23:17:28 2929

原创 python按行读取文件,如何去掉换行符"\n"

for line in file.readlines(): line=line.strip('\n')

2019-09-12 10:35:29 3478

原创 RuntimeError: one of the variables needed for gradient computation has been modified by...

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation在计算loss的过程中,浅复制搞的鬼出错代码:temp = target正确代码:temp = target.clone()当然,此错误还有其他原因...

2019-09-05 21:27:03 1129

空空如也

空空如也

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

TA关注的人

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