File size: 765 Bytes
b6e6733
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import fiftyone as fo
from io import BytesIO
from PIL import Image
from datasets import load_dataset
import os

# Load the dataset
imagenet_hard_dataset = load_dataset("taesiri/imagenet-hard", split="validation")

# same every image on disk and save path in a list

os.makedirs("dataset", exist_ok=True)

list_of_images = []

for i in range(len(imagenet_hard_dataset)):
    image = imagenet_hard_dataset[i]["image"].convert("RGB")
    image.save(f"dataset/{i}.JPEG", "JPEG", quality=100)
    list_of_images.append(f"imagenet_hard_images/{i}.jpg")


if __name__ == "__main__":
    # Ensures that the App processes are safely launched on Windows
    dataset = fo.Dataset.from_images_dir("./dataset/")
    session = fo.launch_app(dataset, port=7860)
    session.wait()