Spaces:
Runtime error
Runtime error
File size: 1,051 Bytes
ecfd74a 75d4c04 1d6c0ac 2a6b5a3 ecfd74a 2a6b5a3 ecfd74a 2a6b5a3 ecfd74a 1d6c0ac ecfd74a 2a6b5a3 ecfd74a 75d4c04 2a6b5a3 75d4c04 |
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 |
import pickle
import datasets
from renumics import spotlight
import os
if __name__ == "__main__":
cache_file = "dataset_cache.pkl"
if os.path.exists(cache_file):
# Load dataset from cache
with open(cache_file, "rb") as file:
dataset = pickle.load(file)
print("Dataset loaded from cache.")
else:
# Load dataset using datasets.load_dataset()
dataset = datasets.load_dataset("renumics/cifar100-enriched", split="train")
print("Dataset loaded using datasets.load_dataset().")
# Save dataset to cache
with open(cache_file, "wb") as file:
pickle.dump(dataset, file)
print("Dataset saved to cache.")
df = dataset.to_pandas()
df_show = df.drop(columns=['embedding', 'probabilities'])
while True:
view = spotlight.show(df_show.sample(5000, random_state=1), port=7860, host="0.0.0.0",
dtype={"image": spotlight.Image, "embedding_reduced": spotlight.Embedding}, allow_filebrowsing=False)
view.close() |