<jupyter_start><jupyter_text>- в обучающую выборку нужно добавить как можно больше примеров не руки, самый разный мусор, который они будут грузить- почистить руки и оставить только ладони<jupyter_code>### 10 изображений для 2х классов надо
train_datagen = ImageDataGenerator(rescale = 1./255,
                                   shear_range = 0.2,
                                   zoom_range = 0.2,
                                   horizontal_flip = True)

test_datagen = ImageDataGenerator(rescale = 1./255)

training_set = train_datagen.flow_from_directory('classifier_data/train',
                                                 target_size = (64, 64),
                                                 batch_size = 16,
                                                 class_mode = 'binary')

test_set = test_datagen.flow_from_directory('classifier_data/test',
                                            target_size = (64, 64),
                                            batch_size = 16,
                                            class_mode = 'binary')
classifier = Sequential()
classifier.add(Conv2D(32, (3, 3), input_shape = (64, 64, 3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Conv2D(32, (3, 3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Flatten())
classifier.add(Dense(units = 128, activation = 'relu'))
classifier.add(Dense(units = 1, activation = 'sigmoid'))
classifier.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy'])
classifier.fit_generator(training_set,
                         steps_per_epoch = 2,
                         epochs = 2,
                         validation_data = test_set,
                         validation_steps = 0)
classifier.save('models/classifier')
# classifier.evaluate_generator(test_set,steps=2)
def get_prediction(url):
    raw_test_image = image.load_img(url, target_size = (64, 64))
    test_image = image.img_to_array(raw_test_image)
    test_image = np.expand_dims(test_image, axis = 0)
    result = classifier.predict(test_image)
    if result[0][0] == 1:
        print('no')
    else:
        print('hand')
    display(raw_test_image)
files_1 = glob.glob('images/*')
files_2 = glob.glob('data/*')
files_3 = glob.glob('classifier_data/test_cd/dog/*')
files = files_1 + files_2 + files_3
files
for file in files:
    get_prediction(file)<jupyter_output>no
{'fraction_non_alphanumeric': 0.1085972850678733, 'fraction_numerical': 0.028794734677087618, 'mean_word_length': 2.183246073298429, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '558168', 'license': 'MIT', 'n_tokens_mistral': 784, 'n_tokens_neox': 738, 'n_words': 147, 'path': 'classifier.ipynb', 'repo_name': 'MNCTTY/palm_app', 'size': '2431'}