This commit is contained in:
wangobango 2021-11-28 21:00:52 +01:00
parent 8833430697
commit addd9af657

View File

@ -5,7 +5,7 @@ from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
def preprocess(img):
scale_percent = 15
scale_percent = 10
width = int(img.shape[1] * scale_percent / 100)
height = int(img.shape[0] * scale_percent / 100)
dim = (width, height)
@ -16,7 +16,7 @@ def preprocess(img):
def readData(data_links):
x, y = [], []
for link in data_links:
img = cv2.imread(link, cv2.IMREAD_GRAYSCALE)
img = cv2.imread(link, cv2.IMREAD_COLOR)
img = preprocess(img)
label = link.split("/")[1].split('_')[1]
x.append(img)
@ -31,8 +31,8 @@ x, y = readData(data_links)
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=42)
clf = MLPClassifier(solver='adam', alpha=1e-5, hidden_layer_sizes=(1000, 500, 500), random_state=1,
activation='relu', batch_size='auto', shuffle=True, verbose=True)
clf = MLPClassifier(solver='adam', alpha=1e-5, hidden_layer_sizes=(1000, 700), random_state=1,
activation='relu', batch_size='auto', shuffle=True, verbose=True, learning_rate='adaptive', n_iter_no_change=10)
clf.fit(X_train, y_train)
print("Score:")