当前位置:网站首页>VARIATIONAL IMAGE COMPRESSION WITH A SCALE HYPERPRIOR文献实验复现
VARIATIONAL IMAGE COMPRESSION WITH A SCALE HYPERPRIOR文献实验复现
2022-07-02 01:31:00 【小夭。】
前言
这篇文章是在END-TO-END OPTIMIZED IMAGE COMPRESSION文献基础上进行的改进,主要是加入了超先验网络对边信息进行了处理。相关环境配置与基础可以参考END-TO-END OPTIMIZED IMAGE COMPRESSION
github地址:github
1、相关命令
(1)训练
python bmshj2018.py -V train
同样,我这里方便调试,加入了launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
// bmshj2018
"args": ["--verbose","train"] // 训练
}
]
}
2、数据集
if args.train_glob:
train_dataset = get_custom_dataset("train", args)
validation_dataset = get_custom_dataset("validation", args)
else:
train_dataset = get_dataset("clic", "train", args)
validation_dataset = get_dataset("clic", "validation", args)
validation_dataset = validation_dataset.take(args.max_validation_steps)
给定数据集地址的情况下使用对应数据集,否则使用默认CLIC数据集
3、整理训练流程
整个代码其实主要还是在bls2017.py上进行的补充,所以整个流转流程是和bls2017的过程一样,这里我简单整理一下这篇文献的训练过程
实例化对象
init中初始化一些参数(LocationScaleIndexedEntropyModel、ContinuousBatchedEntropyModel两个熵模型中所需参数,对应的模型说明可以见tfc熵模型,具体的参数有scale_fn以及给定的num_scales)
初始化非线性分析变换、非线性综合变换、超先验非线性分析变换、超先验非线性综合变换、添加均匀噪声、获得先验概率等
call中通过两个熵模型计算
(1)x->y(非线性分析变换)
(2)y->z(超先验非线性分析变换)
(3)z->z_hat、边信息bit数(ContinuousBatchedEntropyModel熵模型)
(4)y->y_hat、比特数(LocationScaleIndexedEntropyModel熵模型)
(5)计算bpp(这里bpp=bit/px,bit数等于上面两项bit数相加)、mse、loss
其中非线性分析变换即cnn卷积的过程,其中有一步补零的过程是为了输入与输出图片尺寸相等model.compile
通过model.compile配置训练方法,使用优化器进行梯度下降、算bpp、mse、lose的加权平均过滤剪裁数据集
通过参数查看是否给定了数据集路径
给定数据集路径:直接剪裁成256x256(统一剪裁成256*256送入网络训练,后面压缩的图片不会改变大小)
未给定数据集路径:用CLIC数据集,过滤出图片大小大于256x256的三通的图片,然后进行剪裁
分出训练数据集与验证数据集model.fit
传入训练数据集,设置相关参数(epoch等)进行训练
通过retval = super().fit(*args, **kwargs)进入model的train_step(不得不说这里封装的太严实了…但从单文件的代码根本找不到怎么跳进去的)train_step
self.trainable_variables获取变量集,通过传入变量集与定义的损失函数,进行前向传播与反向误差传播更新参数。然后更新loss, bpp, mse
def train_step(self, x):
with tf.GradientTape() as tape:
loss, bpp, mse = self(x, training=True)
variables = self.trainable_variables
gradients = tape.gradient(loss, variables)
self.optimizer.apply_gradients(zip(gradients, variables))
self.loss.update_state(loss)
self.bpp.update_state(bpp)
self.mse.update_state(mse)
return {
m.name: m.result() for m in [self.loss, self.bpp, self.mse]}
- 接下来就是重复训练的过程,直到到终止条件(比如epoch达到10000)
4、压缩一张图片
python bmshj2018.py [options] compress original.png compressed.tfci
这里通过launch.json调试
"args": ["--verbose","compress","./models/kodak/kodim01.png", "./models/kodim01.tfci"] // 压缩一张图
引入你自己的path
边栏推荐
- 三分钟学会基础k线图知识
- Basic usage of three JS high-order functions --filter---map---reduce
- Raspberry pie 4B learning notes - IO communication (1-wire)
- KS006基于SSM实现学生成绩管理系统
- [image enhancement] vascular image enhancement based on frangi filter with matlab code
- 站在新的角度来看待产业互联网,并且去寻求产业互联网的正确方式和方法
- I'll teach you to visit Amazon RDS for a year and build a MySQL cloud database (only 10 minutes, really fragrant)
- The concept and application of Cartland number
- Study note 2 -- definition and value of high-precision map
- About asp Net core uses a small detail of datetime date type parameter
猜你喜欢

Docker安装Oracle_11g

ACM tutorial - quick sort (regular + tail recursion + random benchmark)

成功实现边缘编码需要了解的六大经验教训

【疾病检测】基于BP神经网络实现肺癌检测系统含GUI界面

Basic concepts of machine learning
![[Floyd] post disaster reconstruction](/img/7a/f72c7781ef148212c870a56fb9a607.jpg)
[Floyd] post disaster reconstruction
![[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production](/img/dc/e9adb1b41c2175c6f18d8027e0530a.jpg)
[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production

Learn about servlets

The first "mobile cloud Cup" empty publicity meeting, looking forward to working with developers to create a new world of computing!

Hcip day 14 (MPLS protocol)
随机推荐
Unity AssetBundle subcontracting
电商系统中常见的9大坑,你踩过没?
[Floyd] post disaster reconstruction
Single chip microcomputer -- hlk-w801 transplant NES simulator (III)
首场“移动云杯”空宣会,期待与开发者一起共创算网新世界!
现货黄金分析的技巧有什么呢?
Just using the way and method of consuming the Internet to land and practice the industrial Internet will not bring long-term development
6-2漏洞利用-ftp不可避免的问题
Bubble Sort Graph
[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production
Study note 2 -- definition and value of high-precision map
Feature extraction and detection 16 brisk feature detection and matching
学习笔记2--高精度地图定义及价值
[image enhancement] vascular image enhancement based on frangi filter with matlab code
6-3 vulnerability exploitation SSH environment construction
The pain of Xiao Sha
error: . repo/manifests/: contains uncommitted changes
matlab 使用 resample 完成重采样
Design and implementation of radio energy transmission system
k线图形态这样记(口诀篇)