Code Monkey home page Code Monkey logo

scene-baseline's Introduction

PyTorch Baseline for AI challenger scene

AI Challenger 场景分类竞赛的示例代码

使用

1.环境配置

安装:

  • PyTorch,根据官网说明下载指定的版本即可。
  • 第三方依赖: pip install -r requirements.txt

2.数据预处理:

这一步主要是根据json文件进行简单的处理,生成二进制scene.pth,可以跳过这一步,直接下载随程序附带的scene.pth

如果你想自己生成scene.pth,修改scripts/data_process.py 中的文件路径,然后运行

python scripts/data_process.py

3.启动visdom

可视化工具visdom

nohup python2 -m visdom.server&

4.训练

训练之前还需要新建checkpoints文件夹用来保存模型mkdir checkpoints。 注意修改utils.py 中文件路径

python main.py train --model='resnet34'

在 Titan Xp下,大概90分钟可以在验证集上得到大约0.938的准确率

python main.py train --model='resnet365'

使用place365的预训练模型resnet50, 可以在验证集达到0.957的top3分数,

打开浏览器 输入http://ip:8097 可以看到训练过程。visdom 中要用到两个js文件plotly.min.jsreact-grid-layout.min.js,这两个js文件被防火墙所拦截~ 所以你可能需要自备梯子才能用visdom。

另外一个解决方法是: locate locate visdom/static/index.html,修改index.html中两行js的地址

5.提交

python main.py submit --model='resnet34' --load-path='res34_1018_2204_0.938002232143' 

会在当前目录生成result.json文件,直接提交即可

关于CPU运行

把所有.cuda()代码去掉,就能使得程序在CPU上运行

各个文件说明

欢迎参考之前在知乎专栏写过的一篇关于PyTorch的文件组织安排的文章了解每个文件的作用

models/: 存放各个模型定义,所有的模型继承自basic_module.py中的BasicModule.

models/resnet.py: 对torchvision中的resnet18, resnet34, resnet50, resnet101 和resnet152 进行了简单的封装。

dataset.py: 数据加载相关

main.py: 主程序,包含训练和测试

utils.py: 可视化工具visdom的封装,计算top3准确率函数,可配置变量(可通过命令行参数修改,也可以通过修改文件配置)等。

scene-baseline's People

Contributors

chenyuntc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.