import torch import requests import sys import os # -------------------------------- # LOADING THE GRADIENTS # -------------------------------- """ Gradient contents (gradients/model{i}.pt): - "gradients": dict {parameter_name -> gradient tensor}, mirroring the model's named_parameters() - "family": "mlp", "cnn", or "vit" - "activation": "relu" | "tanh" | "sigmoid" | "gelu" - "feature_shape": (C, H, W) per-image input feature shape - "batch_size": 128 """ grad = torch.load(os.path.join("gradients", "model1.pt"), weights_only=False) print("gradient file keys:", list(grad)) print(" family:", grad["family"], "| activation:", grad["activation"], "| feature_shape:", grad["feature_shape"], "| batch_size:", grad["batch_size"]) print(" gradient tensors:") for name, g in grad["gradients"].items(): print(f" {name:14} {tuple(g.shape)}") # -------------------------------- # LOADING THE MODEL (white-box) # -------------------------------- """ Model contents (models/model{i}.pt): A plain state_dict {parameter_name -> weight tensor} Further information regarding the model can be found in the corresponding gradient file. """ state = torch.load(os.path.join("models", "model1.pt"), weights_only=False) print("\nmodel state_dict keys:", list(state)) for name, w in state.items(): print(f" {name:14} {tuple(w.shape)}") # -------------------------------- # SUBMISSION FORMAT # -------------------------------- """ The submission must be a .pt file that torch.load()s to a dict with EXACTLY the keys "model1" ... "model12". Each value is a tensor of your reconstructed images for that model: - shape: (128, 3, 64, 64) - dtype: float32 - pixel values in the [0, 1] range The 128 images do not have to be in any particular order: each is matched to the nearest ground-truth image (one-to-one, no reuse) and scored by SSIM. """ # Example submission: submission = { f"model{i}": torch.rand(128, 3, 64, 64, dtype=torch.float32) # values in [0, 1] for i in range(1, 12 + 1) } torch.save(submission, "example_submission.pt") # -------------------------------- # SUBMISSION PROCESS # -------------------------------- """ FL Audit Task — Participant Submission Guide ======================================================== You will upload a single **.pt** file that torch.load()s to a dictionary with keys **model1** through **model12**, each mapping to a tensor of 128 reconstructed images. The evaluator loads your file, runs shape/dtype/range checks, and then scores it against the private ground-truth images. Follow these rules carefully to avoid automatic rejection. 1) File format -------------- - **Extension:** `.pt` (a Torch-saved dictionary) - **Content:** must contain EXACTLY the keys `model1`, `model2`, ..., `model12` (no more, no fewer; note: no underscore). - **Max file size:** 300 MB (hard limit). Larger files are rejected. 2) Per-model tensor requirements -------------------------------- Each value `submission["model{i}"]` must be: - **Shape:** exactly `(128, 3, 64, 64)`. - **Dtype:** a floating-point tensor (it is cast to float32). - **Range:** all pixel values in `[0, 1]`. - **Finite:** no NaN or Inf values. 3) Scoring ---------- For each model your 128 images are matched one-to-one (no reuse) to that model's 128 private images via a Hungarian assignment that maximises the total SSIM (the matching is done per model, not across models). Your score is the mean matched-pair SSIM. During the hackathon the leaderboard shows your score on a fixed 30% subset of the images; the final ranking uses the held-out 70%. 4) Typical failure messages & what they mean -------------------------------------------- - "File extension must be .pt (a torch-saved dict of model1..model12)." → Wrong extension. - "Submission must be a dict with keys 'model1'..'model12', got a ..." → The file did not load to a dictionary. - "Missing key(s): [...]." / "Unexpected key(s): [...]." → Your keys are not exactly model1..model12. - "model{i}: images must have shape (128, 3, 64, 64), got (...)." → Shape mismatch (wrong count or resolution -- remember to upsample to 64x64). - "model{i}: images must be a float tensor (dtype ... given)." → Submit float images, not uint8/integers. - "model{i}: pixel values must be in [0, 1], got min ... max ..." → Rescale your images into [0, 1]. - "model{i}: images contain NaN or Inf values." → Clean up invalid values before submitting. - "File too large: limit 314572800 bytes." → Your file exceeds 300 MB. """ BASE_URL = "http://35.192.205.84" API_KEY = "YOUR_API_KEY_HERE" TASK_ID = "21-fl-audit" FILE_PATH = "example_submission.pt" SUBMIT = False # set True to actually upload FILE_PATH def die(msg): print(f"{msg}", file=sys.stderr) sys.exit(1) if not SUBMIT: print("SUBMIT is False -- set SUBMIT = True (and your API_KEY/FILE_PATH) to upload.") sys.exit(0) if not os.path.isfile(FILE_PATH): die(f"File not found: {FILE_PATH}") try: with open(FILE_PATH, "rb") as f: files = { "file": (os.path.basename(FILE_PATH), f, "application/octet-stream"), } resp = requests.post( f"{BASE_URL}/submit/{TASK_ID}", headers={"X-API-Key": API_KEY}, files=files, timeout=(10, 120), ) try: body = resp.json() except Exception: body = {"raw_text": resp.text} if resp.status_code == 413: die("Upload rejected: file too large (HTTP 413). Reduce size and try again.") resp.raise_for_status() submission_id = body.get("submission_id") print("Successfully submitted.") print("Server response:", body) if submission_id: print(f"Submission ID: {submission_id}") except requests.exceptions.RequestException as e: detail = getattr(e, "response", None) print(f"Submission error: {e}") if detail is not None: try: print("Server response:", detail.json()) except Exception: print("Server response (text):", detail.text) sys.exit(1)