BunkerMinecraft commited on
Commit
f2515f3
·
verified ·
1 Parent(s): 7879302

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -16,12 +16,13 @@ if os.path.exists("config.json"):
16
  class_names = ['battery', 'glass', 'metal', 'organic', 'paper', 'plastic']
17
 
18
  # ---- Build model architecture ----
19
- '''
20
  base_model = tf.keras.applications.EfficientNetB7(
21
- weights=None,
22
  include_top=False,
23
  input_shape=(224, 224, 3)
24
  )
 
 
25
  model = models.Sequential([
26
  base_model,
27
  layers.GlobalAveragePooling2D(),
@@ -31,17 +32,13 @@ model = models.Sequential([
31
  layers.Dropout(0.3),
32
  layers.Dense(6, activation='softmax')
33
  ])
34
- '''
35
 
36
  # ---- Load trained weights ----
37
- '''
38
  if os.path.exists("model_weights.h5"):
39
  model.load_weights("model_weights.h5")
40
  print("Weights loaded successfully.")
41
  else:
42
  print("model_weights.h5 not found! Current directory:", os.listdir())
43
- '''
44
- model = tf.keras.models.load_model("model_weights.h5")
45
 
46
  # ---- Preprocess image ----
47
  def preprocess(image: Image.Image):
 
16
  class_names = ['battery', 'glass', 'metal', 'organic', 'paper', 'plastic']
17
 
18
  # ---- Build model architecture ----
 
19
  base_model = tf.keras.applications.EfficientNetB7(
20
+ weights='imagenet',
21
  include_top=False,
22
  input_shape=(224, 224, 3)
23
  )
24
+ base_model.trainable = False
25
+
26
  model = models.Sequential([
27
  base_model,
28
  layers.GlobalAveragePooling2D(),
 
32
  layers.Dropout(0.3),
33
  layers.Dense(6, activation='softmax')
34
  ])
 
35
 
36
  # ---- Load trained weights ----
 
37
  if os.path.exists("model_weights.h5"):
38
  model.load_weights("model_weights.h5")
39
  print("Weights loaded successfully.")
40
  else:
41
  print("model_weights.h5 not found! Current directory:", os.listdir())
 
 
42
 
43
  # ---- Preprocess image ----
44
  def preprocess(image: Image.Image):