que and training status
This commit is contained in:
@@ -73,7 +73,7 @@ def generate_yolox_json():
|
||||
|
||||
@api_bp.route('/start-yolox-training', methods=['POST'])
|
||||
def start_yolox_training():
|
||||
"""Generate JSONs, exp.py, and start YOLOX training"""
|
||||
"""Generate JSONs, exp.py, and add training to queue"""
|
||||
try:
|
||||
data = request.get_json()
|
||||
project_id = data.get('project_id')
|
||||
@@ -113,8 +113,8 @@ def start_yolox_training():
|
||||
print(f'Generating exp.py at {exp_file_path}...')
|
||||
save_yolox_exp(training_id, exp_file_path)
|
||||
|
||||
# Step 3: Start training
|
||||
print(f'Starting YOLOX training for training {training_id}...')
|
||||
# Step 3: Build training command
|
||||
print(f'Preparing training command for training {training_id}...')
|
||||
|
||||
# Get YOLOX configuration from settings
|
||||
yolox_main_dir = get_setting('yolox_path', '/home/kitraining/Yolox/YOLOX-main')
|
||||
@@ -162,11 +162,12 @@ def start_yolox_training():
|
||||
|
||||
print(f'Training command: {cmd}')
|
||||
|
||||
# Start training in background
|
||||
subprocess.Popen(cmd, shell=True, cwd=yolox_main_dir)
|
||||
# Step 4: Add to training queue
|
||||
from services.training_queue import training_queue
|
||||
training_queue.add_to_queue(training_id, cmd, yolox_main_dir)
|
||||
|
||||
return jsonify({
|
||||
'message': f'JSONs and exp.py generated, training started for training {training_id}',
|
||||
'message': f'Training {training_id} added to queue',
|
||||
'exp_path': exp_file_path
|
||||
})
|
||||
|
||||
@@ -176,6 +177,18 @@ def start_yolox_training():
|
||||
traceback.print_exc()
|
||||
return jsonify({'message': 'Failed to start training', 'error': str(err)}), 500
|
||||
|
||||
@api_bp.route('/training-status', methods=['GET'])
|
||||
def get_training_status():
|
||||
"""Get current training queue status"""
|
||||
try:
|
||||
from services.training_queue import training_queue
|
||||
status = training_queue.get_status()
|
||||
return jsonify(status)
|
||||
|
||||
except Exception as err:
|
||||
print(f'Error getting training status: {err}')
|
||||
return jsonify({'current': None, 'queue': []}), 500
|
||||
|
||||
@api_bp.route('/training-log', methods=['GET'])
|
||||
def training_log():
|
||||
"""Get YOLOX training log"""
|
||||
|
||||
Reference in New Issue
Block a user