Skip to content

Instantly share code, notes, and snippets.

View CaptainAshis's full-sized avatar
☺️
Developing intuition of Algorithms by coding it !!!

Ashis Kumar Panda CaptainAshis

☺️
Developing intuition of Algorithms by coding it !!!
View GitHub Profile
@CaptainAshis
CaptainAshis / unzip.py
Last active August 25, 2018 05:04
unzip fastai
! unzip labels.csv.zip
! unzip sample_submission.csv.zip
! unzip test.zip
! unzip train.zip
@CaptainAshis
CaptainAshis / readfile.py
Created August 25, 2018 05:16
readfile fastai
labels_df=pd.read_csv(f'{PATH}labels.csv')
labels_df.head()
@CaptainAshis
CaptainAshis / val.py
Created August 25, 2018 05:32
validation fastai
label_csv=f'{PATH}labels.csv'
n=len(list(open(label_csv)))-1
val_idxs=get_cv_idxs(n)
@CaptainAshis
CaptainAshis / val_size.py
Created August 25, 2018 08:21
val_size fastai
print("Total size",n)
print("Total validation size",len(val_idxs))
####################
#Total size 10222
#Total validation size 2044
sz=224 # size of image
arch=resnext101_64 # architecture used
bs=64 # batch size used
@CaptainAshis
CaptainAshis / data.py
Created August 27, 2018 09:04
data fastai
data= ImageClassifierData.from_csv(PATH,'train',f'{PATH}labels.csv',test_name='test',
val_idxs=val_idxs,suffix='.jpg',tfms=tfms_from_model(arch, sz),bs=64)
@CaptainAshis
CaptainAshis / im.py
Created August 27, 2018 09:06
imag fastai
fn=PATH+data.trn_ds.fnames[1]
fn
## '/content/clouderizer/dogbreed/data/competitions/dog-breed-identification/train/001cdf01b096e06d78e9e5112d419397.jpg'
img=PIL.Image.open(fn)
img
@CaptainAshis
CaptainAshis / image_size.py
Created August 27, 2018 09:09
image size fastai
img.size
##(500, 375)
# Mapping name of the file to size of the file
size_d={k:PIL.Image.open(PATH+k).size for k in data.trn_ds.fnames}
row_sz,col_sz=list(zip(*size_d.values()))
row_sz=np.array(row_sz)
@CaptainAshis
CaptainAshis / imag_clas.py
Last active August 27, 2018 09:15
imag_clas fastai
len(data.trn_ds),len(data.test_ds)
### (8178, 10357)
len(data.classes),data.classes[:5]
##################################
# (120,
# ['affenpinscher',
# 'afghan_hound',
@CaptainAshis
CaptainAshis / imag_resiz.py
Created August 27, 2018 09:17
image_resiz fastai
def get_data(sz,bs):
tfms=tfms_from_model(arch, sz,aug_tfms=transforms_side_on,max_zoom=1.1)
data= ImageClassifierData.from_csv(PATH,'train',f'{PATH}labels.csv',test_name='test',num_workers=8,
val_idxs=val_idxs,suffix='.jpg',tfms=tfms,bs=bs)
return data if sz>300 else data.resize(340,'tmp')
data=get_data(sz,bs)