dannyroxas commited on
Commit
a5d9072
·
verified ·
1 Parent(s): 7759203

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -44,9 +44,13 @@ class MultiAttributeClassifier:
44
  except Exception as e1:
45
  print(f" ⚠️ Normal loading failed: {e1}")
46
  try:
47
- # Try with compile=False
48
- self.models[category] = tf.keras.models.load_model(model_path, compile=False)
49
- print(f" ✅ Loaded {category} with compile=False")
 
 
 
 
50
  except Exception as e2:
51
  print(f" ❌ Failed to load {category}: {e2}")
52
  continue
@@ -157,15 +161,17 @@ class MultiAttributeClassifier:
157
  except Exception as e2:
158
  print(f" ⚠️ compile=False failed: {e2}")
159
  try:
160
- # Third try: Load with custom objects (for any custom layers)
161
  self.gan_models[model_name] = tf.keras.models.load_model(
162
  model_path,
163
  compile=False,
164
- custom_objects={'tf': tf}
165
  )
166
- print(f" ✅ Loaded with custom_objects")
167
  except Exception as e3:
168
  print(f" ❌ All loading methods failed: {e3}")
 
 
169
  raise e3
170
 
171
  print(f"✅ Loaded GAN: {model_name} from {model_path}")
 
44
  except Exception as e1:
45
  print(f" ⚠️ Normal loading failed: {e1}")
46
  try:
47
+ # Try with compile=False and custom objects
48
+ self.models[category] = tf.keras.models.load_model(
49
+ model_path,
50
+ compile=False,
51
+ custom_objects=CUSTOM_OBJECTS
52
+ )
53
+ print(f" ✅ Loaded {category} with custom_objects")
54
  except Exception as e2:
55
  print(f" ❌ Failed to load {category}: {e2}")
56
  continue
 
161
  except Exception as e2:
162
  print(f" ⚠️ compile=False failed: {e2}")
163
  try:
164
+ # Third try: Load with custom objects (CRITICAL for your models)
165
  self.gan_models[model_name] = tf.keras.models.load_model(
166
  model_path,
167
  compile=False,
168
+ custom_objects=CUSTOM_OBJECTS
169
  )
170
+ print(f" ✅ Loaded with custom_objects (InstanceNormalization)")
171
  except Exception as e3:
172
  print(f" ❌ All loading methods failed: {e3}")
173
+ # Print the actual error for debugging
174
+ print(f" 🔍 Error details: {str(e3)}")
175
  raise e3
176
 
177
  print(f"✅ Loaded GAN: {model_name} from {model_path}")