Answer the question
In order to leave comments, you need to log in
Why don't losses decrease?
Good day, there is a model:
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation="relu", input_shape=(218, 178, 3)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation="relu"))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(128, (3, 3), activation="relu"))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(128, (3, 3), activation="relu"))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Flatten())
model.add(layers.Dense(512, activation="relu"))
model.add(layers.Dense(4, activation="sigmoid"))
model.compile(optimizer="rmsprop", loss="mse")
train_dir = "../path/to/train/images"
images= []
coordinates = []
with open("../path/images_boxes.csv") as file:
for ii, i in enumerate(file.readlines()[1:2001]):
if ii % 100 == 0:
print("=====Creating", ii, "images=====")
info = i.replace("\n", "").split(",")
# где i представляет собой следующее:
# 000001.jpg,95,71,226,313
# то есть структура такая:
# image_id,x_1,y_1,width,height
images.append(img_to_array(load_img(os.path.join(train_dir, info[0]))))
# где train_dir/info[n] представляет собой путь до изображения
coordinates.append([point for point in info[1:]])
images= np.array(images, dtype="float32") / 255.0
coordinates = np.array(coordinates, dtype="float32")
train_images, test_images = images[:1500], images[1500:]
train_coordinates, test_coordinates = coordinates[:1500], coordinates[1500:]
model.fit(train_images, train_coordinates, validation_data=(test_images, test_coordinates), batch_size=20, epochs=5, verbose=1)
model.save("model.h5")
Answer the question
In order to leave comments, you need to log in
You accept applications for payments on the site, save them to the database, and withdraw them manually.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question