资源简介
This repository contains the reference implementation for our proposed Convolutional CRFs in PyTorch (Tensorflow planned)
代码片段和文件信息
“““
The MIT License (MIT)
Copyright (c) 2017 Marvin Teichmann
“““
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import sys
import numpy as np
import imageio
# import scipy as scp
# import scipy.misc
import argparse
import logging
from convcrf import convcrf
from fullcrf import fullcrf
import torch
from torch.autograd import Variable
from utils import pascal_visualizer as vis
from utils import synthetic
import time
try:
import matplotlib.pyplot as plt
matplotlib = True
figure = plt.figure()
plt.close(figure)
except:
matplotlib = False
pass
logging.basicConfig(format=‘%(asctime)s %(levelname)s %(message)s‘
level=logging.INFO
stream=sys.stdout)
def do_crf_inference(image unary args):
if args.pyinn or not hasattr(torch.nn.functional ‘unfold‘):
# pytorch 0.3 or older requires pyinn.
args.pyinn = True
# Cheap and easy trick to make sure that pyinn is loadable.
import pyinn
# get basic hyperparameters
num_classes = unary.shape[2]
shape = image.shape[0:2]
config = convcrf.default_conf
config[‘filter_size‘] = 7
config[‘pyinn‘] = args.pyinn
if args.normalize:
# Warning applying image normalization affects CRF computation.
# The parameter ‘col_feats::schan‘ needs to be adapted.
# Normalize image range
# This changes the image features and influences CRF output
image = image / 255
# mean substraction
# CRF is invariant to mean subtraction output is NOT affected
image = image - 0.5
# std normalization
# Affect CRF computation
image = image / 0.3
# schan = 0.1 is a good starting value for normalized images.
# The relation is f_i = image / schan
config[‘col_feats‘][‘schan‘] = 0.1
# make input pytorch compatible
img = image.transpose(2 0 1) # shape: [3 hight width]
# Add batch dimension to image: [1 3 height width]
img = img.reshape([1 3 shape[0] shape[1]])
img_var = Variable(torch.Tensor(img)).cuda()
un = unary.transpose(2 0 1) # shape: [3 hight width]
# Add batch dimension to unary: [1 21 height width]
un = un.reshape([1 num_classes shape[0] shape[1]])
unary_var = Variable(torch.Tensor(un)).cuda()
logging.debug(“Build ConvCRF.“)
##
# Create CRF module
gausscrf = convcrf.GaussCRF(conf=config shape=shape nclasses=num_classes)
# Cuda computation is required.
# A CPU implementation of our message passing is not provided.
gausscrf.cuda()
# Perform ConvCRF inference
“““
‘Warm up‘: Our implementation compiles cuda kernels during runtime.
The first inference call thus comes with some overhead.
“““
logging.info(“Start Computation.“)
prediction = gausscrf.forward(unary=unary_var img=img_var)
if args.n
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-15 16:56 ConvCRF-master\
文件 1166 2018-05-15 16:56 ConvCRF-master\.gitignore
文件 1073 2018-05-15 16:56 ConvCRF-master\LICENSE
文件 2551 2018-05-15 16:56 ConvCRF-master\README.md
文件 8780 2018-05-15 16:56 ConvCRF-master\benchmark.py
目录 0 2018-05-15 16:56 ConvCRF-master\convcrf\
文件 0 2018-05-15 16:56 ConvCRF-master\convcrf\__init__.py
文件 19822 2018-05-15 16:56 ConvCRF-master\convcrf\convcrf.py
目录 0 2018-05-15 16:56 ConvCRF-master\data\
文件 68 2018-05-15 16:56 ConvCRF-master\data\.directory
文件 236150 2018-05-15 16:56 ConvCRF-master\data\2007_000033_0img.png
文件 1710 2018-05-15 16:56 ConvCRF-master\data\2007_000033_5labels.png
文件 343420 2018-05-15 16:56 ConvCRF-master\data\2007_000129_0img.png
文件 4835 2018-05-15 16:56 ConvCRF-master\data\2007_000129_5labels.png
文件 420470 2018-05-15 16:56 ConvCRF-master\data\2007_000332_0img.png
文件 2174 2018-05-15 16:56 ConvCRF-master\data\2007_000332_5labels.png
文件 326961 2018-05-15 16:56 ConvCRF-master\data\2007_000346_0img.png
文件 2433 2018-05-15 16:56 ConvCRF-master\data\2007_000346_5labels.png
文件 370339 2018-05-15 16:56 ConvCRF-master\data\2007_000847_0img.png
文件 2530 2018-05-15 16:56 ConvCRF-master\data\2007_000847_5labels.png
文件 411275 2018-05-15 16:56 ConvCRF-master\data\2007_001284_0img.png
文件 3839 2018-05-15 16:56 ConvCRF-master\data\2007_001284_5labels.png
文件 228540 2018-05-15 16:56 ConvCRF-master\data\2007_001288_0img.png
文件 1801 2018-05-15 16:56 ConvCRF-master\data\2007_001288_5labels.png
目录 0 2018-05-15 16:56 ConvCRF-master\data\output\
文件 163137 2018-05-15 16:56 ConvCRF-master\data\output\Res1.png
文件 131469 2018-05-15 16:56 ConvCRF-master\data\output\Res2.pdf
文件 161758 2018-05-15 16:56 ConvCRF-master\data\output\Res2.png
文件 163137 2018-05-15 16:56 ConvCRF-master\data\output\Res_1.png
文件 7037 2018-05-15 16:56 ConvCRF-master\demo.py
目录 0 2018-05-15 16:56 ConvCRF-master\fullcrf\
............此处省略9个文件信息
相关资源
- Python-RLSeq2Seq用于SequencetoSequence模型的
- Python-高效准确的EAST文本检测器的一个
- Python-pytorch实现的人脸检测和人脸识别
- Python-UNet用于医学图像分割的嵌套UN
- Python-TensorFlow弱监督图像分割
- Python-基于tensorflow实现的用textcnn方法
- Python-Keras实现Inceptionv4InceptionResnetv1和
- Python-pytorch中文手册
- Python-FastSCNN的PyTorch实现快速语义分割
- Python-滑动窗口高分辨率显微镜图像分
- Python-使用MovieLens数据集训练的电影推
- Python-机器学习驱动的Web应用程序防火
- Python-subpixel利用Tensorflow的一个子像素
-
Python-汉字的神经风格转移Neuralst
y - Python-神经网络模型能够从音频演讲中
- Python-深度增强学习算法的PyTorch实现策
- Python-基于深度学习的语音增强使用
- Python-基于知识图谱的红楼梦人物关系
- Python-STGAN用于图像合成的空间变换生
- Python-利用GAN进行图片填充
- Python-基于50W携程出行攻略的顺承事件
- Python-在TensorFlow中实现实现图像卷积网
- Python-60DaysRLChallenge中文版强化学习6
- Python-一个非常简单的BiLSTMCRF模型用于
- Python-Tensorflow仿AlphaGo框架实现的AI围棋
- Python-我是小诗姬全唐诗作为训练数据
- Python-用于物体跟踪的全卷积连体网络
- Python-数学建模竞赛中所使用的相关算
- Python-MonoDepthPyTorchPyTorch无监督单目深
- Python-用Tensorflowjs实现的可回收非可回
评论
共有 条评论