Added the inference exported model
Browse files- .gitattributes +1 -0
- panda-model-1.pkl +3 -0
- tools.py +25 -0
.gitattributes
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
2 |
example.jpg filter=lfs diff=lfs merge=lfs -text
|
|
|
|
1 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
2 |
example.jpg filter=lfs diff=lfs merge=lfs -text
|
3 |
+
panda-model-1.pkl filter=lfs diff=lfs merge=lfs -text
|
panda-model-1.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:901163c9777e38a23c9d52409b74156bb9f741d5e33655ae8917b0c6e24b3e6b
|
3 |
+
size 47089387
|
tools.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import tifffile
|
3 |
+
|
4 |
+
imgdir = Path('/scratch/train_images')
|
5 |
+
|
6 |
+
def get_crops(x):
|
7 |
+
tile_size = 250
|
8 |
+
if type(x) == PILImage:
|
9 |
+
img = np.array(x)
|
10 |
+
else:
|
11 |
+
tiff_file = imgdir/f'{x["image_id"]}.tiff'
|
12 |
+
img = tifffile.imread(tiff_file, key=1)
|
13 |
+
crop = np.array(img.shape) // tile_size * tile_size; crop
|
14 |
+
imgc = img[:crop[0],:crop[1]]
|
15 |
+
imgc = imgc.reshape(imgc.shape[0] // tile_size, tile_size, imgc.shape[1] // tile_size, tile_size, 3)
|
16 |
+
xs, ys = (imgc.mean(axis=1).mean(axis=2).mean(axis=-1) < 252).nonzero()
|
17 |
+
if len(xs) == 0:
|
18 |
+
xs, ys = (imgc.mean(axis=1).mean(axis=2).mean(axis=-1)).nonzero()
|
19 |
+
# if len(xs) < 2: print("no data in image:", x)
|
20 |
+
pidxs = random.choices(list(range(len(xs))), k=36)
|
21 |
+
return PILImage.create(imgc[xs[pidxs],:,ys[pidxs],:].reshape(6,6,tile_size,tile_size,3).transpose(0,2,1,3,4).reshape(6*tile_size,6*tile_size,3))
|
22 |
+
# return imgc.mean(axis=1).mean(axis=2).mean(axis=-1)
|
23 |
+
|
24 |
+
def get_labels(x):
|
25 |
+
return np.arange(5) <= x['isup_grade']
|