Spaces:
Sleeping
Sleeping
Update app.py
Browse files39 unmodified lines404142434445464748495051525354555657585960616239 unmodified lines"--block_size", "256","--learning_rate", "5e-5",]# run training (blocking) and capture logswith open(LOG, "a", encoding="utf-8") as lf:code = subprocess.Popen(cmd, stdout=lf, stderr=subprocess.STDOUT).wait()# after process exits, show resultif code == 0 and ZIP.exists():info = f"✅ Training complete. Saved: {OUT.name} | Zip: {ZIP.name}"return info, gr.File.update(value=str(ZIP), visible=True), ls_workspace(), read_logs()else:info = f"❌ Training failed (exit {code}). See logs."return info, gr.File.update(visible=False), ls_workspace(), read_logs()def read_logs():return LOG.read_text(encoding="utf-8")[-20000:] if LOG.exists() else "⏳ Waiting…"def refresh_download():return gr.File.update(value=str(ZIP), visible=ZIP.exists()), ls_workspace()# ---------------- Test tab ----------------def list_models():39 unmodified lines40414243444546474849505152535455565758596039 unmodified lines"--block_size", "256","--learning_rate", "5e-5",]with open(LOG, "a", encoding="utf-8") as lf:code = subprocess.Popen(cmd, stdout=lf, stderr=subprocess.STDOUT).wait()if code == 0 and ZIP.exists():info = f"✅ Training complete. Saved: {OUT.name} | Zip: {ZIP.name}"return info, gr.update(value=str(ZIP), visible=True), ls_workspace(), read_logs()else:info = f"❌ Training failed (exit {code}). See logs."return info, gr.update(visible=False), ls_workspace(), read_logs()def read_logs():return LOG.read_text(encoding="utf-8")[-20000:] if LOG.exists() else "⏳ Waiting…"def refresh_download():return gr.update(value=str(ZIP), visible=ZIP.exists()), ls_workspace()# ---------------- Test tab ----------------def list_models():
app.py+3-5