123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #!/bin/bash
- str=$1
- # str是外部传入的实参,如:sudo ./object_detection.sh/data2/fengyang/sunwin/data/image/项目名称/
- # <存放预处理图片的路径 ,只需定位到total_data的上一级目录就行>
- if [ ! -n "$str" ]; then # 利用 -n来判断字符串是否非空
- echo 'path 值为空'
- exit 0
- fi
- if [ ! -d $str ]; then # -d 文件为目录为真
- echo '$str 不存在,请检查路径是否存在...'
- exit 0
- fi
- # 注意:路径后面不要带'/'符号
- #train_model_path='/data2/fengyang/sunwin/train_model'
- #train_code_path='/data2/fengyang/sunwin/code/models-master/research/object_detection'
- data_path='/data2/object_detection/data/image' # 项目名称/存放total_data的路径
- data_manage_code_path='/data2/object_detection/code/data_manage' # 数据预处理data_manage的路径
- yolov5_code_path='/data2/object_detection/code/yolov5'
- if [[ $str == */ ]]; then project_path=${str%?};else project_path=$str;fi
- str_name=${project_path##*/} # ${变量名##删除字符串 正则表达式},作用:从字符串的结尾开始匹配 删除字符串
- project_class_img_path="${project_path}/class_img_dir"
- echo '333'
- sed -i "31c dir = $project_path" $data_manage_code_path/config/data_manage.conf # sed -i 直接对内容进行修改
- sed -n '30,31p' $data_manage_code_path/config/data_manage.conf # 取消默认输出,sed默认会输出所有文本内容,
- # 使用-n参数后只显示处理过的行,打印30到31行
- echo '111'
- cd $data_manage_code_path
- python run_gen.py
- echo '222'
- echo '等待三分钟...。如果不需要执行模型训练功能,请尽快关闭脚本并kill其进程'
- sleep 30s
- cd $yolov5_code_path
- python train.py --data /data2/object_detection/data/image/$str_name/yolo/$str_name.yaml --weights weights/yolov5l6.pt --img 1280 --epochs 70 --name $str_name --batch-size 4
|