Merge branch 'master' of https://gitea.star-rising.cn/xkrs_manan/RODY
This commit is contained in:
commit
60db36c854
@ -242,7 +242,7 @@ from app import file_tool
|
|||||||
|
|
||||||
|
|
||||||
# 启动训练
|
# 启动训练
|
||||||
#@start_train_algorithm()
|
@start_train_algorithm()
|
||||||
def train_R0DY(params_str, id):
|
def train_R0DY(params_str, id):
|
||||||
from app.yolov5.train_server import train_start
|
from app.yolov5.train_server import train_start
|
||||||
params = TrainParams()
|
params = TrainParams()
|
||||||
@ -261,60 +261,60 @@ def train_R0DY(params_str, id):
|
|||||||
|
|
||||||
# 启动验证程序
|
# 启动验证程序
|
||||||
|
|
||||||
# @start_test_algorithm()
|
@start_test_algorithm()
|
||||||
# def validate_RODY(params_str, id):
|
def validate_RODY(params_str, id):
|
||||||
# from app.yolov5.validate_server import validate_start
|
from app.yolov5.validate_server import validate_start
|
||||||
# params = TrainParams()
|
params = TrainParams()
|
||||||
# params.read_from_str(params_str)
|
params.read_from_str(params_str)
|
||||||
# weights = params.get('modPath').value # 验证模型绝对路径
|
weights = params.get('modPath').value # 验证模型绝对路径
|
||||||
|
(filename, extension) = os.path.splitext(weights) # 文件名与后缀名分开
|
||||||
|
img_size = int(filename.split('ROD')[1].split('_')[2]) # 获取图像参数
|
||||||
|
# v_num = int(filename.split('ROD')[1].split('_')[1]) #获取版本号
|
||||||
|
output = params.get('outputPath').value
|
||||||
|
batch_size = params.get('batch_size').default
|
||||||
|
device = params.get('device').value
|
||||||
|
|
||||||
|
validate_start(weights, img_size, batch_size, device, output, id)
|
||||||
|
|
||||||
|
|
||||||
|
@start_detect_algorithm()
|
||||||
|
def detect_RODY(params_str, id):
|
||||||
|
from app.yolov5.detect_server import detect_start
|
||||||
|
params = TrainParams()
|
||||||
|
params.read_from_str(params_str)
|
||||||
|
weights = params.get('modPath').value # 检测模型绝对路径
|
||||||
|
input = params.get('inputPath').value
|
||||||
|
outpath = params.get('outputPath').value
|
||||||
# (filename, extension) = os.path.splitext(weights) # 文件名与后缀名分开
|
# (filename, extension) = os.path.splitext(weights) # 文件名与后缀名分开
|
||||||
# img_size = int(filename.split('ROD')[1].split('_')[2]) #获取图像参数
|
# img_size = int(filename.split('ROD')[1].split('_')[2]) #获取图像参数
|
||||||
# # v_num = int(filename.split('ROD')[1].split('_')[1]) #获取版本号
|
# v_num = int(filename.split('ROD')[1].split('_')[1]) #获取版本号
|
||||||
# output = params.get('outputPath').value
|
|
||||||
# batch_size = params.get('batch_size').default
|
# batch_size = params.get('batch_size').default
|
||||||
# device = params.get('device').value
|
device = params.get('device').value
|
||||||
#
|
|
||||||
# validate_start(weights, img_size, batch_size, device, output, id)
|
detect_start(input, weights, outpath, device, id)
|
||||||
#
|
|
||||||
#
|
|
||||||
# @start_detect_algorithm()
|
|
||||||
# def detect_RODY(params_str, id):
|
|
||||||
# from app.yolov5.detect_server import detect_start
|
|
||||||
# params = TrainParams()
|
|
||||||
# params.read_from_str(params_str)
|
|
||||||
# weights = params.get('modPath').value # 检测模型绝对路径
|
|
||||||
# input = params.get('inputPath').value
|
|
||||||
# outpath = params.get('outputPath').value
|
|
||||||
# # (filename, extension) = os.path.splitext(weights) # 文件名与后缀名分开
|
|
||||||
# # img_size = int(filename.split('ROD')[1].split('_')[2]) #获取图像参数
|
|
||||||
# # v_num = int(filename.split('ROD')[1].split('_')[1]) #获取版本号
|
|
||||||
# # batch_size = params.get('batch_size').default
|
|
||||||
# device = params.get('device').value
|
|
||||||
#
|
|
||||||
# detect_start(input, weights, outpath, device, id)
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# @start_download_pt()
|
|
||||||
# def Export_model_RODY(params_str):
|
|
||||||
# from app.yolov5.export import Start_Model_Export
|
|
||||||
# import zipfile
|
|
||||||
# params = TrainParams()
|
|
||||||
# params.read_from_str(params_str)
|
|
||||||
# exp_inputPath = params.get('exp_inputPath').value # 模型路径
|
|
||||||
# exp_device = params.get('device').value
|
|
||||||
# modellist = Start_Model_Export(exp_inputPath, exp_device)
|
|
||||||
# exp_outputPath = exp_inputPath.replace('pt', 'zip') # 压缩文件
|
|
||||||
# zipf = zipfile.ZipFile(exp_outputPath, 'w')
|
|
||||||
# for file in modellist:
|
|
||||||
# zipf.write(file, arcname=Path(file).name) # 将torchscript和onnx模型压缩
|
|
||||||
#
|
|
||||||
# return exp_outputPath
|
|
||||||
# zipf.write(modellist[1], arcname=modellist[1])
|
|
||||||
# zip_inputpath = os.path.join(exp_outputPath, "inference_model")
|
|
||||||
# zip_outputPath = os.path.join(exp_outputPath, "inference_model.zip")
|
|
||||||
|
|
||||||
|
|
||||||
#@obtain_train_param()
|
@start_download_pt()
|
||||||
|
def Export_model_RODY(params_str):
|
||||||
|
from app.yolov5.export import Start_Model_Export
|
||||||
|
import zipfile
|
||||||
|
params = TrainParams()
|
||||||
|
params.read_from_str(params_str)
|
||||||
|
exp_inputPath = params.get('exp_inputPath').value # 模型路径
|
||||||
|
exp_device = params.get('device').value
|
||||||
|
modellist = Start_Model_Export(exp_inputPath, exp_device)
|
||||||
|
exp_outputPath = exp_inputPath.replace('pt', 'zip') # 压缩文件
|
||||||
|
zipf = zipfile.ZipFile(exp_outputPath, 'w')
|
||||||
|
for file in modellist:
|
||||||
|
zipf.write(file, arcname=Path(file).name) # 将torchscript和onnx模型压缩
|
||||||
|
|
||||||
|
return exp_outputPath
|
||||||
|
zipf.write(modellist[1], arcname=modellist[1])
|
||||||
|
zip_inputpath = os.path.join(exp_outputPath, "inference_model")
|
||||||
|
zip_outputPath = os.path.join(exp_outputPath, "inference_model.zip")
|
||||||
|
|
||||||
|
|
||||||
|
@obtain_train_param()
|
||||||
def returnTrainParams():
|
def returnTrainParams():
|
||||||
# nvmlInit()
|
# nvmlInit()
|
||||||
# gpuDeviceCount = nvmlDeviceGetCount() # 获取Nvidia GPU块数
|
# gpuDeviceCount = nvmlDeviceGetCount() # 获取Nvidia GPU块数
|
||||||
@ -347,63 +347,63 @@ def returnTrainParams():
|
|||||||
return params_str
|
return params_str
|
||||||
|
|
||||||
|
|
||||||
# @obtain_test_param()
|
@obtain_test_param()
|
||||||
# def returnValidateParams():
|
def returnValidateParams():
|
||||||
# # nvmlInit()
|
# nvmlInit()
|
||||||
# # gpuDeviceCount = nvmlDeviceGetCount() # 获取Nvidia GPU块数
|
# gpuDeviceCount = nvmlDeviceGetCount() # 获取Nvidia GPU块数
|
||||||
# # _kernel = [f"cuda:{a}" for a in range(gpuDeviceCount)]
|
# _kernel = [f"cuda:{a}" for a in range(gpuDeviceCount)]
|
||||||
# params_list = [
|
params_list = [
|
||||||
# {"index": 0, "name": "modPath", "value": "E:/alg_demo-master/alg_demo/app/yolov5/圆孔_123_RODY_1_640.pt",
|
{"index": 0, "name": "modPath", "value": "E:/alg_demo-master/alg_demo/app/yolov5/圆孔_123_RODY_1_640.pt",
|
||||||
# "description": '验证模型路径', "default": "./app/maskrcnn/saved_model/test.pt", "type": "S", 'show': False},
|
"description": '验证模型路径', "default": "./app/maskrcnn/saved_model/test.pt", "type": "S", 'show': False},
|
||||||
# {"index": 1, "name": "batch_size", "value": 1, "description": '批次图像数量', "default": 1, "type": "I",
|
{"index": 1, "name": "batch_size", "value": 1, "description": '批次图像数量', "default": 1, "type": "I",
|
||||||
# 'show': False},
|
'show': False},
|
||||||
# {"index": 2, "name": "img_size", "value": 640, "description": '训练图像大小', "default": 640, "type": "I",
|
{"index": 2, "name": "img_size", "value": 640, "description": '训练图像大小', "default": 640, "type": "I",
|
||||||
# 'show': False},
|
'show': False},
|
||||||
# {"index": 3, "name": "outputPath", "value": 'E:/aicheck/data_set/11442136178662604800/val_results/',
|
{"index": 3, "name": "outputPath", "value": 'E:/aicheck/data_set/11442136178662604800/val_results/',
|
||||||
# "description": '输出结果路径',
|
"description": '输出结果路径',
|
||||||
# "default": './app/maskrcnn/datasets/M006B_waibi/res', "type": "S", 'show': False},
|
"default": './app/maskrcnn/datasets/M006B_waibi/res', "type": "S", 'show': False},
|
||||||
# {"index": 4, "name": "device", "value": "0", "description": '训练核心', "default": "cuda", "type": "S",
|
{"index": 4, "name": "device", "value": "0", "description": '训练核心', "default": "cuda", "type": "S",
|
||||||
# "items": '', 'show': False} # _kernel
|
"items": '', 'show': False} # _kernel
|
||||||
# ]
|
]
|
||||||
# # {"index": 9, "name": "saveEpoch", "value": 2, "description": '保存模型轮次', "default": 2, "type": "I", 'show': True}]
|
# {"index": 9, "name": "saveEpoch", "value": 2, "description": '保存模型轮次', "default": 2, "type": "I", 'show': True}]
|
||||||
# params_str = json.dumps(params_list)
|
params_str = json.dumps(params_list)
|
||||||
# return params_str
|
return params_str
|
||||||
#
|
|
||||||
#
|
|
||||||
# @obtain_detect_param()
|
@obtain_detect_param()
|
||||||
# def returnDetectParams():
|
def returnDetectParams():
|
||||||
# # nvmlInit()
|
# nvmlInit()
|
||||||
# # gpuDeviceCount = nvmlDeviceGetCount() # 获取Nvidia GPU块数
|
# gpuDeviceCount = nvmlDeviceGetCount() # 获取Nvidia GPU块数
|
||||||
# # _kernel = [f"cuda:{a}" for a in range(gpuDeviceCount)]
|
# _kernel = [f"cuda:{a}" for a in range(gpuDeviceCount)]
|
||||||
# params_list = [
|
params_list = [
|
||||||
# {"index": 0, "name": "inputPath", "value": 'E:/aicheck/data_set/11442136178662604800/input/',
|
{"index": 0, "name": "inputPath", "value": 'E:/aicheck/data_set/11442136178662604800/input/',
|
||||||
# "description": '输入图像路径', "default": './app/maskrcnn/datasets/M006B_waibi/JPEGImages', "type": "S",
|
"description": '输入图像路径', "default": './app/maskrcnn/datasets/M006B_waibi/JPEGImages', "type": "S",
|
||||||
# 'show': False},
|
'show': False},
|
||||||
# {"index": 1, "name": "outputPath", "value": 'E:/aicheck/data_set/11442136178662604800/val_results/',
|
{"index": 1, "name": "outputPath", "value": 'E:/aicheck/data_set/11442136178662604800/val_results/',
|
||||||
# "description": '输出结果路径',
|
"description": '输出结果路径',
|
||||||
# "default": './app/maskrcnn/datasets/M006B_waibi/res', "type": "S", 'show': False},
|
"default": './app/maskrcnn/datasets/M006B_waibi/res', "type": "S", 'show': False},
|
||||||
# {"index": 0, "name": "modPath", "value": "E:/alg_demo-master/alg_demo/app/yolov5/圆孔_123_RODY_1_640.pt",
|
{"index": 0, "name": "modPath", "value": "E:/alg_demo-master/alg_demo/app/yolov5/圆孔_123_RODY_1_640.pt",
|
||||||
# "description": '模型路径', "default": "./app/maskrcnn/saved_model/test.pt", "type": "S", 'show': False},
|
"description": '模型路径', "default": "./app/maskrcnn/saved_model/test.pt", "type": "S", 'show': False},
|
||||||
# {"index": 3, "name": "device", "value": "0", "description": '推理核', "default": "cpu", "type": "S",
|
{"index": 3, "name": "device", "value": "0", "description": '推理核', "default": "cpu", "type": "S",
|
||||||
# 'show': False},
|
'show': False},
|
||||||
# ]
|
]
|
||||||
# # {"index": 9, "name": "saveEpoch", "value": 2, "description": '保存模型轮次', "default": 2, "type": "I", 'show': True}]
|
# {"index": 9, "name": "saveEpoch", "value": 2, "description": '保存模型轮次', "default": 2, "type": "I", 'show': True}]
|
||||||
# params_str = json.dumps(params_list)
|
params_str = json.dumps(params_list)
|
||||||
# return params_str
|
return params_str
|
||||||
#
|
|
||||||
#
|
|
||||||
# @obtain_download_pt_param()
|
@obtain_download_pt_param()
|
||||||
# def returnDownloadParams():
|
def returnDownloadParams():
|
||||||
# params_list = [
|
params_list = [
|
||||||
# {"index": 0, "name": "exp_inputPath", "value": 'E:/alg_demo-master/alg_demo/app/yolov5/圆孔_123_RODY_1_640.pt',
|
{"index": 0, "name": "exp_inputPath", "value": 'E:/alg_demo-master/alg_demo/app/yolov5/圆孔_123_RODY_1_640.pt',
|
||||||
# "description": '转化模型输入路径',
|
"description": '转化模型输入路径',
|
||||||
# "default": '/mnt/sdc/IntelligentizeAI/IntelligentizeAI/data_set/weights/new磁环检测test_183504733393264640_R-DDM_11.pt/',
|
"default": '/mnt/sdc/IntelligentizeAI/IntelligentizeAI/data_set/weights/new磁环检测test_183504733393264640_R-DDM_11.pt/',
|
||||||
# "type": "S", 'show': False},
|
"type": "S", 'show': False},
|
||||||
# {"index": 1, "name": "device", "value": 'gpu', "description": 'CPU或GPU', "default": 'gpu', "type": "S",
|
{"index": 1, "name": "device", "value": 'gpu', "description": 'CPU或GPU', "default": 'gpu', "type": "S",
|
||||||
# 'show': False}
|
'show': False}
|
||||||
# ]
|
]
|
||||||
# params_str = json.dumps(params_list)
|
params_str = json.dumps(params_list)
|
||||||
# return params_str
|
return params_str
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user