Fetching metadata from the HF Docker repository...
-
Delete main.py
-
Create app.py
-
Update main.py
-
Update main.py
import gradio as gr
import os
import shutil
import subprocess
UPLOAD_DIR = "training_images"
OUTPUT_DIR = "lora_output"
def train_lora(images, learning_rate, num_epochs, rank):
if os.path.exists(UPLOAD_DIR):
shutil.rmtree(UPLOAD_DIR)
os.makedirs(UPLOAD_DIR, exist_ok=True)
if os.path.exists(OUTPUT_DIR):
shutil.rmtree(OUTPUT_DIR)
os.makedirs(OUTPUT_DIR, exist_ok=True)
for idx, img in enumerate(images):
img.save(os.path.join(UPLOAD_DIR, f"image_{idx}.png"))
cmd = [
"python", "train_lora.py",
"--images_dir", UPLOAD_DIR,
"--output_dir", OUTPUT_DIR,
"--learning_rate", str(learning_rate),
"--num_epochs", str(num_epochs),
"--rank", str(rank),
]
result = subprocess.run(cmd, capture_output=True, text=True)
output_file = os.path.join(OUTPUT_DIR, "lora.safetensors")
if os.path.exists(output_file):
return f"✅ Treinamento finalizado!\nModelo salvo em: {output_file}\n\nLogs:\n… -
Create train_lora.py
-
Create main.py
-
Create requirements.txt
-
initial commit