Spaces:
Sleeping
Sleeping
Yuxiang Wang
commited on
Commit
•
679611d
1
Parent(s):
438a207
add missing embedding files
Browse files- .gitignore +2 -0
- app.py +2 -1
- closest_sample.py +13 -2
.gitignore
CHANGED
@@ -11,3 +11,5 @@ images/
|
|
11 |
|
12 |
model/
|
13 |
model_classification/
|
|
|
|
|
|
11 |
|
12 |
model/
|
13 |
model_classification/
|
14 |
+
dataset/
|
15 |
+
*.png
|
app.py
CHANGED
@@ -111,7 +111,8 @@ with gr.Blocks(theme='sudeepshouche/minimalist') as demo:
|
|
111 |
classify_image_button = gr.Button("Classify Image")
|
112 |
|
113 |
with gr.Column():
|
114 |
-
segmented_image = gr.outputs.Image(label="SAM output",type='numpy')
|
|
|
115 |
segment_button = gr.Button("Segment Image")
|
116 |
#classify_segmented_button = gr.Button("Classify Segmented Image")
|
117 |
|
|
|
111 |
classify_image_button = gr.Button("Classify Image")
|
112 |
|
113 |
with gr.Column():
|
114 |
+
#segmented_image = gr.outputs.Image(label="SAM output",type='numpy')
|
115 |
+
segmented_image=gr.Image(label="Segmented Image", type='numpy')
|
116 |
segment_button = gr.Button("Segment Image")
|
117 |
#classify_segmented_button = gr.Button("Classify Segmented Image")
|
118 |
|
closest_sample.py
CHANGED
@@ -2,12 +2,23 @@ from sklearn.decomposition import PCA
|
|
2 |
import pickle as pk
|
3 |
import numpy as np
|
4 |
import pandas as pd
|
|
|
|
|
5 |
|
6 |
|
7 |
|
8 |
pca_fossils = pk.load(open('pca_fossils_170_finer.pkl','rb'))
|
9 |
pca_leaves = pk.load(open('pca_leaves_170_finer.pkl','rb'))
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
#embedding_leaves = np.load('embedding_leaves.npy')
|
12 |
|
13 |
fossils_pd= pd.read_csv('fossils_paths.csv')
|
@@ -39,4 +50,4 @@ def get_images(embedding):
|
|
39 |
paths= [path.replace('/gpfs/data/tserre/irodri15/Fossils/new_data/leavesdb-v1_1/images/Fossil/Florissant_Fossil/512/full/jpg/',
|
40 |
'/media/data_cifs/projects/prj_fossils/data/processed_data/leavesdb-v1_1/images/Fossil/Florissant_Fossil/original/full/jpg/') for path in paths]
|
41 |
print(paths)
|
42 |
-
return paths
|
|
|
2 |
import pickle as pk
|
3 |
import numpy as np
|
4 |
import pandas as pd
|
5 |
+
import os
|
6 |
+
from huggingface_hub import snapshot_download
|
7 |
|
8 |
|
9 |
|
10 |
pca_fossils = pk.load(open('pca_fossils_170_finer.pkl','rb'))
|
11 |
pca_leaves = pk.load(open('pca_leaves_170_finer.pkl','rb'))
|
12 |
+
|
13 |
+
if not os.path.exists('dataset'):
|
14 |
+
REPO_ID='Serrelab/Fossils'
|
15 |
+
token = os.environ.get('READ_TOKEN')
|
16 |
+
print(f"Read token:{token}")
|
17 |
+
if token is None:
|
18 |
+
print("warning! A read token in env variables is needed for authentication.")
|
19 |
+
snapshot_download(repo_id=REPO_ID, token=token,repo_type='dataset',local_dir='dataset')
|
20 |
+
|
21 |
+
embedding_fossils = np.load('dataset/embedding_fossils_170_finer.npy')
|
22 |
#embedding_leaves = np.load('embedding_leaves.npy')
|
23 |
|
24 |
fossils_pd= pd.read_csv('fossils_paths.csv')
|
|
|
50 |
paths= [path.replace('/gpfs/data/tserre/irodri15/Fossils/new_data/leavesdb-v1_1/images/Fossil/Florissant_Fossil/512/full/jpg/',
|
51 |
'/media/data_cifs/projects/prj_fossils/data/processed_data/leavesdb-v1_1/images/Fossil/Florissant_Fossil/original/full/jpg/') for path in paths]
|
52 |
print(paths)
|
53 |
+
return paths
|