teddyk251 commited on
Commit
e60a692
·
1 Parent(s): 1082f9f

fix image broken links

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -10,7 +10,7 @@ TOKEN = os.environ.get("HF_TOKEN")
10
 
11
  ds = load_dataset(REPO_ID, split="train", token=TOKEN)
12
 
13
- ds = ds.cast_column("image", HFImage(decode=False))
14
 
15
  def img_src(img):
16
  # HF Datasets gives either a dict with 'path' (local cache) or 'url'
@@ -44,11 +44,12 @@ def paginate(rows, page, page_size):
44
  # for i in range(len(sub))]\
45
  gallery_items = []
46
  for i in range(len(sub)):
47
- src = img_src(sub[i]["image"])
48
- if not src:
 
49
  continue # skip records without a resolvable path/url
50
- label = f'{sub[i]["dataset"]} / {sub[i]["model"]} — {sub[i].get("filename","")}'
51
- gallery_items.append((src, label))
52
  return gallery_items, total, total_pages, page
53
 
54
  def refresh(dataset_sel, model_sel, query, page, page_size):
 
10
 
11
  ds = load_dataset(REPO_ID, split="train", token=TOKEN)
12
 
13
+ ds = ds.cast_column("image", HFImage(decode=True))
14
 
15
  def img_src(img):
16
  # HF Datasets gives either a dict with 'path' (local cache) or 'url'
 
44
  # for i in range(len(sub))]\
45
  gallery_items = []
46
  for i in range(len(sub)):
47
+ # src = img_src(sub[i]["image"])
48
+ img = sub[i]["image"]
49
+ if img is None:
50
  continue # skip records without a resolvable path/url
51
+ label = f'{sub[i]["dataset"]} / {sub[i]["model"]} — {sub[i].get("filename","")}'
52
+ gallery_items.append((img, label))
53
  return gallery_items, total, total_pages, page
54
 
55
  def refresh(dataset_sel, model_sel, query, page, page_size):