File size: 1,458 Bytes
bbe297f 4d1ea2e bbe297f 4d1ea2e bbe297f 4d1ea2e bbe297f f8cd4a8 bbe297f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
from pathlib import Path
import os
import gradio as gr
from gradio.components.gallery import GalleryImageType
import datasets
from datasets import load_dataset
from huggingface_hub import HfApi, HfFileSystem, login
from dotenv import load_dotenv
load_dotenv()
HF_TOKEN = os.getenv('HF_TOKEN')
login(token=HF_TOKEN, add_to_git_credential=True)
def stream_dataset_from_hub(split):
dataset = load_dataset('mcarthuradal/arm-unicef',
data_dir='images',
split=split,
streaming=True)
return dataset
dataset = stream_dataset_from_hub('train')
def get_images(path: str | Path) -> list[GalleryImageType]:
# filenames = os.listdir(path)
# image_names = [filename for filename in filenames if filename.endswith('.tif')]
n = 50
image_batch = dataset.iter(n)
yield image_batch['image']
iface = gr.Interface(fn=get_images,
inputs='text',
outputs='gallery',
title='Aerial Images Gallery',
description='A gallery of the train and test data to be used without annotations',
analytics_enabled=False,
allow_flagging='never', )
gr.Gallery(columns=5,
rows=10,
min_width=500,
allow_preview=True,
show_download_button=False,
show_share_button=False)
iface.launch(inbrowser=True)
|