first push
This commit is contained in:
36
backend/services/push_yolox_exp.py
Normal file
36
backend/services/push_yolox_exp.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from models.training import Training
|
||||
from models.TrainingProjectDetails import TrainingProjectDetails
|
||||
from database.database import db
|
||||
|
||||
def push_yolox_exp_to_db(settings):
|
||||
"""Save YOLOX settings to database"""
|
||||
normalized = dict(settings)
|
||||
|
||||
# Map 'act' from frontend to 'activation' for DB
|
||||
if 'act' in normalized:
|
||||
normalized['activation'] = normalized['act']
|
||||
del normalized['act']
|
||||
|
||||
# Convert 'on'/'off' to boolean for save_history_ckpt
|
||||
if isinstance(normalized.get('save_history_ckpt'), str):
|
||||
normalized['save_history_ckpt'] = normalized['save_history_ckpt'] == 'on'
|
||||
|
||||
# Convert comma-separated strings to arrays
|
||||
for key in ['input_size', 'test_size', 'mosaic_scale', 'mixup_scale']:
|
||||
if isinstance(normalized.get(key), str):
|
||||
arr = [float(v.strip()) for v in normalized[key].split(',')]
|
||||
normalized[key] = arr[0] if len(arr) == 1 else arr
|
||||
|
||||
# Find TrainingProjectDetails for this project
|
||||
details = TrainingProjectDetails.query.filter_by(project_id=normalized['project_id']).first()
|
||||
if not details:
|
||||
raise Exception(f'TrainingProjectDetails not found for project_id {normalized["project_id"]}')
|
||||
|
||||
normalized['project_details_id'] = details.id
|
||||
|
||||
# Create DB row
|
||||
training = Training(**normalized)
|
||||
db.session.add(training)
|
||||
db.session.commit()
|
||||
|
||||
return training
|
||||
Reference in New Issue
Block a user