mathpluscode Claude Opus 4.8 (1M context) commited on
Commit
2b808f7
·
1 Parent(s): 7ea7dc5

Fix broken demo: pin example data fetch to CineMA commit

Browse files

The ukb/ example images were removed from the CineMA main branch (UK
Biobank data can't be redistributed publicly), so fetching data from
/main/ returned 404 and broke the CMR Views, MAE, LAX Segmentation, and
Landmark tabs. Fetch from the same commit the cinema package is pinned to
in requirements.txt, which still ships the ukb/ data and matches the API.
Also raise on failed downloads so a bad response isn't cached.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -38,6 +38,11 @@ from tqdm import tqdm
38
  cache_dir = Path(__file__).parent
39
  cache_dir.mkdir(parents=True, exist_ok=True)
40
 
 
 
 
 
 
41
 
42
  # set device and dtype
43
  dtype, device = torch.float32, torch.device("cpu")
@@ -57,8 +62,9 @@ theme = gr.themes.Ocean(
57
  def load_nifti_from_github(name: str) -> sitk.Image:
58
  path = cache_dir / name
59
  if not path.exists():
60
- image_url = f"https://raw.githubusercontent.com/mathpluscode/CineMA/main/cinema/examples/data/{name}"
61
  response = requests.get(image_url)
 
62
  path.parent.mkdir(parents=True, exist_ok=True)
63
  with open(path, "wb") as f:
64
  f.write(response.content)
 
38
  cache_dir = Path(__file__).parent
39
  cache_dir.mkdir(parents=True, exist_ok=True)
40
 
41
+ # Pin example data to the same CineMA commit as the installed `cinema` package
42
+ # (see requirements.txt). The `main` branch no longer ships the `ukb/` example
43
+ # images, so fetching from this commit keeps the data consistent with the API.
44
+ CINEMA_DATA_REF = "dd9c19cfe5f09c26dbf29373f92ced2f9a0648b7"
45
+
46
 
47
  # set device and dtype
48
  dtype, device = torch.float32, torch.device("cpu")
 
62
  def load_nifti_from_github(name: str) -> sitk.Image:
63
  path = cache_dir / name
64
  if not path.exists():
65
+ image_url = f"https://raw.githubusercontent.com/mathpluscode/CineMA/{CINEMA_DATA_REF}/cinema/examples/data/{name}"
66
  response = requests.get(image_url)
67
+ response.raise_for_status()
68
  path.parent.mkdir(parents=True, exist_ok=True)
69
  with open(path, "wb") as f:
70
  f.write(response.content)