DmitriiKhizbullin
commited on
Commit
•
edee466
1
Parent(s):
58d7fdf
Fetch checkpoints and images from AWS S3
Browse files- .gitignore +2 -0
- app.py +5 -0
- file_list.txt +56 -0
- src/fetch_files.py +34 -0
.gitignore
CHANGED
@@ -4,6 +4,8 @@
|
|
4 |
/slurm_logs
|
5 |
|
6 |
/lightning_logs/
|
|
|
|
|
7 |
|
8 |
__pycache__
|
9 |
|
|
|
4 |
/slurm_logs
|
5 |
|
6 |
/lightning_logs/
|
7 |
+
/demo_data/
|
8 |
+
/release_ckpts/
|
9 |
|
10 |
__pycache__
|
11 |
|
app.py
CHANGED
@@ -10,6 +10,7 @@ from transformers import (AutoImageProcessor,
|
|
10 |
ResNetForImageClassification)
|
11 |
|
12 |
from src.labelmap import DR_LABELMAP
|
|
|
13 |
|
14 |
|
15 |
class App:
|
@@ -22,6 +23,9 @@ class App:
|
|
22 |
|
23 |
path = f"release_ckpts/{ckpt_name}/inference/"
|
24 |
|
|
|
|
|
|
|
25 |
self.image_processor = AutoImageProcessor.from_pretrained(path)
|
26 |
|
27 |
self.model = ResNetForImageClassification.from_pretrained(path)
|
@@ -147,6 +151,7 @@ class App:
|
|
147 |
|
148 |
def main():
|
149 |
""" App entry point. """
|
|
|
150 |
app = App()
|
151 |
app.launch()
|
152 |
|
|
|
10 |
ResNetForImageClassification)
|
11 |
|
12 |
from src.labelmap import DR_LABELMAP
|
13 |
+
from src.fetch_files import fetch_files
|
14 |
|
15 |
|
16 |
class App:
|
|
|
23 |
|
24 |
path = f"release_ckpts/{ckpt_name}/inference/"
|
25 |
|
26 |
+
if not os.path.exists(path):
|
27 |
+
raise Exception(f"Checkpoint not found at {path}")
|
28 |
+
|
29 |
self.image_processor = AutoImageProcessor.from_pretrained(path)
|
30 |
|
31 |
self.model = ResNetForImageClassification.from_pretrained(path)
|
|
|
151 |
|
152 |
def main():
|
153 |
""" App entry point. """
|
154 |
+
fetch_files()
|
155 |
app = App()
|
156 |
app.launch()
|
157 |
|
file_list.txt
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
demo_data/demo/0/11573_left.jpeg
|
2 |
+
demo_data/demo/0/24879_left.jpeg
|
3 |
+
demo_data/demo/0/30682_right.jpeg
|
4 |
+
demo_data/demo/0/23654_left.jpeg
|
5 |
+
demo_data/demo/0/25149_right.jpeg
|
6 |
+
demo_data/demo/0/28148_left.jpeg
|
7 |
+
demo_data/demo/0/24009_left.jpeg
|
8 |
+
demo_data/demo/0/8594_right.jpeg
|
9 |
+
demo_data/demo/0/2961_right.jpeg
|
10 |
+
demo_data/demo/0/6420_left.jpeg
|
11 |
+
demo_data/demo/3/30226_left.jpeg
|
12 |
+
demo_data/demo/3/26254_right.jpeg
|
13 |
+
demo_data/demo/3/34918_right.jpeg
|
14 |
+
demo_data/demo/3/15930_right.jpeg
|
15 |
+
demo_data/demo/3/12881_left.jpeg
|
16 |
+
demo_data/demo/3/2577_left.jpeg
|
17 |
+
demo_data/demo/3/14481_right.jpeg
|
18 |
+
demo_data/demo/3/11219_left.jpeg
|
19 |
+
demo_data/demo/3/11031_right.jpeg
|
20 |
+
demo_data/demo/3/6433_left.jpeg
|
21 |
+
demo_data/demo/4/38186_left.jpeg
|
22 |
+
demo_data/demo/4/39505_left.jpeg
|
23 |
+
demo_data/demo/4/19471_left.jpeg
|
24 |
+
demo_data/demo/4/33906_right.jpeg
|
25 |
+
demo_data/demo/4/13669_left.jpeg
|
26 |
+
demo_data/demo/4/14436_right.jpeg
|
27 |
+
demo_data/demo/4/37958_left.jpeg
|
28 |
+
demo_data/demo/4/4130_left.jpeg
|
29 |
+
demo_data/demo/4/4086_left.jpeg
|
30 |
+
demo_data/demo/4/43839_right.jpeg
|
31 |
+
demo_data/demo/1/42690_left.jpeg
|
32 |
+
demo_data/demo/1/38114_right.jpeg
|
33 |
+
demo_data/demo/1/41813_right.jpeg
|
34 |
+
demo_data/demo/1/31010_right.jpeg
|
35 |
+
demo_data/demo/1/25680_right.jpeg
|
36 |
+
demo_data/demo/1/17629_left.jpeg
|
37 |
+
demo_data/demo/1/40316_right.jpeg
|
38 |
+
demo_data/demo/1/25154_right.jpeg
|
39 |
+
demo_data/demo/1/30124_right.jpeg
|
40 |
+
demo_data/demo/1/3782_left.jpeg
|
41 |
+
demo_data/demo/2/25945_left.jpeg
|
42 |
+
demo_data/demo/2/1407_right.jpeg
|
43 |
+
demo_data/demo/2/5728_left.jpeg
|
44 |
+
demo_data/demo/2/27297_left.jpeg
|
45 |
+
demo_data/demo/2/12003_right.jpeg
|
46 |
+
demo_data/demo/2/21188_right.jpeg
|
47 |
+
demo_data/demo/2/43789_right.jpeg
|
48 |
+
demo_data/demo/2/7906_right.jpeg
|
49 |
+
demo_data/demo/2/31160_left.jpeg
|
50 |
+
demo_data/demo/2/7805_right.jpeg
|
51 |
+
release_ckpts/2023-12-20_18-39-06_30301601_V100_x4_resnet50_896_setseeds/inference/preprocessor_config.json
|
52 |
+
release_ckpts/2023-12-20_18-39-06_30301601_V100_x4_resnet50_896_setseeds/inference/config.json
|
53 |
+
release_ckpts/2023-12-20_18-39-06_30301601_V100_x4_resnet50_896_setseeds/inference/model.safetensors
|
54 |
+
release_ckpts/2023-12-24_20-02-18_30345221_V100_x4_resnet34/inference/preprocessor_config.json
|
55 |
+
release_ckpts/2023-12-24_20-02-18_30345221_V100_x4_resnet34/inference/model.safetensors
|
56 |
+
release_ckpts/2023-12-24_20-02-18_30345221_V100_x4_resnet34/inference/config.json
|
src/fetch_files.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import requests
|
3 |
+
|
4 |
+
REPO_ROOT = os.path.realpath(os.path.join(os.path.split(__file__)[0], ".."))
|
5 |
+
|
6 |
+
|
7 |
+
def fetch_files():
|
8 |
+
s3_url = "https://sdaia-kaust-public.s3.us-east-2.amazonaws.com/diabetic-retinopathy-detection/"
|
9 |
+
flist_path = os.path.join(REPO_ROOT, "file_list.txt")
|
10 |
+
with open(flist_path, "r") as file:
|
11 |
+
for line in file:
|
12 |
+
subpath = line.strip()
|
13 |
+
url = f"{s3_url}{subpath}"
|
14 |
+
target_path = os.path.join(REPO_ROOT, subpath)
|
15 |
+
if os.path.exists(target_path):
|
16 |
+
print(f"File already in place: {target_path}")
|
17 |
+
continue
|
18 |
+
print(f"Downloading {url}...")
|
19 |
+
req = requests.get(url)
|
20 |
+
if not req.ok:
|
21 |
+
print(f"Failed to download {url}")
|
22 |
+
continue
|
23 |
+
print(f"Downloaded {url}")
|
24 |
+
target_dir = os.path.split(target_path)[0]
|
25 |
+
os.makedirs(target_dir, exist_ok=True)
|
26 |
+
with open(target_path, "wb") as fdst:
|
27 |
+
fdst.write(req.content)
|
28 |
+
print(f"Saved to {target_path}")
|
29 |
+
print("File fetching done")
|
30 |
+
return
|
31 |
+
|
32 |
+
|
33 |
+
if __name__ == "__main__":
|
34 |
+
fetch_files()
|