joonmyung 1.5.7__tar.gz → 1.5.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {joonmyung-1.5.7 → joonmyung-1.5.9}/PKG-INFO +1 -1
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/analysis/__init__.py +1 -2
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/analysis/analysis.py +1 -7
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/analysis/dataset.py +23 -26
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/analysis/metric.py +1 -2
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/analysis/model.py +0 -2
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/analysis/utils.py +0 -3
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung.egg-info/PKG-INFO +1 -1
- {joonmyung-1.5.7 → joonmyung-1.5.9}/setup.py +1 -1
- {joonmyung-1.5.7 → joonmyung-1.5.9}/LICENSE.txt +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/README.md +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/__init__.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/analysis/hook.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/app.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/data.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/draw.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/dummy.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/file.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/gradcam.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/log.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/meta_data/__init__.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/meta_data/label.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/meta_data/utils.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/metric.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/models/__init__.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/models/tome.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/script.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/status.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung/utils.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung.egg-info/SOURCES.txt +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung.egg-info/dependency_links.txt +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung.egg-info/not-zip-safe +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/joonmyung.egg-info/top_level.txt +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/SA/MHSA.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/SA/PVTSA.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/SA/TMSA.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/SA/__init__.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/__init__.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/deit.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/evit.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/modules/PE.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/modules/__init__.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/modules/blocks.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/pvt.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/pvt_v2.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/models/tome.py +0 -0
- {joonmyung-1.5.7 → joonmyung-1.5.9}/setup.cfg +0 -0
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import os
|
|
2
|
-
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
|
|
3
1
|
from joonmyung.analysis.dataset import JDataset
|
|
4
2
|
from joonmyung.analysis.model import JModel
|
|
5
|
-
from joonmyung.draw import saliency, overlay, drawImgPlot,
|
|
3
|
+
from joonmyung.draw import saliency, overlay, drawImgPlot, unNormalize
|
|
6
4
|
from joonmyung.meta_data import data2path
|
|
7
|
-
from joonmyung.data import getTransform
|
|
8
5
|
from joonmyung.metric import targetPred, accuracy
|
|
9
6
|
from joonmyung.log import AverageMeter
|
|
10
|
-
from joonmyung.utils import to_leaf, to_np
|
|
11
7
|
from tqdm import tqdm
|
|
12
8
|
from contextlib import suppress
|
|
13
|
-
import matplotlib.pyplot as plt
|
|
14
9
|
import torch.nn.functional as F
|
|
15
10
|
import numpy as np
|
|
16
11
|
import torch
|
|
17
|
-
import PIL
|
|
18
12
|
import cv2
|
|
19
13
|
|
|
20
14
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
from torchvision.transforms import InterpolationMode
|
|
2
1
|
from joonmyung.meta_data.label import imnet_label, cifar_label
|
|
3
2
|
from torchvision.datasets.folder import default_loader
|
|
3
|
+
from torchvision.transforms import InterpolationMode
|
|
4
4
|
from timm.data import create_dataset, create_loader
|
|
5
5
|
from torchvision import transforms
|
|
6
6
|
from joonmyung.utils import getDir
|
|
7
7
|
import torch
|
|
8
8
|
import copy
|
|
9
9
|
import glob
|
|
10
|
-
import PIL
|
|
11
10
|
import os
|
|
12
11
|
|
|
13
12
|
|
|
@@ -34,7 +33,7 @@ class JDataset():
|
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
def __init__(self, data_path="/hub_data1/joonmyung/data", dataset="imagenet", train=False, transform_type = 0,
|
|
36
|
+
def __init__(self, data_path="/hub_data1/joonmyung/data/imagenet", dataset="imagenet", train=False, transform_type = 0,
|
|
38
37
|
distribution = None, size = None, device="cuda"):
|
|
39
38
|
self.dataset = dataset.lower()
|
|
40
39
|
setting = self.settings[self.dataset]
|
|
@@ -56,21 +55,18 @@ class JDataset():
|
|
|
56
55
|
self.label_paths = sorted(getDir(os.path.join(self.data_path, self.data_type)))
|
|
57
56
|
|
|
58
57
|
# self.img_paths = [sorted(glob.glob(os.path.join(self.data_path, self.data_type, "*", "*")))]
|
|
59
|
-
self.img_paths = [[path, idx] for idx, label_path in enumerate(self.label_paths) for path in sorted(glob.glob(os.path.join(self.data_path, self.data_type, label_path, "*")))]
|
|
58
|
+
# self.img_paths = [[path, idx] for idx, label_path in enumerate(self.label_paths) for path in sorted(glob.glob(os.path.join(self.data_path, self.data_type, label_path, "*")))]
|
|
59
|
+
self.img_paths = [sorted(glob.glob(os.path.join(self.data_path, self.data_type, label_path, "*"))) for label_path in self.label_paths]
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
def __getitem__(self, idx):
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
else:
|
|
66
|
-
transform_type = self.transform_type
|
|
67
|
-
|
|
68
|
-
[img_path, targets] = [idx, 0] if type(idx) == str else self.img_paths[idx]
|
|
63
|
+
label_num, img_num = idx
|
|
64
|
+
img_path = self.img_paths[label_num][img_num]
|
|
69
65
|
|
|
70
66
|
sample = default_loader(img_path)
|
|
71
|
-
sample = self.transform[transform_type](sample)
|
|
67
|
+
sample = self.transform[self.transform_type](sample)
|
|
72
68
|
|
|
73
|
-
return sample[None].to(self.device), torch.tensor(
|
|
69
|
+
return sample[None].to(self.device), torch.tensor(label_num).to(self.device), self.label_name[int(label_num)]
|
|
74
70
|
|
|
75
71
|
def getItems(self, indexs):
|
|
76
72
|
ds, ls, lns = [], [], []
|
|
@@ -81,16 +77,6 @@ class JDataset():
|
|
|
81
77
|
lns.append(ln)
|
|
82
78
|
return torch.cat(ds, dim=0), torch.stack(ls, dim=0), lns
|
|
83
79
|
|
|
84
|
-
def getIndex(self, c: list = [0, 1000], i: list = [0, 50]):
|
|
85
|
-
[c_s, c_e], [i_s, i_e] = c, i
|
|
86
|
-
c = torch.arange(c_s, c_e).reshape(-1, 1).repeat(1, i_e - i_s).reshape(-1)
|
|
87
|
-
i = torch.arange(i_s, i_e).reshape(1, -1).repeat(c_e - c_s, 1).reshape(-1)
|
|
88
|
-
c_i = torch.stack([c, i], dim=-1)
|
|
89
|
-
return c_i
|
|
90
|
-
|
|
91
|
-
def __len__(self):
|
|
92
|
-
return
|
|
93
|
-
|
|
94
80
|
def getAllItems(self, batch_size=32):
|
|
95
81
|
dataset = create_dataset(
|
|
96
82
|
root=self.data_path, name="IMNET"
|
|
@@ -111,6 +97,17 @@ class JDataset():
|
|
|
111
97
|
tf_preprocessing=False)
|
|
112
98
|
return loader
|
|
113
99
|
|
|
100
|
+
def getIndex(self, c: list = [0, 1000], i: list = [0, 50]):
|
|
101
|
+
[c_s, c_e], [i_s, i_e] = c, i
|
|
102
|
+
c = torch.arange(c_s, c_e).reshape(-1, 1).repeat(1, i_e - i_s).reshape(-1)
|
|
103
|
+
i = torch.arange(i_s, i_e).reshape(1, -1).repeat(c_e - c_s, 1).reshape(-1)
|
|
104
|
+
c_i = torch.stack([c, i], dim=-1)
|
|
105
|
+
return c_i
|
|
106
|
+
|
|
107
|
+
def __len__(self):
|
|
108
|
+
return
|
|
109
|
+
|
|
110
|
+
|
|
114
111
|
def validation(self, data):
|
|
115
112
|
return data.lower()
|
|
116
113
|
|
|
@@ -127,9 +124,9 @@ class JDataset():
|
|
|
127
124
|
return result
|
|
128
125
|
|
|
129
126
|
if __name__ == "__main__":
|
|
130
|
-
root_path = "/hub_data1/joonmyung/data"
|
|
127
|
+
root_path = "/hub_data1/joonmyung/data/imagenet"
|
|
131
128
|
dataset = "imagenet"
|
|
132
|
-
dataset = JDataset(root_path, dataset, train=
|
|
133
|
-
d, l, l_n = dataset[
|
|
134
|
-
samples = dataset.getitems([[0,1], [0,2], [0,3]])
|
|
129
|
+
dataset = JDataset(root_path, dataset, train=False)
|
|
130
|
+
d, l, l_n = dataset[[10, 3]]
|
|
131
|
+
# samples = dataset.getitems([[0,1], [0,2], [0,3]])
|
|
135
132
|
print(1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|