Update app.py
Browse files
app.py
CHANGED
|
@@ -36,7 +36,7 @@ SESSION = {
|
|
| 36 |
|
| 37 |
|
| 38 |
def run_training(train_files, test_files, input_size, epochs, batch_size,
|
| 39 |
-
learning_rate, background_weight):
|
| 40 |
if not train_files or not test_files:
|
| 41 |
yield "Please select both a train folder and a test folder first.", None, None
|
| 42 |
return
|
|
@@ -93,7 +93,7 @@ def run_training(train_files, test_files, input_size, epochs, batch_size,
|
|
| 93 |
epoch_logs = []
|
| 94 |
history = fu.train_model(
|
| 95 |
model, train_ds, val_ds, int(epochs), float(learning_rate),
|
| 96 |
-
float(background_weight), epoch_logs,
|
| 97 |
)
|
| 98 |
log_lines.extend(epoch_logs)
|
| 99 |
yield "\n".join(log_lines), None, None
|
|
@@ -196,6 +196,9 @@ with gr.Blocks(title="Crow FOMO Trainer") as demo:
|
|
| 196 |
0.05, 1.0, value=0.3, step=0.05,
|
| 197 |
label="Background loss weight (lower = focus more on crows, helps with class imbalance)",
|
| 198 |
)
|
|
|
|
|
|
|
|
|
|
| 199 |
train_btn = gr.Button("Start Training", variant="primary")
|
| 200 |
train_log = gr.Textbox(label="Training log", lines=15)
|
| 201 |
loss_plot = gr.Image(label="Loss curve")
|
|
@@ -203,7 +206,7 @@ with gr.Blocks(title="Crow FOMO Trainer") as demo:
|
|
| 203 |
|
| 204 |
train_btn.click(
|
| 205 |
run_training,
|
| 206 |
-
inputs=[train_files, test_files, input_size, epochs, batch_size, learning_rate, background_weight],
|
| 207 |
outputs=[train_log, loss_plot, tflite_out],
|
| 208 |
)
|
| 209 |
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
def run_training(train_files, test_files, input_size, epochs, batch_size,
|
| 39 |
+
learning_rate, background_weight, optimizer_name):
|
| 40 |
if not train_files or not test_files:
|
| 41 |
yield "Please select both a train folder and a test folder first.", None, None
|
| 42 |
return
|
|
|
|
| 93 |
epoch_logs = []
|
| 94 |
history = fu.train_model(
|
| 95 |
model, train_ds, val_ds, int(epochs), float(learning_rate),
|
| 96 |
+
float(background_weight), epoch_logs, optimizer_name=optimizer_name,
|
| 97 |
)
|
| 98 |
log_lines.extend(epoch_logs)
|
| 99 |
yield "\n".join(log_lines), None, None
|
|
|
|
| 196 |
0.05, 1.0, value=0.3, step=0.05,
|
| 197 |
label="Background loss weight (lower = focus more on crows, helps with class imbalance)",
|
| 198 |
)
|
| 199 |
+
optimizer_name = gr.Dropdown(
|
| 200 |
+
["adamw", "adam", "sgd"], value="adamw", label="Optimizer",
|
| 201 |
+
)
|
| 202 |
train_btn = gr.Button("Start Training", variant="primary")
|
| 203 |
train_log = gr.Textbox(label="Training log", lines=15)
|
| 204 |
loss_plot = gr.Image(label="Loss curve")
|
|
|
|
| 206 |
|
| 207 |
train_btn.click(
|
| 208 |
run_training,
|
| 209 |
+
inputs=[train_files, test_files, input_size, epochs, batch_size, learning_rate, background_weight, optimizer_name],
|
| 210 |
outputs=[train_log, loss_plot, tflite_out],
|
| 211 |
)
|
| 212 |
|