Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract thumbnails #1

Open
wants to merge 119 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
8780d05
Add files via upload
agrawal08akhil May 23, 2018
fb7c088
Add files via upload
rahulmeena810 May 23, 2018
414d704
commiting to scrab_thumbnails
akhil08agrawal May 28, 2018
51ccebb
adding the code scrab_sb
akhil08agrawal May 28, 2018
7b2d2cc
update the code scrab_socialblade
akhil08agrawal May 29, 2018
6f4b7f7
updating the code yvue.py, which will be completed later
akhil08agrawal May 29, 2018
fbe55fc
updating and adding a new read me file
akhil08agrawal May 29, 2018
c98e73d
updating yvue.py
akhil08agrawal Jun 1, 2018
feea3db
updating model
akhil08agrawal Jun 1, 2018
4e1e09f
adding tl model1
rahulmeena810 Jun 1, 2018
ed1d5bc
updating data
rahulmeena810 Jun 1, 2018
9c4d9b3
updating the code
rahulmeena810 Jun 1, 2018
9ca14e7
second change
rahulmeena810 Jun 1, 2018
1168e6a
third second model
Jun 1, 2018
2c724de
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
Jun 1, 2018
b59aae4
adding model 2
rahulmeena810 Jun 1, 2018
076e3fa
Merge branch 'extract_thumbnails' of https://github.com/KubricIO/thum…
rahulmeena810 Jun 1, 2018
b6386ad
adding new files
Jun 4, 2018
cf32354
adding new csv which contains new channel ids
akhil08agrawal Jun 4, 2018
db7aa32
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
akhil08agrawal Jun 4, 2018
cb61618
modified yvue
Jun 4, 2018
724785c
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
akhil08agrawal Jun 4, 2018
d52aef0
Add files via upload
rahulmeena810 Jun 5, 2018
fa8a84e
adding new data
akhil08agrawal Jun 5, 2018
0ff470c
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
akhil08agrawal Jun 5, 2018
0ad1bb3
adding bad thumbnail extracter
rahulmeena810 Jun 6, 2018
ca108c7
updating dataset
akhil08agrawal Jun 6, 2018
7ea936c
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
rahulmeena810 Jun 6, 2018
96c0e24
adding new file
rahulmeena810 Jun 6, 2018
495b2e6
adding new images
rahulmeena810 Jun 7, 2018
f96d07a
adding new good images
rahulmeena810 Jun 7, 2018
c7cd00b
changing data
rahulmeena810 Jun 8, 2018
bf56a87
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
rahulmeena810 Jun 8, 2018
cfee59e
updating .gitignore file
akhil08agrawal Jun 8, 2018
53a9c1b
prediction algorithm
akhil08agrawal Jun 8, 2018
b4ed2e6
`Merge branch 'extract_thumbnails' of https://github.com/kubricio/thu…
akhil08agrawal Jun 8, 2018
21fff90
video_to_frames.py code
akhil08agrawal Jun 8, 2018
67c5352
video_to_frames.py code
akhil08agrawal Jun 8, 2018
0bace84
video to frames2 copy
akhil08agrawal Jun 11, 2018
5e8daea
new data set
akhil08agrawal Jun 18, 2018
302a108
adding movie poster to training data
akhil08agrawal Jun 25, 2018
51712d6
adding requirements file
akhil08agrawal Jun 25, 2018
61ba9bf
adding bad images
akhil08agrawal Jun 25, 2018
7c2815e
deleting an image
akhil08agrawal Jun 25, 2018
d66e292
updating model_two.py
rahulmeena810 Jun 25, 2018
3c71d60
1
rahulmeena810 Jun 25, 2018
46afd55
2
rahulmeena810 Jun 25, 2018
e59a408
3
rahulmeena810 Jun 25, 2018
8aba96c
4
rahulmeena810 Jun 25, 2018
0f6624d
adding movie poster extraction code
akhil08agrawal Jun 25, 2018
33d844b
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
akhil08agrawal Jun 25, 2018
37b39f5
adding new second_model.h5
rahulmeena810 Jun 26, 2018
fd705b3
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
rahulmeena810 Jun 26, 2018
ed5f548
improving model_two.py
rahulmeena810 Jun 27, 2018
767eb12
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
rahulmeena810 Jun 27, 2018
938046e
removing no. of images divisible by batch_size error
rahulmeena810 Jun 27, 2018
72e6c05
modifying model_two to take data in multiple of batch_size
rahulmeena810 Jun 27, 2018
1ac0e25
solved an error
rahulmeena810 Jun 27, 2018
87e8cf0
fixing labels
rahulmeena810 Jun 27, 2018
e61c608
uploading new h5 file
rahulmeena810 Jun 27, 2018
0189b70
renaming h5 file
rahulmeena810 Jun 27, 2018
11da42f
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
rahulmeena810 Jun 27, 2018
2e00441
new h5 file
rahulmeena810 Jun 27, 2018
58ff662
changing epochs to 20 and batch size to 16
rahulmeena810 Jun 27, 2018
ea4d43e
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
rahulmeena810 Jun 27, 2018
4e9b6f8
changing epochs to 25 and batch size to 8
rahulmeena810 Jun 27, 2018
1dd8291
epochs=20, batch_size=16
rahulmeena810 Jun 27, 2018
a1886e2
epochs=20,batch size=4
rahulmeena810 Jun 27, 2018
5490450
adam optimizer and dense=2
rahulmeena810 Jun 29, 2018
9763c63
adam optimizer and dense=1
rahulmeena810 Jun 29, 2018
f412f47
adam optimizer and dense=1 and some other things
rahulmeena810 Jun 29, 2018
eebbc84
updating model 2
akhil08agrawal Jun 29, 2018
b2bb8f9
updating model two
akhil08agrawal Jun 29, 2018
b0520c3
updating model 2
akhil08agrawal Jun 29, 2018
2b565ab
updating model 2
akhil08agrawal Jun 29, 2018
1d0a1b3
updating model 2
akhil08agrawal Jun 29, 2018
297eb78
updating model 2
akhil08agrawal Jun 29, 2018
d6dc9ad
updating model 2
akhil08agrawal Jun 29, 2018
ca52d8b
updating model 2
akhil08agrawal Jun 29, 2018
cac7a1c
updating model 3
akhil08agrawal Jun 29, 2018
c1968b2
adding stuff to model2
rahulmeena810 Jun 29, 2018
3130528
updating model 3
akhil08agrawal Jun 29, 2018
f5cf0ae
updating model 3
akhil08agrawal Jun 29, 2018
243dba5
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
akhil08agrawal Jun 29, 2018
2683276
updating model 3
akhil08agrawal Jun 29, 2018
d6f571e
updating model 3
akhil08agrawal Jun 29, 2018
48e3b23
fixing broken model2
rahulmeena810 Jun 29, 2018
cf7861e
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
rahulmeena810 Jun 29, 2018
6066f29
updating model 3
akhil08agrawal Jun 29, 2018
6c90e9d
Merge branch 'extract_thumbnails' of https://github.com/kubricio/thum…
akhil08agrawal Jun 29, 2018
c146deb
updating model three
akhil08agrawal Jul 2, 2018
edc2c7c
updating .idea/workspace
akhil08agrawal Jul 2, 2018
0b46d09
updating code
akhil08agrawal Jul 2, 2018
3742d3b
updating code 3
akhil08agrawal Jul 2, 2018
a2fa0ec
updating code
akhil08agrawal Jul 2, 2018
cbaf2e6
adding new images
akhil08agrawal Jul 2, 2018
2bc5ac6
updating model 3
rahulrathi123 Jul 2, 2018
0f6a75c
updating model 3
akhil08agrawal Jul 2, 2018
31a3c68
updating model 3
akhil08agrawal Jul 2, 2018
7d888d2
updating model 3
akhil08agrawal Jul 2, 2018
45d937b
updating pred img code
akhil08agrawal Jul 2, 2018
629de60
updating code 3
akhil08agrawal Jul 2, 2018
139799f
updating training data
akhil08agrawal Jul 2, 2018
ebf862f
updating code 3
akhil08agrawal Jul 2, 2018
ade0f4b
updating code 3
akhil08agrawal Jul 2, 2018
6a15971
updating new code for training it with a new convolution layer
akhil08agrawal Jul 3, 2018
21a7377
updating new code for training it with a new convolution layer
akhil08agrawal Jul 3, 2018
9827de0
updating code with inception idea
akhil08agrawal Jul 3, 2018
d2f69f2
updating code with inception idea
akhil08agrawal Jul 3, 2018
0ea7370
updating code with inception idea
akhil08agrawal Jul 3, 2018
45a22ac
updating code with inception idea
akhil08agrawal Jul 3, 2018
8850100
updating model 3
akhil08agrawal Jul 5, 2018
b6b2384
adding model 3
akhil08agrawal Jul 5, 2018
1681402
adding feedback loop code and the required data for it
akhil08agrawal Jul 5, 2018
7ab31bf
updating feedback loop
akhil08agrawal Jul 5, 2018
489e795
added feedback_loop_edit
karthikvarma04 Jul 6, 2018
8e20474
updated feedback loop edit
karthikvarma04 Jul 6, 2018
4f40426
updating feedback loop
akhil08agrawal Jul 6, 2018
2fe462c
updated feedback loop edit
karthikvarma04 Jul 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
config.py
api_key.txt
*.npy
*.py.save

6 changes: 6 additions & 0 deletions .keras/keras.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"floatx": "float32",
"epsilon": 1e-07,
"backend": "tensorflow",
"image_data_format": "channels_last"
}
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# thumbnailr
# thumbnailr


The codes uploaded so far :

1) yvue.py ( youtube video url extracter)

This video takes in input the csv file of channel ids and gives out the thumbnails
of the top videos for each YouTube Channel

The csv file is also added named channel_list_top_500.csv

2) scrap_sb : This code extracts the channel ids from the social blade site.
This code is not inculcated in the main code so that the choice of videos for
good thumbnails can be different and so we provide the downloaded dataset from
the same code.

Binary file added bad/1000.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1002.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1003.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1004.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1005.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1006.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1007.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1008.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1009.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1010.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1011.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1012.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1013.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1014.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1015.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1016.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1017.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1018.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1019.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1020.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1021.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1022.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1023.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1024.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bad/1025.jpg
Binary file added bad/1026.jpg
Binary file added bad/1027.jpg
Binary file added bad/1028.jpg
Binary file added bad/1029.jpg
Binary file added bad/1030.jpg
Binary file added bad/1031.jpg
Binary file added bad/1032.jpg
Binary file added bad/1033.jpg
Binary file added bad/1034.jpg
Binary file added bad/1035.jpg
Binary file added bad/1036.jpg
Binary file added bad/1037.jpg
Binary file added bad/1038.jpg
Binary file added bad/1039.jpg
Binary file added bad/1040.jpg
Binary file added bad/1041.jpg
Binary file added bad/1042.jpg
Binary file added bad/1043.jpg
Binary file added bad/1044.jpg
Binary file added bad/1045.jpg
Binary file added bad/1046.jpg
Binary file added bad/1047.jpg
Binary file added bad/1048.jpg
Binary file added bad/1049.jpg
Binary file added bad/1050.jpg
Binary file added bad/1051.jpg
Binary file added bad/1052.jpg
Binary file added bad/1053.jpg
Binary file added bad/1054.jpg
Binary file added bad/1055.jpg
Binary file added bad/1056.jpg
Binary file added bad/1057.jpg
Binary file added bad/1058.jpg
Binary file added bad/1059.jpg
Binary file added bad/1060.jpg
Binary file added bad/1061.jpg
Binary file added bad/1062.jpg
Binary file added bad/1063.jpg
Binary file added bad/1064.jpg
Binary file added bad/1065.jpg
Binary file added bad/1066.jpg
Binary file added bad/1067.jpg
Binary file added bad/1068.jpg
Binary file added bad/1069.jpg
Binary file added bad/1070.jpg
Binary file added bad/1071.jpg
Binary file added bad/1072.jpg
Binary file added bad/1073.jpg
Binary file added bad/1074.jpg
Binary file added bad/1075.jpg
Binary file added bad/1076.jpg
Binary file added bad/1077.jpg
Binary file added bad/1078.jpg
Binary file added bad/1079.jpg
Binary file added bad/1080.jpg
Binary file added bad/1081.jpg
Binary file added bad/1082.jpg
Binary file added bad/1083.jpg
Binary file added bad/1084.jpg
Binary file added bad/1085.jpg
Binary file added bad/1086.jpg
Binary file added bad/1087.jpg
Binary file added bad/1088.jpg
Binary file added bad/1089.jpg
Binary file added bad/1090.jpg
Binary file added bad/1091.jpg
Binary file added bad/1092.jpg
Binary file added bad/1093.jpg
Binary file added bad/1094.jpg
Binary file added bad/1095.jpg
Binary file added bad/1096.jpg
Binary file added bad/1097.jpg
Binary file added bad/1098.jpg
Binary file added bad/1099.jpg
Binary file added bad/1100.jpg
Binary file added bad/1101.jpg
Binary file added bad/1102.jpg
Binary file added bad/1103.jpg
Binary file added bad/1104.jpg
Binary file added bad/1105.jpg
Binary file added bad/1106.jpg
Binary file added bad/1107.jpg
Binary file added bad/1108.jpg
Binary file added bad/1109.jpg
Binary file added bad/1110.jpg
Binary file added bad/1111.jpg
Binary file added bad/1112.jpg
Binary file added bad/1113.jpg
Binary file added bad/1114.jpg
Binary file added bad/1115.jpg
Binary file added bad/1116.jpg
Binary file added bad/1117.jpg
Binary file added bad/1118.jpg
Binary file added bad/1119.jpg
Binary file added bad/1120.jpg
Binary file added bad/1121.jpg
Binary file added bad/1122.jpg
Binary file added bad/1123.jpg
Binary file added bad/1124.jpg
Binary file added bad/1125.jpg
Binary file added bad/1126.jpg
Binary file added bad/1127.jpg
Binary file added bad/1128.jpg
Binary file added bad/1129.jpg
Binary file added bad/1130.jpg
Binary file added bad/1131.jpg
Binary file added bad/1132.jpg
Binary file added bottleneck_fc_model.h5
Binary file not shown.
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
api_key = 'AIzaSyBrg-tiQY2DcHZ8ixXm6ZqEPd1R8aEGrGE'
71 changes: 71 additions & 0 deletions feedback_loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import cv2
import os
from PIL import Image
import subprocess

import numpy as np
import requests
#import urllib2

import shutil
from uuid import uuid4

def create_directory(directory):
"""
:param directory: folder path which needs to be created if not already present
:return: nothing
"""
if not os.path.exists(directory):
os.makedirs(directory)

def get_filecount(path_to_directory):
if os.path.exists(path_to_directory):
path,dirs,files = os.walk(path_to_directory).__next__()
file_count = len(files)
return file_count
else :
print("path does not exist")
return 0


path = '/home/akhil/thumbnailr/overall/' # change the path to directory
if not os.path.isdir(path):
os.makedirs(path)

# files = os.listdir(path)
count = get_filecount(path)
print(count)

path1 = './' + 'folder1'
create_directory(path1)
path2 = './' + 'folder2'
create_directory(path2)
path3 = './' + 'folder3'
create_directory(path3)
path4 = './' + 'folder4'
create_directory(path4)
path5 = './' + 'folder5'
create_directory(path5)
path6 = './' + 'folder6'
create_directory(path6)

def feedback_loop():


path = './overall/'
create_directory(path)
for i in range(5):
print ("i = ",i)
image = Image.open(path + str(i + 1) + '.jpg',"r")
image.show()
folder = input()
cv2.imwrite(os.path.join(path + '/folder' + str(folder) + './'+ str (i + 1) + ".jpg"), image)
os.popen('killall display')
image.close()
i +=1

feedback_loop()




71 changes: 71 additions & 0 deletions feedback_loop_edit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import cv2
import os
from PIL import Image
import subprocess
import numpy as np
import requests
#import urllib2

import shutil
from uuid import uuid4

def create_directory(directory):
"""
:param directory: folder path which needs to be created if not already present
:return: nothing
"""
if not os.path.exists(directory):
os.makedirs(directory)

def get_filecount(path_to_directory):
if os.path.exists(path_to_directory):
path,dirs,files = os.walk(path_to_directory).__next__()
file_count = len(files)
return file_count
else :
print("path does not exist")
return 0


path = '/home/karthik/thumbnailr/overall/' # change the path to directory
if not os.path.isdir(path):
os.makedirs(path)

files = os.listdir(path)
count = get_filecount(path)
print(count)

path1 = './' + 'folder1'
create_directory(path1)
path2 = './' + 'folder2'
create_directory(path2)
path3 = './' + 'folder3'
create_directory(path3)
path4 = './' + 'folder4'
create_directory(path4)
path5 = './' + 'folder5'
create_directory(path5)
path6 = './' + 'folder6'
create_directory(path6)


def feedback_loop():

for i in range(5):
print ("i = ",i)
image = Image.open(path + str(i + 1) + '.jpg',"r")
image.show()
folder = input()
shutil.copy2(path + str(i + 1) + '.jpg','./'+ 'folder'+folder)
os.popen('killall display')
image.close()
i +=1




feedback_loop()




116 changes: 116 additions & 0 deletions first_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats
- put the cat pictures index 1000-1400 in data/validation/cats
- put the dogs pictures index 12500-13499 in data/train/dogs
- put the dog pictures index 13500-13900 in data/validation/dogs
So that we have 1000 training examples for each class, and 400 validation examples for each class.
In summary, this is our directory structure:
```
data/
train/
dogs/
dog001.jpg
dog002.jpg
...
cats/
cat001.jpg
cat002.jpg
...
validation/
dogs/
dog001.jpg
dog002.jpg
...
cats/
cat001.jpg
cat002.jpg
...
```
'''
from PIL import Image
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
from keras import backend as K


# dimensions of our images.
img_width, img_height = 150, 150

train_data_dir = '/home/rahul/th_data/train'
validation_data_dir = '/home/rahul/th_data/validation'
nb_train_samples = 2780
nb_validation_samples = 740
epochs = 16
batch_size = 10

if K.image_data_format() == 'channels_first':
input_shape = (3, img_width, img_height)
else:
input_shape = (img_width, img_height, 3)

model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=input_shape))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Flatten())
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(1))
model.add(Activation('sigmoid'))

model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])

# this is the augmentation configuration we will use for training
train_datagen = ImageDataGenerator(
rescale=1. / 255,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True)

# this is the augmentation configuration we will use for testing:
# only rescaling
test_datagen = ImageDataGenerator(rescale=1. / 255)

train_generator = train_datagen.flow_from_directory(
train_data_dir,
target_size=(img_width, img_height),
batch_size=batch_size,
class_mode='binary')

validation_generator = test_datagen.flow_from_directory(
validation_data_dir,
target_size=(img_width, img_height),
batch_size=batch_size,
class_mode='binary')

model.fit_generator(
train_generator,
steps_per_epoch=nb_train_samples // batch_size,
epochs=epochs,
validation_data=validation_generator,
validation_steps=nb_validation_samples // batch_size)

model.save_weights('first_try.h5')
model.save('first_try_model.h5')
Binary file added first_model.py - Shortcut.lnk
Binary file not shown.
Loading