From 964a8024c05045e357d54689123b942f0aa507d7 Mon Sep 17 00:00:00 2001 From: Yunhao Meng Date: Thu, 2 Oct 2025 22:37:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96fed=5Frun=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E8=BF=9B=E5=BA=A6=E6=9D=A1=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fed_run.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fed_run.py b/fed_run.py index b41c4de..51b35ce 100644 --- a/fed_run.py +++ b/fed_run.py @@ -142,7 +142,8 @@ def fed_run(): # --- build clients --- model_name = cfg.get("model_name", "yolo_v11_n") clients = {} - for uid in users: + + for uid in tqdm(users, desc="Building clients", leave=True, unit="client"): c = FedYoloClient(name=uid, model_name=model_name, params=params) c.load_trainset(user_data[uid]["filename"]) clients[uid] = c @@ -176,11 +177,11 @@ def fed_run(): res_root = cfg.get("res_root", "results") os.makedirs(res_root, exist_ok=True) - for rnd in tqdm(range(num_round), desc="main federal loop round"): + for rnd in tqdm(range(num_round), desc="main federal loop round:"): t0 = time.time() # Local training (sequential over all users) - for uid in tqdm(users, desc=f"Round {rnd + 1} local training", leave=False): + for uid in tqdm(users, desc=f"Round {rnd + 1} local training: ", leave=False): client = clients[uid] # FedYoloClient instance client.update(global_state) # load global weights state_dict, n_data, loss_dict = client.train(args_cli) # local training @@ -213,10 +214,11 @@ def fed_run(): history["train_loss"].append(scalar_train_loss) history["round_time_sec"].append(time.time() - t0) - print( + tqdm.write( f"[round {rnd + 1:04d}] " f"loss={scalar_train_loss:.4f} mAP50-95={mAP:.4f} mAP50={mAP50:.4f} " f"P={precision:.4f} R={recall:.4f}" + f"\n" ) # Save running JSON (resumable logs)