import pickle import datasets from renumics import spotlight import os import pandas as pd if __name__ == "__main__": cache_file = "dataset_cache.parquet" cache_file_enrichment="cifar100-enrichment-cv.parquet" cache_file_issues="sliceguard-issues.pkl" if os.path.exists(cache_file): # Load dataset from cache df = pd.read_parquet(cache_file) print("Dataset loaded from cache.") else: # Load dataset using datasets.load_dataset() dataset = datasets.load_dataset("renumics/cifar100-enriched", split="test") print("Dataset loaded using datasets.load_dataset().") df = dataset.to_pandas() # Save dataset to cache df.to_parquet(cache_file) print("Dataset saved to cache.") df_cv=pd.read_parquet(cache_file_enrichment) df = pd.concat([df, df_cv], axis=1) with open(cache_file_issues, "rb") as issue_file: issues = pickle.load(issue_file) #df = dataset.to_pandas() df_show = df.drop(columns=['embedding', 'probabilities']) while True: view = spotlight.show(df_show, issues=issues, port=7860, host="0.0.0.0", layout="sliceguard-layout.json", dtype={"image": spotlight.Image, "embedding_reduced": spotlight.Embedding}, allow_filebrowsing=False) view.close()