drankush-ai commited on
Commit
805baa7
·
verified ·
1 Parent(s): 98da1e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py CHANGED
@@ -277,6 +277,40 @@ try:
277
 
278
  print("=== End Custom ZNormalization ===\n")
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  # Replace the encodes method
281
  ZNormalization.encodes = patched_encodes
282
  print("✅ Applied ZNormalization patch to handle missing attributes in encodes method")
 
277
 
278
  print("=== End Custom ZNormalization ===\n")
279
 
280
+ # Add PadOrCrop debug prints
281
+ from fastMONAI.vision_augmentation import PadOrCrop
282
+ original_padorcrop_encodes = PadOrCrop.encodes
283
+
284
+ def patched_padorcrop_encodes(self, o):
285
+ """Patched version of PadOrCrop.encodes with debug prints."""
286
+ print("\n=== PadOrCrop Debug ===")
287
+ print(f"Input type: {type(o)}")
288
+ if hasattr(o, 'shape'): print(f"Input shape: {o.shape}")
289
+
290
+ # Safely get attributes with fallbacks
291
+ target_shape = getattr(self, 'size', o.shape[1:]) # Default to input shape
292
+ padding_mode = getattr(self, 'padding_mode', 'constant')
293
+ mask_name = getattr(self, 'mask_name', None)
294
+
295
+ print(f"Target shape: {target_shape}")
296
+ print(f"Padding mode: {padding_mode}")
297
+ print(f"Mask name: {mask_name}")
298
+
299
+ try:
300
+ result = original_padorcrop_encodes(self, o)
301
+ print(f"Output type: {type(result)}")
302
+ if hasattr(result, 'shape'): print(f"Output shape: {result.shape}")
303
+ return result
304
+ except Exception as e:
305
+ print(f"Error in PadOrCrop: {str(e)}")
306
+ print("Fallback - returning input as-is")
307
+ return o
308
+
309
+ print("=== End PadOrCrop Debug ===\n")
310
+
311
+ PadOrCrop.encodes = patched_padorcrop_encodes
312
+ print("✅ Applied PadOrCrop patch with debug prints")
313
+
314
  # Replace the encodes method
315
  ZNormalization.encodes = patched_encodes
316
  print("✅ Applied ZNormalization patch to handle missing attributes in encodes method")