import json import os from functools import lru_cache import gradio as gr from huggingface_hub import hf_hub_download, hf_hub_url DATASET_REPO_ID = 'marcuskwan/relight-five-model-comparison-assets' MODEL_COLUMNS = [ ("qwen", "Qwen"), ("lightx2v", "LightX2V"), ("step1x", "Step1X"), ("ic_light", "IC-Light"), ("firered", "FireRed"), ] @lru_cache(maxsize=1) def load_manifest(): path = hf_hub_download(DATASET_REPO_ID, "manifest.jsonl", repo_type="dataset") rows = [] with open(path, "r", encoding="utf-8") as f: for line in f: if line.strip(): rows.append(json.loads(line)) return rows def asset_url(path): return hf_hub_url(DATASET_REPO_ID, filename=path, repo_type="dataset") def image_cell(label, url): return f"""
""" def render(sample_id): rows = load_manifest() row = next((r for r in rows if r["sample_id"] == sample_id), rows[0]) cells = [ image_cell("Reference", asset_url(row["reference_image"])), image_cell("Original gen", asset_url(row["original_gen"])), ] for key, label in MODEL_COLUMNS: cells.append(image_cell(label, asset_url(row["outputs"][key]))) prompt = row["prompt"].replace("&", "&").replace("<", "<").replace(">", ">") return f"""