File size: 1,010 Bytes
0f290d2
8aa6d91
c0327b8
 
8aa6d91
c0327b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8aa6d91
c0327b8
 
 
 
 
 
 
0f290d2
8aa6d91
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr
import spaces
import subprocess
import os

# 1. Wrap the execution in a function tagged with @spaces.GPU
@spaces.GPU(duration=120)  # Requests maximum GPU execution time
def run_training():
    print("--- STARTING TRAINING RUN ---")
    try:
        # 2. This triggers your custom train.py script on the GPU backend
        result = subprocess.run(
            ["python", "train.py"], 
            capture_output=True, 
            text=True, 
            check=True
        )
        return f"Training Complete! Logs:\n\n{result.stdout}"
    except subprocess.CalledProcessError as e:
        return f"Training Failed! Error Logs:\n\n{e.stderr}"

# 3. Create a simple single-button interface to click and launch it
with gr.Blocks() as demo:
    gr.Markdown("# Luau AI Training Dashboard")
    train_btn = gr.Button("🚀 Start Fine-Tuning Script")
    output_logs = gr.Textbox(label="Console Outputs", lines=20)
    
    train_btn.click(fn=run_training, outputs=output_logs)

demo.launch()