config设置的两种方式

更新时间:2023-07-29 15:59:10 阅读: 评论:0

config设置的两种⽅式
1. easydict 模块来设置config
config.py  (双下划线会重写属性名称,会在该属性的前⾯加上_class__attribute,直接调⽤class.__attribute 会报错,以下代码的双下划线应该也是为了避免命名冲突吧!)
from easydict import EasyDict as edict
长春旅游攻略必去景点__C                            = edict()
# Consumers can get config by: from config import cfg
cfg                            = __C
# YOLO options
__C.YOLO                        = edict()
__C.YOLO.CLASSES                = "./data/class/coco.names"
__C.YOLO.ANCHORS                = "./data/anchors/"
__C.YOLO.MOVING_AVE_DECAY      = 0.9995
__C.YOLO.STRIDES                = [8, 16, 32]
__C.YOLO.ANCHOR_PER_SCALE      = 3
__C.YOLO.IOU_LOSS_THRESH        = 0.5
__C.YOLO.UPSAMPLE_METHOD        = "resize"
__C.YOLO.ORIGINAL_WEIGHT        = "./checkpoint/yolov3_coco.ckpt"
__C.YOLO.DEMO_WEIGHT            = "./checkpoint/yolov3_coco_demo.ckpt"
姐姐的英语怎么读# Train options
__C.TRAIN                      = edict()
__C.TRAIN.ANNOT_PATH            = "./data/datat/"
车后视镜怎么调整合适
__C.TRAIN.BATCH_SIZE            = 6
__C.TRAIN.INPUT_SIZE            = [320, 352, 384, 416, 448, 480, 512, 544, 576, 608]
__C.TRAIN.DATA_AUG              = True
__C.TRAIN.LEARN_RATE_INIT      = 1e-4
__C.TRAIN.LEARN_RATE_END        = 1e-6
__C.TRAIN.WARMUP_EPOCHS        = 2
__C.TRAIN.FISRT_STAGE_EPOCHS    = 20
__C.TRAIN.SECOND_STAGE_EPOCHS  = 30
__C.TRAIN.INITIAL_WEIGHT        = "./checkpoint/yolov3_coco_demo.ckpt"
# TEST options聂荣锋
__C.TEST                        = edict()
__C.TEST.ANNOT_PATH            = "./data/datat/"
__C.TEST.BATCH_SIZE            = 2
__C.TEST.INPUT_SIZE            = 544
__C.TEST.DATA_AUG              = Fal
__C.TEST.WRITE_IMAGE            = True
苏联斯大林__C.TEST.WRITE_IMAGE_PATH      = "./data/detection/"
__C.TEST.WRITE_IMAGE_SHOW_LABEL = True
__C.TEST.WEIGHT_FILE            = "./checkpoint/yolov3_test_loss=9.2099.ckpt-5"
__C.TEST.SHOW_LABEL            = True
__C.TEST.SCORE_THRESHOLD        = 0.3
__C.TEST.IOU_THRESHOLD          = 0.45
 train.py 
蒋介石传
from config import cfg
class YoloTrain(object):
def__init__(lf):
lf.anchor_per_scale    = cfg.YOLO.ANCHOR_PER_SCALE
lf.class            = ad_class_names(cfg.YOLO.CLASSES)
lf.num_class        = len(lf.class)
lf.learn_rate_init    = cfg.TRAIN.LEARN_RATE_INIT
lf.learn_rate_end      = cfg.TRAIN.LEARN_RATE_END
lf.first_stage_epochs  = cfg.TRAIN.FISRT_STAGE_EPOCHS
lf.warmup_periods      = cfg.TRAIN.WARMUP_EPOCHS
lf.initial_weight      = cfg.TRAIN.INITIAL_WEIGHT
lf.time                = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(time.time()))
2. 通过configobj 来设置config
config
[param]
# coco datat json file
datatFile= "D:\\coco\\person_keypoints_val2014.json"
new_datatFile="D:\\coco\\new_person_keypoints_val2014.json" new_val2014="D:\\coco\\new_val2014\\"
val2014="D:\\coco\\val2014\\"
image_height=552
blank=2
crop_ratio = 1
bbox_ratio = 1
num_keypoints=4
area=32*32
config_reader.py
from configobj import ConfigObj
def config_reader():
config = ConfigObj('config')
param = config['param']
datatFile = param['datatFile']
new_datatFile = param['new_datatFile']
外婆菜炒豆角area=param['area']
num_keypoints=param['num_keypoints']
new_val2014 = param['new_val2014']
val2014=param['val2014']
image_height=param['image_height']
blank=param['blank']
return param
if__name__ == "__main__":明日歌文嘉
config_reader()

本文发布于:2023-07-29 15:59:10,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1100997.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:属性   避免   旅游   攻略
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图