Spaces:
Runtime error
Runtime error
persistant storage test
Browse files161 unmodified lines162163164161 unmodified linesmax_threads=1,show_api=False,)161 unmodified lines162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194161 unmodified linesmax_threads=1,show_api=False,)import shutildef save_to_persistent(uploaded_file):os.makedirs("/data/weights", exist_ok=True)dest = os.path.join("/data/weights", uploaded_file.orig_name)shutil.copy2(uploaded_file.name, dest)return f"✅ Saved {uploaded_file.orig_name} to /data/weights"with gr.Blocks(title="Upload to Persistent Storage") as demo:gr.Markdown("### Upload model weights to `/data/weights` (persistent)")f = gr.File(label="Select .pth file", file_types=[".pth"])out = gr.Textbox()f.upload(save_to_persistent, f, out)if __name__ == "__main__":demo.launch(server_name="0.0.0.0", server_port=int(os.getenv("PORT", 7860)))print("📦 Contents of /data:")for root, dirs, files in os.walk("/data"):level = root.replace("/data", "").count(os.sep)indent = " " * levelprint(f"{indent}{os.path.basename(root)}/")for f in files:print(f"{indent} {f}")
app.py+30