66import cv2
77from easydict import EasyDict as edict
88from models .experimental import attempt_download
9- from utils .ymir_yolov5 import YmirYolov5 , convert_ymir_to_yolov5 , get_weight_file
9+ from ymir .ymir_yolov5 import YmirYolov5 , convert_ymir_to_yolov5 , get_weight_file
1010from ymir_exc import dataset_reader as dr
1111from ymir_exc import env , monitor
1212from ymir_exc import result_writer as rw
@@ -124,10 +124,10 @@ def _run_mining(cfg: edict, task_idx: int = 0, task_num: int = 1) -> None:
124124 raise Exception (f'unknown mining algorithm { mining_algorithm } , not in { support_mining_algorithms } ' )
125125
126126 if gpu_count <= 1 :
127- command = f'python3 mining/ymir_mining_{ mining_algorithm } .py'
127+ command = f'python3 ymir/ mining/ymir_mining_{ mining_algorithm } .py'
128128 else :
129129 port = find_free_port ()
130- command = f'python3 -m torch.distributed.launch --nproc_per_node { gpu_count } --master_port { port } mining/ymir_mining_{ mining_algorithm } .py' # noqa
130+ command = f'python3 -m torch.distributed.launch --nproc_per_node { gpu_count } --master_port { port } ymir/ mining/ymir_mining_{ mining_algorithm } .py' # noqa
131131
132132 logging .info (f'mining: { command } ' )
133133 subprocess .run (command .split (), check = True )
@@ -147,29 +147,13 @@ def _run_infer(cfg: edict, task_idx: int = 0, task_num: int = 1) -> None:
147147 gpu_count : int = len (gpu_id .split (',' )) if gpu_id else 0
148148
149149 if gpu_count <= 1 :
150- N = dr .items_count (env .DatasetType .CANDIDATE )
151- infer_result = dict ()
152- model = YmirYolov5 (cfg )
153- idx = - 1
154-
155- monitor_gap = max (1 , N // 100 )
156- for asset_path , _ in dr .item_paths (dataset_type = env .DatasetType .CANDIDATE ):
157- img = cv2 .imread (asset_path )
158- result = model .infer (img )
159- infer_result [asset_path ] = result
160- idx += 1
161-
162- if idx % monitor_gap == 0 :
163- percent = get_ymir_process (stage = YmirStage .TASK , p = idx / N , task_idx = task_idx , task_num = task_num )
164- monitor .write_monitor_logger (percent = percent )
165-
166- rw .write_infer_result (infer_result = infer_result )
150+ command = 'python3 ymir/mining/ymir_infer.py'
167151 else :
168152 port = find_free_port ()
169- command = f'python3 -m torch.distributed.launch --nproc_per_node { gpu_count } --master_port { port } mining/ymir_infer.py' # noqa
153+ command = f'python3 -m torch.distributed.launch --nproc_per_node { gpu_count } --master_port { port } ymir/ mining/ymir_infer.py' # noqa
170154
171- logging .info (f'infer: { command } ' )
172- subprocess .run (command .split (), check = True )
155+ logging .info (f'infer: { command } ' )
156+ subprocess .run (command .split (), check = True )
173157
174158 monitor .write_monitor_logger (
175159 percent = get_ymir_process (stage = YmirStage .POSTPROCESS , p = 1.0 , task_idx = task_idx , task_num = task_num ))
0 commit comments