Spaces:
Sleeping
Sleeping
fix image broken links
Browse files
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=
|
| 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 |
-
|
| 48 |
-
|
|
|
|
| 49 |
continue # skip records without a resolvable path/url
|
| 50 |
-
|
| 51 |
-
|
| 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):
|