dk00069 commited on
Commit
9944d31
·
verified ·
1 Parent(s): 3857185

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -6,8 +6,23 @@ import numpy as np
6
  import tensorflow as tf
7
  from PIL import Image
8
 
9
- model_path = "waste_classifier_final_fixed.h5"
10
- model = tf.keras.models.load_model(model_path, compile=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  labels = ["Cardboard", "Glass", "Metal", "Paper", "Plastic", "Trash"]
13
 
 
6
  import tensorflow as tf
7
  from PIL import Image
8
 
9
+ # Custom fix for batch_shape compatibility
10
+ from tensorflow.keras.layers import InputLayer
11
+
12
+ class CompatibleInputLayer(InputLayer):
13
+ def __init__(self, *args, **kwargs):
14
+ kwargs.pop('batch_shape', None)
15
+ kwargs.pop('optional', None)
16
+ super().__init__(*args, **kwargs)
17
+
18
+ # Load model with custom object
19
+ model_path = "waste_classifier_patched.h5"
20
+ model = tf.keras.models.load_model(
21
+ model_path,
22
+ compile=False,
23
+ custom_objects={"InputLayer": CompatibleInputLayer}
24
+ )
25
+ print("✅ Model loaded!")
26
 
27
  labels = ["Cardboard", "Glass", "Metal", "Paper", "Plastic", "Trash"]
28