elang197 commited on
Commit
a8c3ae1
·
verified ·
1 Parent(s): 3e73f96

Update Dog_Training.py

Browse files
Files changed (1) hide show
  1. Dog_Training.py +5 -5
Dog_Training.py CHANGED
@@ -25,7 +25,7 @@ def load_images_from_folder(folder, img_size=(128, 128)):
25
  return np.array(images), np.array(labels)
26
 
27
 
28
- # Lade und verarbeite die Trainings- und Testdaten
29
  train_images, train_labels = load_images_from_folder('DataDogs')
30
  test_images, test_labels = load_images_from_folder('DataDogs')
31
 
@@ -34,7 +34,7 @@ label_encoder = LabelEncoder()
34
  train_labels_encoded = label_encoder.fit_transform(train_labels)
35
  test_labels_encoded = label_encoder.transform(test_labels)
36
 
37
- # Definiere das CNN-Modell
38
  model = Sequential([
39
  Conv2D(32, (3, 3), activation='relu', input_shape=(128, 128, 3)),
40
  MaxPooling2D((2, 2)),
@@ -48,13 +48,13 @@ model = Sequential([
48
  Dense(len(label_encoder.classes_), activation='softmax')
49
  ])
50
 
51
- # Kompiliere das Modell
52
  model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
53
 
54
- # Trainiere das Modell
55
  model.fit(train_images, train_labels_encoded, epochs=10, validation_data=(test_images, test_labels_encoded))
56
 
57
- # Speichere das trainierte Modell und den LabelEncoder
58
  model.save('dog_breed_classifier.h5')
59
 
60
  with open('label_encoder.pkl', 'wb') as f:
 
25
  return np.array(images), np.array(labels)
26
 
27
 
28
+ # training/test split
29
  train_images, train_labels = load_images_from_folder('DataDogs')
30
  test_images, test_labels = load_images_from_folder('DataDogs')
31
 
 
34
  train_labels_encoded = label_encoder.fit_transform(train_labels)
35
  test_labels_encoded = label_encoder.transform(test_labels)
36
 
37
+ # Modell definieren
38
  model = Sequential([
39
  Conv2D(32, (3, 3), activation='relu', input_shape=(128, 128, 3)),
40
  MaxPooling2D((2, 2)),
 
48
  Dense(len(label_encoder.classes_), activation='softmax')
49
  ])
50
 
51
+ # Modell Kompilieren
52
  model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
53
 
54
+ # das Modell Trainieren
55
  model.fit(train_images, train_labels_encoded, epochs=10, validation_data=(test_images, test_labels_encoded))
56
 
57
+ # das trainierte Modell und den LabelEncoder Speichern
58
  model.save('dog_breed_classifier.h5')
59
 
60
  with open('label_encoder.pkl', 'wb') as f: