training fix. add global settings
This commit is contained in:
@@ -1,40 +1,40 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
|
||||
const Annotation = sequelize.define('Annotation', {
|
||||
annotation_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
image_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
x: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
y: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
height: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
width: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
Label: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
tableName: 'annotation',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
module.exports = Annotation;
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
|
||||
const Annotation = sequelize.define('Annotation', {
|
||||
annotation_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
image_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
x: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
y: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
height: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
width: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
Label: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
tableName: 'annotation',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
module.exports = Annotation;
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
from database.database import db
|
||||
|
||||
class Annotation(db.Model):
|
||||
__tablename__ = 'annotation'
|
||||
|
||||
annotation_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
image_id = db.Column(db.Integer, nullable=False)
|
||||
x = db.Column(db.Float, nullable=False)
|
||||
y = db.Column(db.Float, nullable=False)
|
||||
height = db.Column(db.Float, nullable=False)
|
||||
width = db.Column(db.Float, nullable=False)
|
||||
Label = db.Column(db.String(255), nullable=False)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'annotation_id': self.annotation_id,
|
||||
'image_id': self.image_id,
|
||||
'x': self.x,
|
||||
'y': self.y,
|
||||
'height': self.height,
|
||||
'width': self.width,
|
||||
'Label': self.Label
|
||||
}
|
||||
from database.database import db
|
||||
|
||||
class Annotation(db.Model):
|
||||
__tablename__ = 'annotation'
|
||||
|
||||
annotation_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
image_id = db.Column(db.Integer, db.ForeignKey('image.image_id', ondelete='CASCADE'), nullable=False)
|
||||
x = db.Column(db.Float, nullable=False)
|
||||
y = db.Column(db.Float, nullable=False)
|
||||
height = db.Column(db.Float, nullable=False)
|
||||
width = db.Column(db.Float, nullable=False)
|
||||
Label = db.Column(db.String(255), nullable=False)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'annotation_id': self.annotation_id,
|
||||
'image_id': self.image_id,
|
||||
'x': self.x,
|
||||
'y': self.y,
|
||||
'height': self.height,
|
||||
'width': self.width,
|
||||
'Label': self.Label
|
||||
}
|
||||
|
||||
21
backend/models/AnnotationProjectMapping.py
Normal file
21
backend/models/AnnotationProjectMapping.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from database.database import db
|
||||
|
||||
class AnnotationProjectMapping(db.Model):
|
||||
"""Mapping between training project details and label studio projects (3NF)"""
|
||||
__tablename__ = 'annotation_project_mapping'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
project_details_id = db.Column(db.Integer, db.ForeignKey('training_project_details.id', ondelete='CASCADE'), nullable=False)
|
||||
label_studio_project_id = db.Column(db.Integer, db.ForeignKey('label_studio_project.project_id', ondelete='CASCADE'), nullable=False)
|
||||
|
||||
# Unique constraint: each label studio project can only be mapped once per training project details
|
||||
__table_args__ = (
|
||||
db.UniqueConstraint('project_details_id', 'label_studio_project_id', name='uq_annotation_mapping'),
|
||||
)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'project_details_id': self.project_details_id,
|
||||
'label_studio_project_id': self.label_studio_project_id
|
||||
}
|
||||
25
backend/models/ClassMapping.py
Normal file
25
backend/models/ClassMapping.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from database.database import db
|
||||
|
||||
class ClassMapping(db.Model):
|
||||
"""Class name mappings for training project details (3NF)"""
|
||||
__tablename__ = 'class_mapping'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
project_details_id = db.Column(db.Integer, db.ForeignKey('training_project_details.id', ondelete='CASCADE'), nullable=False)
|
||||
label_studio_project_id = db.Column(db.Integer, db.ForeignKey('label_studio_project.project_id', ondelete='CASCADE'), nullable=False)
|
||||
source_class = db.Column(db.String(255), nullable=False)
|
||||
target_class = db.Column(db.String(255), nullable=False)
|
||||
|
||||
# Unique constraint: each source class can only be mapped once per project details AND label studio project
|
||||
__table_args__ = (
|
||||
db.UniqueConstraint('project_details_id', 'label_studio_project_id', 'source_class', name='uq_class_mapping'),
|
||||
)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'project_details_id': self.project_details_id,
|
||||
'label_studio_project_id': self.label_studio_project_id,
|
||||
'source_class': self.source_class,
|
||||
'target_class': self.target_class
|
||||
}
|
||||
@@ -1,35 +1,35 @@
|
||||
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
const Image = sequelize.define('Image', {
|
||||
image_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
image_path: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
project_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
width: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: true,
|
||||
},
|
||||
height: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: true,
|
||||
},
|
||||
|
||||
}, {
|
||||
tableName: 'image',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
module.exports = Image;
|
||||
|
||||
|
||||
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
const Image = sequelize.define('Image', {
|
||||
image_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
image_path: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
project_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
width: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: true,
|
||||
},
|
||||
height: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: true,
|
||||
},
|
||||
|
||||
}, {
|
||||
tableName: 'image',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
module.exports = Image;
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
from database.database import db
|
||||
|
||||
class Image(db.Model):
|
||||
__tablename__ = 'image'
|
||||
|
||||
image_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
image_path = db.Column(db.String(500), nullable=False)
|
||||
project_id = db.Column(db.Integer, nullable=False)
|
||||
width = db.Column(db.Float)
|
||||
height = db.Column(db.Float)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'image_id': self.image_id,
|
||||
'image_path': self.image_path,
|
||||
'project_id': self.project_id,
|
||||
'width': self.width,
|
||||
'height': self.height
|
||||
}
|
||||
from database.database import db
|
||||
|
||||
class Image(db.Model):
|
||||
__tablename__ = 'image'
|
||||
|
||||
image_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
image_path = db.Column(db.String(500), nullable=False)
|
||||
project_id = db.Column(db.Integer, db.ForeignKey('label_studio_project.project_id', ondelete='CASCADE'), nullable=False)
|
||||
width = db.Column(db.Integer)
|
||||
height = db.Column(db.Integer)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'image_id': self.image_id,
|
||||
'image_path': self.image_path,
|
||||
'project_id': self.project_id,
|
||||
'width': self.width,
|
||||
'height': self.height
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
const Label_studio_project = sequelize.define('LabelStudioProject', {
|
||||
project_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
unique: true,
|
||||
allowNull: false,
|
||||
},
|
||||
title:{
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
}
|
||||
|
||||
}, {
|
||||
tableName: 'label_studio_project',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
module.exports = Label_studio_project;
|
||||
|
||||
|
||||
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
const Label_studio_project = sequelize.define('LabelStudioProject', {
|
||||
project_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
unique: true,
|
||||
allowNull: false,
|
||||
},
|
||||
title:{
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
}
|
||||
|
||||
}, {
|
||||
tableName: 'label_studio_project',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
module.exports = Label_studio_project;
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from database.database import db
|
||||
|
||||
class LabelStudioProject(db.Model):
|
||||
__tablename__ = 'label_studio_project'
|
||||
|
||||
project_id = db.Column(db.Integer, primary_key=True, unique=True)
|
||||
title = db.Column(db.String(255), nullable=False)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'project_id': self.project_id,
|
||||
'title': self.title
|
||||
}
|
||||
from database.database import db
|
||||
|
||||
class LabelStudioProject(db.Model):
|
||||
__tablename__ = 'label_studio_project'
|
||||
|
||||
project_id = db.Column(db.Integer, primary_key=True, unique=True)
|
||||
title = db.Column(db.String(255), nullable=False)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'project_id': self.project_id,
|
||||
'title': self.title
|
||||
}
|
||||
|
||||
23
backend/models/ProjectClass.py
Normal file
23
backend/models/ProjectClass.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from database.database import db
|
||||
|
||||
class ProjectClass(db.Model):
|
||||
"""Class definitions for training projects (3NF)"""
|
||||
__tablename__ = 'project_class'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
project_id = db.Column(db.Integer, db.ForeignKey('training_project.project_id', ondelete='CASCADE'), nullable=False)
|
||||
class_name = db.Column(db.String(255), nullable=False)
|
||||
display_order = db.Column(db.Integer, default=0)
|
||||
|
||||
# Unique constraint: one class name per project
|
||||
__table_args__ = (
|
||||
db.UniqueConstraint('project_id', 'class_name', name='uq_project_class'),
|
||||
)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'project_id': self.project_id,
|
||||
'class_name': self.class_name,
|
||||
'display_order': self.display_order
|
||||
}
|
||||
21
backend/models/Settings.py
Normal file
21
backend/models/Settings.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from database.database import db
|
||||
|
||||
class Settings(db.Model):
|
||||
__tablename__ = 'settings'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
key = db.Column(db.String(255), unique=True, nullable=False)
|
||||
value = db.Column(db.Text, nullable=True)
|
||||
description = db.Column(db.String(500), nullable=True)
|
||||
created_at = db.Column(db.DateTime, server_default=db.func.now())
|
||||
updated_at = db.Column(db.DateTime, server_default=db.func.now(), onupdate=db.func.now())
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'key': self.key,
|
||||
'value': self.value,
|
||||
'description': self.description,
|
||||
'created_at': self.created_at.isoformat() if self.created_at else None,
|
||||
'updated_at': self.updated_at.isoformat() if self.updated_at else None
|
||||
}
|
||||
@@ -1,38 +1,38 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
const Training_Project = sequelize.define('LabelStudioProject', {
|
||||
project_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
unique: true,
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
},
|
||||
title:{
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
classes: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: false,
|
||||
},
|
||||
project_image: {
|
||||
type: DataTypes.BLOB,
|
||||
},
|
||||
project_image_type: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
}
|
||||
|
||||
}, {
|
||||
tableName: 'training_project',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
module.exports = Training_Project;
|
||||
|
||||
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
const Training_Project = sequelize.define('LabelStudioProject', {
|
||||
project_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
unique: true,
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
},
|
||||
title:{
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
classes: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: false,
|
||||
},
|
||||
project_image: {
|
||||
type: DataTypes.BLOB,
|
||||
},
|
||||
project_image_type: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
}
|
||||
|
||||
}, {
|
||||
tableName: 'training_project',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
module.exports = Training_Project;
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +1,36 @@
|
||||
from database.database import db
|
||||
|
||||
class TrainingProject(db.Model):
|
||||
__tablename__ = 'training_project'
|
||||
|
||||
project_id = db.Column(db.Integer, primary_key=True, unique=True, autoincrement=True)
|
||||
title = db.Column(db.String(255), nullable=False)
|
||||
description = db.Column(db.String(500))
|
||||
classes = db.Column(db.JSON, nullable=False)
|
||||
project_image = db.Column(db.LargeBinary)
|
||||
project_image_type = db.Column(db.String(100))
|
||||
|
||||
def to_dict(self):
|
||||
result = {
|
||||
'project_id': self.project_id,
|
||||
'title': self.title,
|
||||
'description': self.description,
|
||||
'classes': self.classes,
|
||||
'project_image_type': self.project_image_type
|
||||
}
|
||||
if self.project_image:
|
||||
import base64
|
||||
base64_data = base64.b64encode(self.project_image).decode('utf-8')
|
||||
mime_type = self.project_image_type or 'image/png'
|
||||
result['project_image'] = f'data:{mime_type};base64,{base64_data}'
|
||||
else:
|
||||
result['project_image'] = None
|
||||
return result
|
||||
from database.database import db
|
||||
|
||||
class TrainingProject(db.Model):
|
||||
__tablename__ = 'training_project'
|
||||
|
||||
project_id = db.Column(db.Integer, primary_key=True, unique=True, autoincrement=True)
|
||||
title = db.Column(db.String(255), nullable=False)
|
||||
description = db.Column(db.String(500))
|
||||
project_image = db.Column(db.LargeBinary)
|
||||
project_image_type = db.Column(db.String(100))
|
||||
|
||||
# Relationship to classes (3NF)
|
||||
classes_relation = db.relationship('ProjectClass', backref='project', lazy=True, cascade='all, delete-orphan')
|
||||
|
||||
def to_dict(self, include_classes=True):
|
||||
result = {
|
||||
'project_id': self.project_id,
|
||||
'title': self.title,
|
||||
'description': self.description,
|
||||
'project_image_type': self.project_image_type
|
||||
}
|
||||
|
||||
# Include classes as array for backwards compatibility
|
||||
if include_classes:
|
||||
from models.ProjectClass import ProjectClass
|
||||
classes = ProjectClass.query.filter_by(project_id=self.project_id).order_by(ProjectClass.display_order).all()
|
||||
result['classes'] = [c.class_name for c in classes]
|
||||
|
||||
if self.project_image:
|
||||
import base64
|
||||
base64_data = base64.b64encode(self.project_image).decode('utf-8')
|
||||
mime_type = self.project_image_type or 'image/png'
|
||||
result['project_image'] = f'data:{mime_type};base64,{base64_data}'
|
||||
else:
|
||||
result['project_image'] = None
|
||||
return result
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
const TrainingProjectDetails = sequelize.define('TrainingProjectDetails', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
unique: true,
|
||||
},
|
||||
project_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
annotation_projects: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: false,
|
||||
},
|
||||
class_map: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
}
|
||||
}, {
|
||||
tableName: 'training_project_details',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
module.exports = TrainingProjectDetails;
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
const TrainingProjectDetails = sequelize.define('TrainingProjectDetails', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
unique: true,
|
||||
},
|
||||
project_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
annotation_projects: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: false,
|
||||
},
|
||||
class_map: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
}
|
||||
}, {
|
||||
tableName: 'training_project_details',
|
||||
timestamps: false,
|
||||
});
|
||||
|
||||
module.exports = TrainingProjectDetails;
|
||||
|
||||
@@ -1,19 +1,35 @@
|
||||
from database.database import db
|
||||
|
||||
class TrainingProjectDetails(db.Model):
|
||||
__tablename__ = 'training_project_details'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, unique=True, autoincrement=True)
|
||||
project_id = db.Column(db.Integer, nullable=False, unique=True)
|
||||
annotation_projects = db.Column(db.JSON, nullable=False)
|
||||
class_map = db.Column(db.JSON)
|
||||
description = db.Column(db.JSON)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'project_id': self.project_id,
|
||||
'annotation_projects': self.annotation_projects,
|
||||
'class_map': self.class_map,
|
||||
'description': self.description
|
||||
}
|
||||
from database.database import db
|
||||
|
||||
class TrainingProjectDetails(db.Model):
|
||||
__tablename__ = 'training_project_details'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, unique=True, autoincrement=True)
|
||||
project_id = db.Column(db.Integer, db.ForeignKey('training_project.project_id', ondelete='CASCADE'), nullable=False, unique=True)
|
||||
description_text = db.Column(db.Text) # Renamed from 'description' JSON to plain text
|
||||
|
||||
# Relationships (3NF)
|
||||
annotation_mappings = db.relationship('AnnotationProjectMapping', backref='project_details', lazy=True, cascade='all, delete-orphan')
|
||||
class_mappings = db.relationship('ClassMapping', backref='project_details', lazy=True, cascade='all, delete-orphan')
|
||||
|
||||
def to_dict(self, include_mappings=True):
|
||||
result = {
|
||||
'id': self.id,
|
||||
'project_id': self.project_id,
|
||||
'description': self.description_text
|
||||
}
|
||||
|
||||
# Include mappings for backwards compatibility
|
||||
if include_mappings:
|
||||
from models.AnnotationProjectMapping import AnnotationProjectMapping
|
||||
from models.ClassMapping import ClassMapping
|
||||
|
||||
# Get annotation projects as array
|
||||
mappings = AnnotationProjectMapping.query.filter_by(project_details_id=self.id).all()
|
||||
result['annotation_projects'] = [m.label_studio_project_id for m in mappings]
|
||||
|
||||
# Get class map as dictionary (grouped by label_studio_project_id for backwards compatibility)
|
||||
# Return format: {source: target} (flattened across all projects)
|
||||
class_maps = ClassMapping.query.filter_by(project_details_id=self.id).all()
|
||||
result['class_map'] = {cm.source_class: cm.target_class for cm in class_maps}
|
||||
|
||||
return result
|
||||
|
||||
25
backend/models/TrainingSize.py
Normal file
25
backend/models/TrainingSize.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from database.database import db
|
||||
|
||||
class TrainingSize(db.Model):
|
||||
"""Size configurations for training (3NF - replaces JSON arrays)"""
|
||||
__tablename__ = 'training_size'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
training_id = db.Column(db.Integer, db.ForeignKey('training.id', ondelete='CASCADE'), nullable=False)
|
||||
size_type = db.Column(db.String(50), nullable=False) # 'input_size', 'test_size', 'mosaic_scale', 'mixup_scale'
|
||||
value_order = db.Column(db.Integer, nullable=False, default=0) # Order in array (0=first, 1=second)
|
||||
value = db.Column(db.Float, nullable=False)
|
||||
|
||||
# Composite key ensures proper ordering
|
||||
__table_args__ = (
|
||||
db.UniqueConstraint('training_id', 'size_type', 'value_order', name='uq_training_size'),
|
||||
)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'training_id': self.training_id,
|
||||
'size_type': self.size_type,
|
||||
'value_order': self.value_order,
|
||||
'value': self.value
|
||||
}
|
||||
@@ -1,16 +1,26 @@
|
||||
# Import all models to ensure they are registered with SQLAlchemy
|
||||
from models.TrainingProject import TrainingProject
|
||||
from models.TrainingProjectDetails import TrainingProjectDetails
|
||||
from models.training import Training
|
||||
from models.LabelStudioProject import LabelStudioProject
|
||||
from models.Images import Image
|
||||
from models.Annotation import Annotation
|
||||
|
||||
__all__ = [
|
||||
'TrainingProject',
|
||||
'TrainingProjectDetails',
|
||||
'Training',
|
||||
'LabelStudioProject',
|
||||
'Image',
|
||||
'Annotation'
|
||||
]
|
||||
# Import all models to ensure they are registered with SQLAlchemy
|
||||
from models.TrainingProject import TrainingProject
|
||||
from models.TrainingProjectDetails import TrainingProjectDetails
|
||||
from models.training import Training
|
||||
from models.LabelStudioProject import LabelStudioProject
|
||||
from models.Images import Image
|
||||
from models.Annotation import Annotation
|
||||
from models.Settings import Settings
|
||||
from models.ProjectClass import ProjectClass
|
||||
from models.AnnotationProjectMapping import AnnotationProjectMapping
|
||||
from models.ClassMapping import ClassMapping
|
||||
from models.TrainingSize import TrainingSize
|
||||
|
||||
__all__ = [
|
||||
'TrainingProject',
|
||||
'TrainingProjectDetails',
|
||||
'Training',
|
||||
'LabelStudioProject',
|
||||
'Image',
|
||||
'Annotation',
|
||||
'Settings',
|
||||
'ProjectClass',
|
||||
'AnnotationProjectMapping',
|
||||
'ClassMapping',
|
||||
'TrainingSize'
|
||||
]
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
const LabelStudioProject = require('./LabelStudioProject.js');
|
||||
const Annotation = require('./Annotation.js');
|
||||
const Image = require('./Images.js');
|
||||
const sequelize = require('../database/database.js');
|
||||
const TrainingProjectDetails = require('./TrainingProjectDetails.js');
|
||||
const TrainingProject = require('./TrainingProject.js');
|
||||
const Training = require('./training.js');
|
||||
|
||||
|
||||
|
||||
const Project = LabelStudioProject;
|
||||
const Img = Image;
|
||||
const Ann = Annotation;
|
||||
|
||||
// Associations
|
||||
Project.hasMany(Img, { foreignKey: 'project_id' });
|
||||
Img.belongsTo(Project, { foreignKey: 'project_id' });
|
||||
|
||||
Img.hasMany(Ann, { foreignKey: 'image_id' });
|
||||
Ann.belongsTo(Img, { foreignKey: 'image_id' });
|
||||
|
||||
// TrainingProjectDetails <-> TrainingProject
|
||||
TrainingProjectDetails.belongsTo(TrainingProject, { foreignKey: 'project_id' });
|
||||
TrainingProject.hasOne(TrainingProjectDetails, { foreignKey: 'project_id' });
|
||||
|
||||
// Training <-> TrainingProjectDetails
|
||||
Training.belongsTo(TrainingProjectDetails, { foreignKey: 'project_details_id' });
|
||||
TrainingProjectDetails.hasMany(Training, { foreignKey: 'project_details_id' });
|
||||
|
||||
module.exports = { Project, Img, Ann, TrainingProjectDetails, TrainingProject, Training };
|
||||
const LabelStudioProject = require('./LabelStudioProject.js');
|
||||
const Annotation = require('./Annotation.js');
|
||||
const Image = require('./Images.js');
|
||||
const sequelize = require('../database/database.js');
|
||||
const TrainingProjectDetails = require('./TrainingProjectDetails.js');
|
||||
const TrainingProject = require('./TrainingProject.js');
|
||||
const Training = require('./training.js');
|
||||
|
||||
|
||||
|
||||
const Project = LabelStudioProject;
|
||||
const Img = Image;
|
||||
const Ann = Annotation;
|
||||
|
||||
// Associations
|
||||
Project.hasMany(Img, { foreignKey: 'project_id' });
|
||||
Img.belongsTo(Project, { foreignKey: 'project_id' });
|
||||
|
||||
Img.hasMany(Ann, { foreignKey: 'image_id' });
|
||||
Ann.belongsTo(Img, { foreignKey: 'image_id' });
|
||||
|
||||
// TrainingProjectDetails <-> TrainingProject
|
||||
TrainingProjectDetails.belongsTo(TrainingProject, { foreignKey: 'project_id' });
|
||||
TrainingProject.hasOne(TrainingProjectDetails, { foreignKey: 'project_id' });
|
||||
|
||||
// Training <-> TrainingProjectDetails
|
||||
Training.belongsTo(TrainingProjectDetails, { foreignKey: 'project_details_id' });
|
||||
TrainingProjectDetails.hasMany(Training, { foreignKey: 'project_details_id' });
|
||||
|
||||
module.exports = { Project, Img, Ann, TrainingProjectDetails, TrainingProject, Training };
|
||||
|
||||
@@ -1,140 +1,140 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
const Training = sequelize.define('training', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
autoIncrement: true,
|
||||
unique: true,
|
||||
primaryKey: true
|
||||
},
|
||||
exp_name: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
max_epoch: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
depth: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
width: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
activation: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
warmup_epochs: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
warmup_lr: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
basic_lr_per_img: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
scheduler: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
no_aug_epochs: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
min_lr_ratio: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
ema: {
|
||||
type: DataTypes.BOOLEAN
|
||||
},
|
||||
weight_decay: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
momentum: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
input_size: {
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
print_interval: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
eval_interval: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
save_history_ckpt: {
|
||||
type: DataTypes.BOOLEAN
|
||||
},
|
||||
test_size: {
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
test_conf: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
nms_thre: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
multiscale_range: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
enable_mixup: {
|
||||
type: DataTypes.BOOLEAN
|
||||
},
|
||||
mosaic_prob: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
mixup_prob: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
hsv_prob: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
flip_prob: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
degrees: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
mosaic_scale: {
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
mixup_scale: {
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
translate: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
shear: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
training_name: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
project_details_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
},
|
||||
seed: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
train: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
valid: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
test: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
selected_model: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
transfer_learning: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
model_upload: {
|
||||
type: DataTypes.BLOB
|
||||
}
|
||||
}, {
|
||||
tableName: 'training',
|
||||
timestamps: false
|
||||
});
|
||||
|
||||
module.exports = Training;
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../database/database.js');
|
||||
|
||||
const Training = sequelize.define('training', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
autoIncrement: true,
|
||||
unique: true,
|
||||
primaryKey: true
|
||||
},
|
||||
exp_name: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
max_epoch: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
depth: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
width: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
activation: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
warmup_epochs: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
warmup_lr: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
basic_lr_per_img: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
scheduler: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
no_aug_epochs: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
min_lr_ratio: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
ema: {
|
||||
type: DataTypes.BOOLEAN
|
||||
},
|
||||
weight_decay: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
momentum: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
input_size: {
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
print_interval: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
eval_interval: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
save_history_ckpt: {
|
||||
type: DataTypes.BOOLEAN
|
||||
},
|
||||
test_size: {
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
test_conf: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
nms_thre: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
multiscale_range: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
enable_mixup: {
|
||||
type: DataTypes.BOOLEAN
|
||||
},
|
||||
mosaic_prob: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
mixup_prob: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
hsv_prob: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
flip_prob: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
degrees: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
mosaic_scale: {
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
mixup_scale: {
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
translate: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
shear: {
|
||||
type: DataTypes.FLOAT
|
||||
},
|
||||
training_name: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
project_details_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
},
|
||||
seed: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
train: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
valid: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
test: {
|
||||
type: DataTypes.INTEGER
|
||||
},
|
||||
selected_model: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
transfer_learning: {
|
||||
type: DataTypes.STRING(255)
|
||||
},
|
||||
model_upload: {
|
||||
type: DataTypes.BLOB
|
||||
}
|
||||
}, {
|
||||
tableName: 'training',
|
||||
timestamps: false
|
||||
});
|
||||
|
||||
module.exports = Training;
|
||||
|
||||
@@ -1,92 +1,109 @@
|
||||
from database.database import db
|
||||
|
||||
class Training(db.Model):
|
||||
__tablename__ = 'training'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True, unique=True)
|
||||
exp_name = db.Column(db.String(255))
|
||||
max_epoch = db.Column(db.Integer)
|
||||
depth = db.Column(db.Float)
|
||||
width = db.Column(db.Float)
|
||||
activation = db.Column(db.String(255))
|
||||
warmup_epochs = db.Column(db.Integer)
|
||||
warmup_lr = db.Column(db.Float)
|
||||
basic_lr_per_img = db.Column(db.Float)
|
||||
scheduler = db.Column(db.String(255))
|
||||
no_aug_epochs = db.Column(db.Integer)
|
||||
min_lr_ratio = db.Column(db.Float)
|
||||
ema = db.Column(db.Boolean)
|
||||
weight_decay = db.Column(db.Float)
|
||||
momentum = db.Column(db.Float)
|
||||
input_size = db.Column(db.JSON)
|
||||
print_interval = db.Column(db.Integer)
|
||||
eval_interval = db.Column(db.Integer)
|
||||
save_history_ckpt = db.Column(db.Boolean)
|
||||
test_size = db.Column(db.JSON)
|
||||
test_conf = db.Column(db.Float)
|
||||
nms_thre = db.Column(db.Float)
|
||||
multiscale_range = db.Column(db.Integer)
|
||||
enable_mixup = db.Column(db.Boolean)
|
||||
mosaic_prob = db.Column(db.Float)
|
||||
mixup_prob = db.Column(db.Float)
|
||||
hsv_prob = db.Column(db.Float)
|
||||
flip_prob = db.Column(db.Float)
|
||||
degrees = db.Column(db.Float)
|
||||
mosaic_scale = db.Column(db.JSON)
|
||||
mixup_scale = db.Column(db.JSON)
|
||||
translate = db.Column(db.Float)
|
||||
shear = db.Column(db.Float)
|
||||
training_name = db.Column(db.String(255))
|
||||
project_details_id = db.Column(db.Integer, nullable=False)
|
||||
seed = db.Column(db.Integer)
|
||||
train = db.Column(db.Integer)
|
||||
valid = db.Column(db.Integer)
|
||||
test = db.Column(db.Integer)
|
||||
selected_model = db.Column(db.String(255))
|
||||
transfer_learning = db.Column(db.String(255))
|
||||
model_upload = db.Column(db.LargeBinary)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'exp_name': self.exp_name,
|
||||
'max_epoch': self.max_epoch,
|
||||
'depth': self.depth,
|
||||
'width': self.width,
|
||||
'activation': self.activation,
|
||||
'warmup_epochs': self.warmup_epochs,
|
||||
'warmup_lr': self.warmup_lr,
|
||||
'basic_lr_per_img': self.basic_lr_per_img,
|
||||
'scheduler': self.scheduler,
|
||||
'no_aug_epochs': self.no_aug_epochs,
|
||||
'min_lr_ratio': self.min_lr_ratio,
|
||||
'ema': self.ema,
|
||||
'weight_decay': self.weight_decay,
|
||||
'momentum': self.momentum,
|
||||
'input_size': self.input_size,
|
||||
'print_interval': self.print_interval,
|
||||
'eval_interval': self.eval_interval,
|
||||
'save_history_ckpt': self.save_history_ckpt,
|
||||
'test_size': self.test_size,
|
||||
'test_conf': self.test_conf,
|
||||
'nms_thre': self.nms_thre,
|
||||
'multiscale_range': self.multiscale_range,
|
||||
'enable_mixup': self.enable_mixup,
|
||||
'mosaic_prob': self.mosaic_prob,
|
||||
'mixup_prob': self.mixup_prob,
|
||||
'hsv_prob': self.hsv_prob,
|
||||
'flip_prob': self.flip_prob,
|
||||
'degrees': self.degrees,
|
||||
'mosaic_scale': self.mosaic_scale,
|
||||
'mixup_scale': self.mixup_scale,
|
||||
'translate': self.translate,
|
||||
'shear': self.shear,
|
||||
'training_name': self.training_name,
|
||||
'project_details_id': self.project_details_id,
|
||||
'seed': self.seed,
|
||||
'train': self.train,
|
||||
'valid': self.valid,
|
||||
'test': self.test,
|
||||
'selected_model': self.selected_model,
|
||||
'transfer_learning': self.transfer_learning
|
||||
}
|
||||
from database.database import db
|
||||
|
||||
class Training(db.Model):
|
||||
__tablename__ = 'training'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True, unique=True)
|
||||
exp_name = db.Column(db.String(255))
|
||||
max_epoch = db.Column(db.Integer)
|
||||
depth = db.Column(db.Float)
|
||||
width = db.Column(db.Float)
|
||||
activation = db.Column(db.String(255))
|
||||
warmup_epochs = db.Column(db.Integer)
|
||||
warmup_lr = db.Column(db.Float)
|
||||
basic_lr_per_img = db.Column(db.Float)
|
||||
scheduler = db.Column(db.String(255))
|
||||
no_aug_epochs = db.Column(db.Integer)
|
||||
min_lr_ratio = db.Column(db.Float)
|
||||
ema = db.Column(db.Boolean)
|
||||
weight_decay = db.Column(db.Float)
|
||||
momentum = db.Column(db.Float)
|
||||
# input_size moved to TrainingSize table
|
||||
print_interval = db.Column(db.Integer)
|
||||
eval_interval = db.Column(db.Integer)
|
||||
save_history_ckpt = db.Column(db.Boolean)
|
||||
# test_size moved to TrainingSize table
|
||||
test_conf = db.Column(db.Float)
|
||||
nms_thre = db.Column(db.Float)
|
||||
multiscale_range = db.Column(db.Integer)
|
||||
enable_mixup = db.Column(db.Boolean)
|
||||
mosaic_prob = db.Column(db.Float)
|
||||
mixup_prob = db.Column(db.Float)
|
||||
hsv_prob = db.Column(db.Float)
|
||||
flip_prob = db.Column(db.Float)
|
||||
degrees = db.Column(db.Float)
|
||||
# mosaic_scale moved to TrainingSize table
|
||||
# mixup_scale moved to TrainingSize table
|
||||
translate = db.Column(db.Float)
|
||||
shear = db.Column(db.Float)
|
||||
training_name = db.Column(db.String(255))
|
||||
project_details_id = db.Column(db.Integer, db.ForeignKey('training_project_details.id', ondelete='CASCADE'), nullable=False)
|
||||
seed = db.Column(db.Integer)
|
||||
train = db.Column(db.Integer)
|
||||
valid = db.Column(db.Integer)
|
||||
test = db.Column(db.Integer)
|
||||
selected_model = db.Column(db.String(255))
|
||||
transfer_learning = db.Column(db.String(255))
|
||||
model_upload = db.Column(db.LargeBinary)
|
||||
|
||||
# Relationship to size configurations (3NF)
|
||||
size_configs = db.relationship('TrainingSize', backref='training', lazy=True, cascade='all, delete-orphan')
|
||||
|
||||
def to_dict(self, include_sizes=True):
|
||||
result = {
|
||||
'id': self.id,
|
||||
'exp_name': self.exp_name,
|
||||
'max_epoch': self.max_epoch,
|
||||
'depth': self.depth,
|
||||
'width': self.width,
|
||||
'activation': self.activation,
|
||||
'warmup_epochs': self.warmup_epochs,
|
||||
'warmup_lr': self.warmup_lr,
|
||||
'basic_lr_per_img': self.basic_lr_per_img,
|
||||
'scheduler': self.scheduler,
|
||||
'no_aug_epochs': self.no_aug_epochs,
|
||||
'min_lr_ratio': self.min_lr_ratio,
|
||||
'ema': self.ema,
|
||||
'weight_decay': self.weight_decay,
|
||||
'momentum': self.momentum,
|
||||
'print_interval': self.print_interval,
|
||||
'eval_interval': self.eval_interval,
|
||||
'save_history_ckpt': self.save_history_ckpt,
|
||||
'test_conf': self.test_conf,
|
||||
'nms_thre': self.nms_thre,
|
||||
'multiscale_range': self.multiscale_range,
|
||||
'enable_mixup': self.enable_mixup,
|
||||
'mosaic_prob': self.mosaic_prob,
|
||||
'mixup_prob': self.mixup_prob,
|
||||
'hsv_prob': self.hsv_prob,
|
||||
'flip_prob': self.flip_prob,
|
||||
'degrees': self.degrees,
|
||||
'translate': self.translate,
|
||||
'shear': self.shear,
|
||||
'training_name': self.training_name,
|
||||
'project_details_id': self.project_details_id,
|
||||
'seed': self.seed,
|
||||
'train': self.train,
|
||||
'valid': self.valid,
|
||||
'test': self.test,
|
||||
'selected_model': self.selected_model,
|
||||
'transfer_learning': self.transfer_learning
|
||||
}
|
||||
|
||||
# Include size arrays for backwards compatibility
|
||||
if include_sizes:
|
||||
from models.TrainingSize import TrainingSize
|
||||
|
||||
def get_size_array(size_type):
|
||||
sizes = TrainingSize.query.filter_by(
|
||||
training_id=self.id,
|
||||
size_type=size_type
|
||||
).order_by(TrainingSize.value_order).all()
|
||||
return [s.value for s in sizes] if sizes else None
|
||||
|
||||
result['input_size'] = get_size_array('input_size')
|
||||
result['test_size'] = get_size_array('test_size')
|
||||
result['mosaic_scale'] = get_size_array('mosaic_scale')
|
||||
result['mixup_scale'] = get_size_array('mixup_scale')
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user