Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. # coding: utf-8
  2.  
  3. # In[1]:
  4.  
  5. from theano.sandbox import cuda
  6. cuda.use('gpu3')
  7.  
  8.  
  9. # In[2]:
  10.  
  11. get_ipython().magic(u'matplotlib inline')
  12. import utils; reload(utils)
  13. from utils import *
  14. from __future__ import division, print_function
  15.  
  16.  
  17. # In[3]:
  18.  
  19. #path = "data/fish/sample/"
  20. path = "data/fish/"
  21. batch_size=64
  22.  
  23.  
  24. # In[4]:
  25.  
  26. batches = get_batches(path+'train', batch_size=batch_size)
  27. val_batches = get_batches(path+'valid', batch_size=batch_size*2, shuffle=False)
  28.  
  29.  
  30. # ## Setup dirs
  31.  
  32. # In[ ]:
  33.  
  34. get_ipython().magic(u'cd data/fish')
  35.  
  36. get_ipython().magic(u'cd train')
  37.  
  38. get_ipython().magic(u'mkdir ../valid')
  39.  
  40.  
  41. # In[ ]:
  42.  
  43. g = glob('*')
  44. for d in g: os.mkdir('../valid/'+d)
  45.  
  46. g = glob('*/*.jpg')
  47. shuf = np.random.permutation(g)
  48. for i in range(500): os.rename(shuf[i], '../valid/' + shuf[i])
  49.  
  50.  
  51. # In[ ]:
  52.  
  53. get_ipython().magic(u'mkdir ../sample')
  54. get_ipython().magic(u'mkdir ../sample/train')
  55. get_ipython().magic(u'mkdir ../sample/valid')
  56.  
  57.  
  58. # In[ ]:
  59.  
  60. from shutil import copyfile
  61.  
  62. g = glob('*')
  63. for d in g:
  64. os.mkdir('../sample/train/'+d)
  65. os.mkdir('../sample/valid/'+d)
  66.  
  67.  
  68. # In[ ]:
  69.  
  70. g = glob('*/*.jpg')
  71. shuf = np.random.permutation(g)
  72. for i in range(400): copyfile(shuf[i], '../sample/train/' + shuf[i])
  73.  
  74. get_ipython().magic(u'cd ../valid')
  75.  
  76. g = glob('*/*.jpg')
  77. shuf = np.random.permutation(g)
  78. for i in range(200): copyfile(shuf[i], '../sample/valid/' + shuf[i])
  79.  
  80. get_ipython().magic(u'cd ..')
  81.  
  82.  
  83. # In[ ]:
  84.  
  85. get_ipython().magic(u'mkdir results')
  86.  
  87. get_ipython().magic(u'mkdir sample/results')
  88.  
  89. get_ipython().magic(u'cd ../..')
  90.  
  91.  
  92. # ## Initial model
  93.  
  94. # In[5]:
  95.  
  96. from vgg16 import Vgg16
  97. model = vgg_ft(8)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement