forked from sagarvegad/Video-Classification-CNN-and-LSTM-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_test_images.py
41 lines (37 loc) · 1.73 KB
/
create_test_images.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import numpy as np
import os
import pandas as pd
import cv2
from scipy.misc import imread,imresize
import pickle
parent = os.listdir("/Users/svdj16/Documents/6_sem_mini_project/video/test")
x = []
y = []
count = 0
output = 0
for video_class in parent[1:]:
print video_class
child = os.listdir("/Users/svdj16/Documents/6_sem_mini_project/video/test" + "/" + video_class)
for class_i in child[1:]:
sub_child = os.listdir("/Users/svdj16/Documents/6_sem_mini_project/video/test" + "/" + video_class + "/" + class_i)
for image_fol in sub_child[1:]:
if (video_class == 'class_4' ):
if(count%4 == 0): #(selected images at gap of 4)
image = imread("/Users/svdj16/Documents/6_sem_mini_project/video/test" + "/" + video_class + "/" + class_i + "/" + image_fol)
image = imresize(image , (224,224))
x.append(image)
y.append(output)
cv2.imwrite('/Users/svdj16/Documents/6_sem_mini_project/video/validate/' + video_class + '/' + str(count) + '_' + image_fol,image)
count+=1
else:
if(count%8 == 0):
image = imread("/Users/svdj16/Documents/6_sem_mini_project/video/test" + "/" + video_class + "/" + class_i + "/" + image_fol)
image = imresize(image , (224,224))
x.append(image)
y.append(output)
cv2.imwrite('/Users/svdj16/Documents/6_sem_mini_project/video/validate/' + video_class + '/' + str(count) + '_' + image_fol,image)
count+=1
output+=1
x = np.array(x)
y = np.array(y)
print("x",len(x),"y",len(y))