MarkusStoll's picture
fix
cb250cc
raw
history blame contribute delete
963 Bytes
import pickle
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:
df = pickle.load(file)
print("Dataset loaded from cache.")
while True:
df = df.drop(columns=["embedding_ft", "nn_image", "embedding_foundation"])
df = df.sample(10000, random_state=42).reset_index(drop=True)
dtypes = {
"image": spotlight.Image,
"embedding_foundation_precalc": spotlight.Embedding,
}
view = spotlight.show(
df,
dtype=dtypes,
port=7860,
host="0.0.0.0",
allow_filebrowsing=False
)
view.close()
else:
print(f"Dataset {cache_file} not found. Please run prepare.py first.")