MarkusStoll Syoy commited on
Commit
e6582df
0 Parent(s):

Duplicate from renumics/cifar100-enriched

Browse files

Co-authored-by: Marius Steger <Syoy@users.noreply.huggingface.co>

Files changed (8) hide show
  1. .gitattributes +34 -0
  2. .gitignore +2 -0
  3. Dockerfile +19 -0
  4. README.md +21 -0
  5. prepare.py +22 -0
  6. requirements.txt +2 -0
  7. run.py +30 -0
  8. spotlight-layout.json +1 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+
2
+ .venv/
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+ ENV HOME=/code
5
+ # COPY ./requirements.txt /code/requirements.txt
6
+ # RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
7
+
8
+ RUN apt install curl
9
+ RUN pip install pip -U
10
+
11
+ RUN pip install renumics-spotlight==1.2.0rc2
12
+
13
+ RUN pip install datasets
14
+
15
+ COPY . .
16
+ RUN mkdir -p /code/.cache
17
+ RUN chmod -R 777 /code
18
+ RUN python prepare.py
19
+ CMD ["python", "run.py"]
README.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Explore CIFAR-100 Enriched with Spotlight
3
+ emoji: 📊
4
+ colorFrom: gray
5
+ colorTo: blue
6
+ sdk: docker
7
+ pinned: false
8
+ license: mit
9
+ app_file: run.py
10
+ datasets:
11
+ - renumics/cifar100-enriched
12
+ - cifar100
13
+ tags:
14
+ - renumics
15
+ - spotlight
16
+ - EDA
17
+ - enriched
18
+ duplicated_from: renumics/cifar100-enriched
19
+ ---
20
+
21
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
prepare.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import datasets
3
+ import os
4
+
5
+ if __name__ == "__main__":
6
+ cache_file = "dataset_cache.pkl"
7
+ if os.path.exists(cache_file):
8
+ # Load dataset from cache
9
+ with open(cache_file, "rb") as file:
10
+ dataset = pickle.load(file)
11
+ print("Dataset loaded from cache.")
12
+ else:
13
+ # Load dataset using datasets.load_dataset()
14
+ dataset = datasets.load_dataset("renumics/cifar100-enriched", split="train")
15
+ print("Dataset loaded using datasets.load_dataset().")
16
+
17
+ # Save dataset to cache
18
+ with open(cache_file, "wb") as file:
19
+ pickle.dump(dataset, file)
20
+
21
+ print("Dataset saved to cache.")
22
+
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ renumics-spotlight
2
+ datasets
run.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import datasets
3
+ from renumics import spotlight
4
+ import os
5
+
6
+ if __name__ == "__main__":
7
+ cache_file = "dataset_cache.pkl"
8
+ if os.path.exists(cache_file):
9
+ # Load dataset from cache
10
+ with open(cache_file, "rb") as file:
11
+ dataset = pickle.load(file)
12
+ print("Dataset loaded from cache.")
13
+ else:
14
+ # Load dataset using datasets.load_dataset()
15
+ dataset = datasets.load_dataset("renumics/cifar100-enriched", split="train")
16
+ print("Dataset loaded using datasets.load_dataset().")
17
+
18
+ # Save dataset to cache
19
+ with open(cache_file, "wb") as file:
20
+ pickle.dump(dataset, file)
21
+
22
+ print("Dataset saved to cache.")
23
+
24
+
25
+ df = dataset.to_pandas()
26
+ df_show = df.drop(columns=['embedding', 'probabilities'])
27
+ while True:
28
+ view = spotlight.show(df_show.sample(5000, random_state=1), port=7860, host="0.0.0.0",
29
+ dtype={"image": spotlight.Image, "embedding_reduced": spotlight.Embedding}, allow_filebrowsing=False)
30
+ view.close()
spotlight-layout.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"orientation":"vertical","children":[{"kind":"split","weight":55.52608311229001,"orientation":"horizontal","children":[{"kind":"tab","weight":41.16700201207244,"children":[{"kind":"widget","name":"Table","type":"table","config":{"tableView":"full","visibleColumns":["coarse_label_str","fine_label_prediction_str","fine_label_str","image","__idx__"],"sorting":[["__idx__","DESC"]],"orderByRelevance":false,"columnWidths":{"coarse_label":92,"coarse_label_str":165,"embedding_reduced":128,"fine_label":92,"fine_label_prediction":92,"fine_label_prediction_error":92,"fine_label_prediction_str":244,"fine_label_str":194,"full_image":256,"image":200,"split":256,"__idx__":92,"__last_edited_at__":192,"__last_edited_by__":256}}}]},{"kind":"tab","weight":33.66487769877306,"children":[{"kind":"widget","name":"Similarity Map","type":"similaritymap","config":{"placeBy":null,"reductionMethod":null,"colorBy":"fine_label_str","sizeBy":null,"filter":false,"umapNNeighbors":20,"umapMetric":null,"umapMinDist":0.15,"pcaNormalization":null,"umapMenuLocalGlobalBalance":null,"umapMenuIsAdvanced":false}},{"kind":"widget","name":"Scatter Plot","type":"scatterplot","config":{"xAxisColumn":null,"yAxisColumn":null,"colorBy":null,"sizeBy":null,"filter":false}}]},{"kind":"tab","weight":25.168120289154498,"children":[{"kind":"widget","name":"Histogram","type":"histogram","config":{"columnKey":"fine_label_str","stackByColumnKey":"fine_label_prediction_error","filter":false}}]}]},{"kind":"tab","weight":44.47391688770999,"children":[{"kind":"widget","name":"Inspector","type":"inspector","config":{"views":[{"view":"ImageView","key":"es3NP2fbYeG5TzTQqCzZKL","name":"image","columns":["image"]},{"view":"TextLens","columns":["fine_label_str"],"name":"view","key":"7262001a-1270-467c-bfe8-6b6883adbc7d"},{"view":"TextLens","columns":["fine_label_prediction_str"],"name":"view","key":"f72a8ae9-17c4-4097-b454-79a6f60865db"},{"view":"ScalarView","columns":["fine_label_prediction_error"],"name":"view","key":"be4d6afe-9093-4581-b363-df11d3c6d34a"}],"visibleColumns":4}}]}]}