ttoosi commited on
Commit
64114f8
·
verified ·
1 Parent(s): 3529ca1

Update inference.py

Browse files
Files changed (1) hide show
  1. inference.py +9 -5
inference.py CHANGED
@@ -694,12 +694,16 @@ class GenerativeInferenceModel:
694
 
695
  # Prepare image tensor - match original code's conditional transform
696
  load_start = time.time()
697
- use_norm = config['inference_normalization'] == 'on'
 
 
 
 
698
  custom_transform = get_transform(
699
- input_size=224,
700
- normalize=use_norm,
701
- norm_mean=IMAGENET_MEAN,
702
- norm_std=IMAGENET_STD
703
  )
704
 
705
  # Special handling for GradModulation as in original
 
694
 
695
  # Prepare image tensor - match original code's conditional transform
696
  load_start = time.time()
697
+ # Pick the right preproc for this model
698
+ pre = self.model_preproc.get(model_type, {"size": 224, "mean": IMAGENET_MEAN, "std": IMAGENET_STD})
699
+
700
+ # IMPORTANT: the model already includes a NormalizeByChannelMeanStd as layer 0,
701
+ # so do NOT normalize again here, or you’ll double-normalize.
702
  custom_transform = get_transform(
703
+ input_size=pre["size"], # 112 for resnet50_robust_face
704
+ normalize=False, # leave False; model handles normalization internally
705
+ norm_mean=pre["mean"],
706
+ norm_std=pre["std"]
707
  )
708
 
709
  # Special handling for GradModulation as in original