Download reports/render_figures.py from Kiriti-Ray/luma-restore: direct link, hf CLI and curl.
- Browser
- Download file 3.5 kB
-
https://huggingface.co/Kiriti-Ray/luma-restore/resolve/main/reports/render_figures.py
- Command line
-
hf download hf://Kiriti-Ray/luma-restore/reports/render_figures.py
-
curl -L -o render_figures.py https://huggingface.co/Kiriti-Ray/luma-restore/resolve/main/reports/render_figures.py
3.5 kB
| """Render the quality–compute report from the recorded benchmark.""" | |
| import json | |
| from pathlib import Path | |
| import matplotlib | |
| matplotlib.use("Agg") | |
| import matplotlib.pyplot as plt | |
| ROOT = Path(__file__).resolve().parent | |
| BACKGROUND = "#f6f8fc" | |
| INK = "#18263a" | |
| plt.rcParams.update({ | |
| "figure.facecolor": BACKGROUND, | |
| "axes.facecolor": BACKGROUND, | |
| "text.color": INK, | |
| "axes.labelcolor": INK, | |
| "xtick.color": INK, | |
| "ytick.color": INK, | |
| "font.family": "DejaVu Sans", | |
| }) | |
| def format_axis(axis, title, xlabel): | |
| for edge in ("top", "right"): | |
| axis.spines[edge].set_visible(False) | |
| for edge in ("bottom", "left"): | |
| axis.spines[edge].set_color("#bdcadb") | |
| axis.set_axisbelow(True) | |
| axis.grid(alpha=0.35, color="#b1c2d3") | |
| axis.set_title(title, loc="left", fontweight="bold") | |
| axis.set_xlabel(xlabel) | |
| axis.set_ylabel("Mean RGB PSNR (dB)") | |
| def main(): | |
| data = json.loads((ROOT / "test-results.json").read_text()) | |
| summary = data["summary"] | |
| calibration = data["calibration"] | |
| fixed_names = ("stage_1", "stage_2", "stage_3") | |
| blue, purple, green = "#3462a1", "#7753ad", "#008371" | |
| figure, (validation, test) = plt.subplots(1, 2, figsize=(11.8, 4.7)) | |
| figure.subplots_adjust(left=0.09, right=0.97, top=0.74, bottom=0.20, wspace=0.27) | |
| figure.text(0.06, 0.91, "What does another restoration pass buy?", fontsize=20, weight="bold") | |
| figure.text(0.06, 0.84, "LumaRestore · LOL-v2 Real · Quality versus average update count", | |
| fontsize=10.5, color="#43566c") | |
| for name, color, label in ( | |
| ("regional", green, "Regional exit"), ("global", purple, "Whole-image exit") | |
| ): | |
| curve = calibration["threshold_curves"][name] | |
| validation.scatter([point["mean_stages"] for point in curve], [point["psnr"] for point in curve], | |
| color=color, s=13, alpha=0.55, label=label) | |
| selected = calibration["adaptive"][name] | |
| validation.scatter(selected["mean_stages"], selected["psnr"], s=95, color=color, | |
| edgecolors="white", linewidth=1.3, zorder=5) | |
| floor = calibration["fixed_validation_psnr"] - calibration["tolerance_db"] | |
| validation.axhline(floor, color=INK, alpha=0.7, linestyle="--", linewidth=1, label="Validation quality floor") | |
| validation.legend(frameon=False, fontsize=8, loc="best") | |
| format_axis(validation, "Validation threshold sweep", "Mean update count") | |
| test.plot([1, 2, 3], [summary[name]["psnr"] for name in fixed_names], | |
| "o-", color=blue, linewidth=2, label="Fixed exits") | |
| test.scatter(summary["cnn"]["mean_stages"], summary["cnn"]["psnr"], s=66, | |
| marker="s", color="#798296", label="One-pass CNN") | |
| for key, color, label in ( | |
| ("adaptive_regional", green, "Regional exit"), ("adaptive_global", purple, "Whole-image exit") | |
| ): | |
| row = summary[key] | |
| test.scatter(row["mean_stages"], row["psnr"], s=110, marker="D", color=color, | |
| edgecolors="white", linewidth=1.1, label=label, zorder=5) | |
| test.legend(frameon=False, fontsize=8, loc="best") | |
| test.set_xticks([1, 1.5, 2, 2.5, 3]) | |
| format_axis(test, "Official test split", "Mean update count") | |
| figure.text(0.06, 0.055, "Validation dots show candidate thresholds. Outlined markers show the selected policies.", | |
| fontsize=9.2, color="#43566c") | |
| figure.savefig(ROOT / "quality-compute.png", dpi=145) | |
| if __name__ == "__main__": | |
| main() | |