Interspecies Knowledge Transfer for Facial Keypoint Detection关键点检测

 

Github地址:Interspecies Knowledge Transfer for Facial Keypoint Detection(迁移学习检测动物头部关键点)

基于torch进行论文中想法的实现

论文地址

1. Torch的安装部分

不得不说torch要比caffe好配置多了,emm , 祝愿你们可以一次性顺利配置好,话不多说开始了

Torch的github库https://github.com/torch/distro

git clone https://github.com/torch/distro.git ~/torch --recursive
# 国内git clone特别慢,建议参考前一篇博客https://www.cnblogs.com/pprp/p/9450512.html进行加速,或者采用我的git lab(git clone https://gitlab.com/pprp/distro.git ~/torch --recursive)
# 假设在~/torch下进行配置,你也可以更改位置
cd ~/torch
# 安装依赖(如果失败了,记得查看有哪些失败了,然后手动重装)
bash install-deps
# 安装
./install.sh
source ~/.bashrc

uninstall 卸载

rm -rf ~/torch
./clean.sh

可以使用命令行中的Luarocks安装新软件包:

# run luarocks WITHOUT sudo
$ luarocks install image
$ luarocks list

安装完成后,您可以使用命令来运行火炬th

Th简介详细介绍

$ th

  ______             __   |  Torch7
/_ __/__ ________/ / | Scientific computing for Lua.
/ / / _ \/ __/ __/ _ \ |
/_/ \___/_/ \__/_//_/ | https://github.com/torch
| http://torch.ch th> torch.Tensor{1,2,3}
1
2
3
[torch.DoubleTensor of dimension 3] th>

要退出交互式会话,请键入^c两次 - 控制键以及c键,两次或键入os.exit()。一旦用户输入了完整的表达式,例如1 + 2,并且命中输入,交互式会话将评估表达式并显示其值。

要评估在源文件file.lua中编写的表达式,请编写 dofile "file.lua"

要以非交互方式在文件中运行代码,可以将其作为th命令的第一个参数::

$ th file.lua

有多种方法可以运行Lua代码并提供选项,类似于可用于perlruby程序的选项:

 $ th -h
Usage: th [options] [script.lua [arguments]] Options:
-l name load library name
-e statement execute statement
-h,--help print this help
-a,--async preload async (libuv) and start async repl (BETA)
-g,--globals monitor global variables (print a warning on creation/access)
-gg,--gglobals monitor global variables (throw an error on creation/access)
-x,--gfx start gfx server and load gfx env
-i,--interactive enter the REPL after executing a script

2. 具体用法

Update

To update your already installed distro to the latest master branch of torch/distro simply run:

./update.sh

Cleaning

To remove all the temporary compilation files you can run:

./clean.sh

To remove the installation run:

# Warning: this will remove your current installation
rm -rf ./install

You may also want to remove the torch-activate entry from your shell start-up script (~/.bashrc or ~/.profile).

Test

You can test that all libraries are installed properly by running:

./test.sh

3. 继续配置animal_human_kp

1. 安装一些其他配置

Install Torch requirements:

luarocks install torchx
  • npy4th (You may need to checkout commit from 5-10-16)
git clone https://github.com/htwaijry/npy4th.git
cd npy4th
luarocks make

Install Python requirements if needed:

Install the Spatial Tranformer module provided:

cd stnbhwd-master
luarocks make

2. 数据集

cd ~/animal_human_kp
cd data
wget https://www.dropbox.com/s/9t770jhcjqo3mmg/release_data.zip
unzip *.zip

3.模型下载

cd ~/animal_human_kp
cd models
wget https://www.dropbox.com/s/44ocinlmx8mp8v2/release_models.zip
unzip *.zip

4. 开始数据的测试

cd ~/animal_human_kp
mkdir output
cd torch
th test.th -out_dir_images ../output/

打开output文件夹

#会出现一些结果文件
results.html
stats.txt
bar.pdf

5. 训练模型

开始训练整个模型:

cd torch
th train_full_model.th

训练翘曲网络:

th torch/train_warping_net.th

测试数据的调整:

解释参数:

Options
-mean_im_path mean image for image preprocessing for keypoint network training [../data/aflw_cvpr_224_mean.png]
-std_im_path std image for image preprocessing for keypoint network training [../data/aflw_cvpr_224_std.png]
-limit num of test data to read. negative means all [-1] # 设置多少张图片测试,-1代表全部
-val_data_path validation data file path [../data/our_horse.txt] # 设置读取图片的路径以及对应的npy文件的路径
-model_path [../models/horse_full_model_tps.dat] # 训练生成模型的位置
-out_dir_images [../scratch/test_images] # 结果的输出
-gpu gpu to run the training on [1] # 选取哪个gpu
-iterations num of iterations to run [2] # 设置迭代的层数
-batchSize batch size [100]
-bgr [true]
-face true if testing a model with no warping network [false]

/animal_human_kp/torch test.th中找到-val_data_path的设置,修改为需要的txt形式,

其中对应文件的形式为 对应的图片地址+空格+对应的npy文件地址

合成代码如下:

cd /animal_human_kp/data/horse/im/ inria-horses
# 生成完整的路径
ls | sed "s:^:`pwd`/:" > test_minLoss_horse.txt
cp test_minLoss_horse.txt test_minLoss_horse_npy.txt
# 然后通过vim的替换命令s进行替换,以下是一个示例
vim test_minLoss_horse_npy.txt
:%s/im/npy/ig
:%s/jpg/npy/ig
# 将两个文件进行合成
paste -d' ' test_minLoss_horse.txt test_minLoss_horse_npy.txt > our_horse.txt
# 注意最后再次检查合成文件的内容,进行排查

将our_horse.txt放到/animal_human_kp/data文件下

然后到torch文件夹下运行代码:

# out 是我新建的文件夹,你也可以指定到你需要的位置
th test.th -out_dir_images ../out -val_data_path ../data/our_horse.txt -iterations 100

Animal_human_kp人脸与马脸迁移学习GitHub 论文实现的更多相关文章

  1. 基于TensorFlow Object Detection API进行迁移学习训练自己的人脸检测模型(二)

    前言 已完成数据预处理工作,具体参照: 基于TensorFlow Object Detection API进行迁移学习训练自己的人脸检测模型(一) 设置配置文件 新建目录face_faster_rcn ...

  2. NASNet学习笔记——   核心一:延续NAS论文的核心机制使得能够自动产生网络结构;    核心二:采用resnet和Inception重复使用block结构思想;    核心三:利用迁移学习将生成的网络迁移到大数据集上提出一个new search space。

    from:https://blog.csdn.net/xjz18298268521/article/details/79079008 NASNet总结 论文:<Learning Transfer ...

  3. Sebastian Ruder : NLP 领域知名博主博士论文面向自然语言处理的神经网络迁移学习

    Sebastian Ruder 博士的答辩 PPT<Neural Transfer Learning for Natural Language Processing>介绍了面向自然语言的迁 ...

  4. 1、VGG16 2、VGG19 3、ResNet50 4、Inception V3 5、Xception介绍——迁移学习

    ResNet, AlexNet, VGG, Inception: 理解各种各样的CNN架构 本文翻译自ResNet, AlexNet, VGG, Inception: Understanding va ...

  5. 迁移学习︱艺术风格转化:Artistic style-transfer+ubuntu14.0+caffe(only CPU)

    说起来这门技术大多是秀的成分高于实际,但是呢,其也可以作为图像增强的工具,看到一些比赛拿他作训练集扩充,还是一个比较好的思路.如何在caffe上面实现简单的风格转化呢? 好像网上的博文都没有说清楚,而 ...

  6. keras系列︱迁移学习:利用InceptionV3进行fine-tuning及预测、完美案例(五)

    引自:http://blog.csdn.net/sinat_26917383/article/details/72982230 之前在博客<keras系列︱图像多分类训练与利用bottlenec ...

  7. DNN结构构建:NAS网络结构搜索和强化学习、迁移学习

    前言 谷歌推出的NASNet架构,用于大规模图像分类和识别.NASNet架构特点是由两个AutoML设计的Layer组成--Normal Layer and Reduction Layer,这样的效果 ...

  8. Google Tensorflow 迁移学习 Inception-v3

    附上代码加数据地址 https://github.com/Liuyubao/transfer-learning ,欢迎参考. 一.Inception-V3模型 1.1 详细了解模型可参考以下论文: [ ...

  9. Gluon炼丹(Kaggle 120种狗分类,迁移学习加双模型融合)

    这是在kaggle上的一个练习比赛,使用的是ImageNet数据集的子集. 注意,mxnet版本要高于0.12.1b2017112. 下载数据集. train.zip test.zip labels ...

随机推荐

  1. python console

    print(sys.stdout.encoding, locale.getpreferredencoding ()) windows console : chcp 65001; 在设置了这个环境变量时 ...

  2. TuShare获取K线数据

    Tushare是一个免费.开源的python财经数据接口包.主要实现对股票等金融数据从数据采集.清洗加工 到 数据存储的过程,能够为金融分析人员提供快速.整洁.和多样的便于分析的数据,为他们在数据获取 ...

  3. 转载(web app变革之rem)

    rem这是个低调的css单位,近一两年开始崭露头角,有许多同学对rem的评价不一,有的在尝试使用,有的在使用过程中遇到坑就弃用了.但是我对rem综合评价是用来做web app它绝对是最合适的人选之一. ...

  4. JUnit4.12 源码分析之Statement

    1. Statement 抽象类Statement作为命令模式的Command,只有一个方法 各种Runner作为命令模式中的Invoker,将发出各种Statement,来表示它们运行JUnit测试 ...

  5. golang zlib 压缩,解压缩

    package main import ( "bytes" "compress/zlib" "fmt" "io" &qu ...

  6. JavaWeb—Base64编码(转载)

    基本概念 Base64这个术语最初是在“MIME内容传输编码规范”中提出的.Base64不是一种加密算法,虽然编码后的字符串看起来有点加密的赶脚.它实际上是一种“二进制到文本”的编码方法,它能够将给定 ...

  7. module_init module_exit

    像你写C程序需要包含C库的头文件那样,Linux内核编程也需要包含Kernel头文件,大多的Linux驱动程序需要包含下面三个头文件:#include <linux/init.h>#inc ...

  8. 模块讲解----json模块(跨平台的序列化与反序列化)

    一.json的特点 1.只能处理简单的可序列化的对象:(字典,列表,元祖) 2.json支持不同语言之间的数据交互:(python  -  go,python - java)   二.使用场景 1.玩 ...

  9. [golang note] 类型系统

    值和引用 • 值语义和引用语义 值语义和引用语义的差别在于赋值: b = a b.Modify() 如果b的修改不会影响a的值,那么属于值类型,否则属于引用类型. • 值类型和引用类型 √ 引用类型一 ...

  10. import MySQLdb 与 import mysql 有什么区别?

    MySQLdb 只支持Python 2.* ,暂时还不支持3.* 可以用PyMySQL 代替,把__init__.py 中添加俩行: import pymysql pymysql.install_as ...