usamaalam commited on
Commit
0ceb664
·
1 Parent(s): 54ee03a

Fix ELA computation to match train.py (ImageChops.multiply, not Brightness)

Browse files

The model trained on attenuated/dark ELA images (multiply divides by 255),
but app.py was amplifying them via Brightness.enhance, causing every image
to saturate the ELA branch and predict FORGED.

Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -20,7 +20,12 @@ def compute_ela(original, quality=ELA_QUALITY, scale=ELA_SCALE):
20
  compressed = Image.open(buf)
21
 
22
  ela_image = ImageChops.difference(original, compressed)
23
- ela_image = ImageEnhance.Brightness(ela_image).enhance(scale)
 
 
 
 
 
24
  return ela_image
25
 
26
  def get_gradcam(model, input_data):
 
20
  compressed = Image.open(buf)
21
 
22
  ela_image = ImageChops.difference(original, compressed)
23
+ # Must match train.py exactly: ImageChops.multiply divides by 255 internally,
24
+ # so this attenuates (diff * scale / 255) rather than amplifies. The model was
25
+ # trained on these dark ELA images — using Brightness.enhance here breaks it.
26
+ ela_image = ImageChops.multiply(
27
+ ela_image, Image.new('RGB', ela_image.size, (scale, scale, scale))
28
+ )
29
  return ela_image
30
 
31
  def get_gradcam(model, input_data):