Spaces:
Runtime error
Runtime error
File size: 963 Bytes
bc08e7a 1db7b55 cb250cc bc08e7a |
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 |
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.")
|