From 6a8a491d3a2e71e66f0601c2b7c386fcf771acf7 Mon Sep 17 00:00:00 2001 From: JIAKUNHAO Date: Fri, 18 Nov 2022 15:44:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=AD=E7=BB=83=E5=8D=A1=E4=BD=8Fdebug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/AlgorithmController.py | 13 +++++++------ app/yolov5/train_server.py | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/controller/AlgorithmController.py b/app/controller/AlgorithmController.py index 3067d6e..09751f4 100644 --- a/app/controller/AlgorithmController.py +++ b/app/controller/AlgorithmController.py @@ -297,6 +297,7 @@ def error_return(id: str, data): # 启动训练 @start_train_algorithm() def train_R0DY(params_str, id): + print(params_str) from app.yolov5.train_server import train_start params = TrainParams() params.read_from_str(params_str) @@ -308,12 +309,12 @@ def train_R0DY(params_str, id): epoches = params.get('epochnum').value batch_size = params.get('batch_size').value device = params.get('device').value - try: - train_start(weights, savemodel, epoches, img_size, batch_size, device, data_list, id) - print("train down!") - except Exception as e: - print(repr(e)) - error_return(id=id,data=repr(e)) + #try: + train_start(weights, savemodel, epoches, img_size, batch_size, device, data_list, id) + print("train down!") + # except Exception as e: + # print(repr(e)) + # error_return(id=id,data=repr(e)) # 启动验证程序 diff --git a/app/yolov5/train_server.py b/app/yolov5/train_server.py index 1b42781..ab1872d 100644 --- a/app/yolov5/train_server.py +++ b/app/yolov5/train_server.py @@ -93,6 +93,7 @@ def train(hyp, opt, device, data_list,id,callbacks): # hyp is path/to/hyp.yaml #将数据路径写到yaml文件中 #data_list = file_tool.get_file(proj_no=pro) # print(data_list) + print("get in train()") yaml_rewrite(file=opt.data, data_list=data_list) save_dir, epochs,batch_size, weights, single_cls, evolve, data, cfg, resume, noval, nosave, workers, freeze = \ @@ -209,6 +210,7 @@ def train(hyp, opt, device, data_list,id,callbacks): # hyp is path/to/hyp.yaml ema = ModelEMA(model) if RANK in {-1, 0} else None # Resume + print("Resume") best_fitness, start_epoch = 0.0, 0 if pretrained: if resume: @@ -226,6 +228,7 @@ def train(hyp, opt, device, data_list,id,callbacks): # hyp is path/to/hyp.yaml model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model).to(device) LOGGER.info('Using SyncBatchNorm()') + print("Trainloader") # Trainloader train_loader, dataset = create_dataloader(train_path, imgsz, @@ -283,6 +286,7 @@ def train(hyp, opt, device, data_list,id,callbacks): # hyp is path/to/hyp.yaml model.class_weights = labels_to_class_weights(dataset.labels, nc).to(device) * nc # attach class weights model.names = names + print("Start training") # Start training t0 = time.time() nb = len(train_loader) # number of batches