Skip to content

Commit

Permalink
[new feature] visdom_open.py
Browse files Browse the repository at this point in the history
  • Loading branch information
WangGodder committed May 11, 2021
1 parent 3aef7bb commit f92e7a5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ Before you start trainer, please use command as follows to open visdom server.
```shell script
python -m visdom.server
```
Or you can run script/visdom_open.py
```shell
python script/visdom_open.py
```
Then you can see the charts in browser in special port.

----
Expand All @@ -74,6 +78,18 @@ Then you can see the charts in browser in special port.
- inherit implement TrainBase
- change config.yml file and run.

#### A easy way to create your method
run script create_algorithm.py as following:
```shell
python create_algorithm.py ${method_name}
```
You can assign the method name by command or in create_algorithm.py

After running create_algorithm.py, you should get a new python file with your method name in "torchcmh/training/".
And you should also get a directory with your method name in "torchcmh/models".

Finish your algorithm and run it.

#### some function in TrainBase
- loss variable \
In your method, some variables you need to store and check, such as loss and acc.
Expand Down
9 changes: 7 additions & 2 deletions UpdateLog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@


## 2021.5.11
### version : 0.3.1
### new features:
- 根据模板生成算法所需的算法和模型文件
- 将vidsom的配置和启动加载到run命令中,不需要单独使用命令启动
### fixed bug:
- 添加visdom启动脚本
- 更新README介绍
### fix bug:
- 部分算法代码的缩进问题
- plotter.py 创建Visdom对象时默认端口8097,并在调用接口添加该参数

6 changes: 3 additions & 3 deletions script/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ datasetPath:
Mirflickr25k:
img_dir: I:\dataset\mirflickr25k\mirflickr
NUS WIDE:
img_dir:
img_dir: I:\dataset\nuswide\
COCO2014:
img_dir:
img_dir: I:\dataset\coco2014\
IAPR TC-12:
img_dir:
img_dir: I:\dataset\iaprtc-12\

dataPreprocess:
img:
Expand Down
12 changes: 12 additions & 0 deletions script/visdom_open.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# coding: utf-8
# author: Godder
# Date: 2021/5/11
# Github: https://github.com/WangGodder
import os
import sys

if __name__ == '__main__':
port = 8097
if len(sys.argv) > 1:
port = int(sys.argv[1])
result = os.system("python -m visdom.server -port %i" % port)
5 changes: 3 additions & 2 deletions torchcmh/utils/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class VisdomLinePlotter(object):
"""Plots to Visdom"""
def __init__(self, env_name='plotter'):
self.viz = Visdom()
def __init__(self, env_name='plotter', port=8097):
self.viz = Visdom(port=port)
self.env = env_name
self.plots = {}
self.epoch = 0
Expand All @@ -33,6 +33,7 @@ def next_epoch(self):
def reset_epoch(self):
self.epoch = 0


def get_plotter(env_name: str):
return VisdomLinePlotter(env_name)

0 comments on commit f92e7a5

Please sign in to comment.