mirror of
https://github.com/ostris/ai-toolkit.git
synced 2026-05-01 03:31:35 +00:00
Built out the ui trainer plugin with db comminication
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"update_db": "npx prisma generate && npx prisma db push",
|
||||
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,css,scss}\""
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -13,12 +13,15 @@ model Settings {
|
||||
value String
|
||||
}
|
||||
|
||||
|
||||
model Training {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
gpu_id Int
|
||||
job_config String // JSON string
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
}
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
gpu_id Int
|
||||
job_config String // JSON string
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @updatedAt
|
||||
status String @default("stopped")
|
||||
stop Boolean @default(false)
|
||||
step Int @default(0)
|
||||
info String @default("")
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@ export const defaultJobConfig: JobConfig = {
|
||||
name: 'my_first_flex_lora_v1',
|
||||
process: [
|
||||
{
|
||||
type: 'sd_trainer',
|
||||
type: 'ui_trainer',
|
||||
training_folder: 'output',
|
||||
sqlite_db_path: './aitk_db.db',
|
||||
device: 'cuda:0',
|
||||
network: {
|
||||
type: 'lora',
|
||||
|
||||
@@ -51,10 +51,29 @@ export const NumberInput = (props: NumberInputProps) => {
|
||||
type="number"
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
let value = Number(e.target.value);
|
||||
if (isNaN(value)) value = 0;
|
||||
// Use parseFloat instead of Number to properly handle decimal values
|
||||
const rawValue = e.target.value;
|
||||
|
||||
// Special handling for empty or partial inputs
|
||||
if (rawValue === '' || rawValue === '-' || rawValue === '.') {
|
||||
// For empty or partial inputs (like just a minus sign or decimal point),
|
||||
// we need to maintain the raw input in the input field
|
||||
// but pass a valid number to onChange
|
||||
onChange(0);
|
||||
return;
|
||||
}
|
||||
|
||||
let value = parseFloat(rawValue);
|
||||
|
||||
// Handle NaN cases
|
||||
if (isNaN(value)) {
|
||||
value = 0;
|
||||
}
|
||||
|
||||
// Apply min/max constraints only for valid numbers
|
||||
if (min !== undefined && value < min) value = min;
|
||||
if (max !== undefined && value > max) value = max;
|
||||
|
||||
onChange(value);
|
||||
}}
|
||||
className={inputClasses}
|
||||
@@ -62,6 +81,8 @@ export const NumberInput = (props: NumberInputProps) => {
|
||||
required={required}
|
||||
min={min}
|
||||
max={max}
|
||||
// Allow decimal points
|
||||
step="any"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -121,7 +121,8 @@ export interface SampleConfig {
|
||||
}
|
||||
|
||||
export interface ProcessConfig {
|
||||
type: 'sd_trainer';
|
||||
type: 'ui_trainer';
|
||||
sqlite_db_path?: string;
|
||||
training_folder: string;
|
||||
device: string;
|
||||
network?: NetworkConfig;
|
||||
|
||||
Reference in New Issue
Block a user