
Pytorch学习
徐梓航
email:1038545009@foxmail.com
灯书茶盏,布衣清欢,不骄不躁,天道酬勤
(研究僧的学习记录,熟人大佬就勿关啦)
展开
-
Libtorch使用
1.下载安装cmake2.安装且永久配置opencv(debug+release)3.安装vs2017(开始电脑只有vs2013, 貌似不支持, 很多编译错误)mean, std很重要,开始直接原图没有预处理进行inference, 效果很差, 加了就ok了...std::shared_ptr<torch::jit::script::Module> module = ...原创 2019-12-10 10:13:23 · 1549 阅读 · 0 评论 -
C++ 调用pytorch进行inference
int main() { int img_size = 224; torch::DeviceType device_type = at::kCUDA; cout << "use cuda" << endl; // Deserialize the ScriptModule from a file using torch::jit::load(). Module ...原创 2019-12-04 16:19:55 · 1034 阅读 · 0 评论 -
灰度图像与RGB图像的互相转换
记代码中的一些小细节:解码代码:def decode_segmap(label_mask, dataset, plot=False): """Decode segmentation class labels into a color image Args: label_mask (np.ndarray): an (M,N) array of in...原创 2019-11-19 09:53:43 · 4542 阅读 · 0 评论 -
语义分割—交叉熵损失函数
from dataloaders import utilscriterion = utils.cross_entropy2d import torch.nn as nndef cross_entropy2d(logit, target, ignore_index=255, weight=None, size_average=True, batch_average=True): n...原创 2019-11-18 20:35:10 · 4197 阅读 · 1 评论 -
Pytorch 单机多卡训练
记录下小tips:原创 2019-11-10 15:17:39 · 1354 阅读 · 0 评论 -
pytorch中layer和function的区别
最近遇到代码中的一个warining,UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead. warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate inste...原创 2019-11-05 09:36:14 · 1055 阅读 · 0 评论 -
Pytorch--deeplabv3+
https://github.com/jfzhang95/pytorch-deeplab-xceptionhttps://www.jianshu.com/p/026c5d78d3b1https://www.zhihu.com/question/282696986原创 2019-11-04 14:14:24 · 5540 阅读 · 1 评论 -
Pytorch--RandomScaleCrop操作
class RandomScaleCrop(object): def __init__(self, base_size, crop_size, fill=0): self.base_size = base_size self.crop_size = crop_size self.fill = fill def __call__(self, ...原创 2019-11-02 09:31:07 · 3730 阅读 · 0 评论 -
pytorch分割网络数据输入接口
pytorch的自定义接口是真的方便, 记录一下自己分割数据输入的脚本:# -*- coding: utf-8 -*-# @Time : 2019/10/31 21:36# @Author : Yunyun Xu# @Contact : 1443563995@qq.com# @File : MyDatasetReader.py# @Software: Pycharm...原创 2019-11-01 12:54:47 · 904 阅读 · 0 评论 -
Pytorch 1.2 使用自带tensorboard显示不了graph解决方案
https://discuss.pytorch.org/t/seeking-help-the-model-does-not-appear-in-the-graphs-with-tensorboard/53572论坛中so many people都碰到这个问题了,大家可以看下论坛,有大佬给了解决方案但是我发现更简单的方法就是卸载你装的tensorboardpip uninstall te...原创 2019-10-09 14:54:50 · 1023 阅读 · 0 评论 -
Pytorch GPU
https://www.cnblogs.com/QingHuan/p/10016959.htmlnet = Net()if torch.cuda.is_available(): print("Using GPU")device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")net.to(devi...转载 2019-10-02 16:38:50 · 367 阅读 · 0 评论 -
Pytorch 加载预训练模型
pretrained_dict =...model_dict = model.state_dict()# 1. filter out unnecessary keyspretrained_dict = {k: v for k, vin pretrained_dict.items() if k inmodel_dict}# 2. overwrite entries in the ex...原创 2019-10-02 11:00:51 · 1715 阅读 · 4 评论 -
pytorch 为不同层设置学习率
原创 2019-09-13 11:03:47 · 1030 阅读 · 0 评论 -
Pytorch ImageFoader源码
import torch.utils.data as data#PIL: Python Image Library缩写,图像处理模块# Image,ImageFont,ImageDraw,ImageFilterfrom PIL import Image import osimport os.path # 图片扩展(图片格式)IMG_EXTENSIONS = [ ...原创 2019-09-10 14:30:22 · 811 阅读 · 1 评论 -
win10+GPU+CUDA10.0配置Pytorch环境
安装细节:1.cuda安装选择自定义安装比较好,且要将Driver components 应该勾上,英伟达公司为了方便,把cuda和相应的nvidia Driver打包在一起。否则就有CUDA driver version is insufficient for CUDA runtime version,是说driver驱动程序的版本太低,以致cuda不能运行。2.记录一下测试路径...原创 2019-09-03 13:43:24 · 7246 阅读 · 0 评论