File size: 1,379 Bytes
a04f9f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

import time

import autokeras as ak

import tensorflow as tf




import numpy as np

neutral = np.load ("./neutral/img_emb/img_emb_0.npy")
print(neutral.shape)

porn = np.load ("./porn/img_emb/img_emb_0.npy")
print(porn.shape)

drawings = np.load ("./drawings/img_emb/img_emb_0.npy")
print(drawings.shape)

hentai = np.load ("./hentai/img_emb/img_emb_0.npy")
print(hentai.shape)

sexy = np.load ("./sexy/img_emb/img_emb_0.npy")
print(sexy.shape)



x_t =np.concatenate((porn,sexy),axis = 0)
x_t =np.concatenate((x_t,hentai),axis = 0)
nsfw_t_len=x_t.shape[0]
print(nsfw_t_len)
x_t =np.concatenate((x_t,neutral),axis = 0)
x_t =np.concatenate((x_t,drawings),axis = 0)
y_t = np.zeros(x_t.shape[0], dtype = np.uint8)
sfw_t_len=x_t.shape[0] - nsfw_t_len
print(sfw_t_len)

for i in range(nsfw_t_len):
  y_t[i]=1
from sklearn.utils import shuffle
x_train, y_train = shuffle(x_t, y_t)


print(y_t)
print(y_train)







x_train = x_train.astype(float) #[100:-100]
y_train = y_train.astype(int)#[100:-100]


#x_test = x_test.astype(float) #[100:-100]
#y_test = y_test.astype(int)#[100:-100]


# It tries 10 different models.
clf = ak.StructuredDataClassifier(overwrite=True, max_trials=5)

# Feed the structured data classifier with training data.
clf.fit(x_train, y_train, epochs=10, validation_split=0.1)

model = clf.export_model()
model.summary()




model.save("clip_autokeras_nsfw")