Update forensics/ela_hybrid.py
Browse files- forensics/ela_hybrid.py +16 -5
forensics/ela_hybrid.py
CHANGED
@@ -61,9 +61,20 @@ def visualize_hybrid(hybrid_array: np.ndarray):
|
|
61 |
ela_image = Image.fromarray((hybrid_array[:, :, 3:] * 255).astype(np.uint8))
|
62 |
|
63 |
return [rgb_image, ela_image]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
return
|
|
|
61 |
ela_image = Image.fromarray((hybrid_array[:, :, 3:] * 255).astype(np.uint8))
|
62 |
|
63 |
return [rgb_image, ela_image]
|
64 |
+
|
65 |
+
def generate_hybrid_ela_func(img_np_og, description, quality=95, scale_factor=150):
|
66 |
+
"""
|
67 |
+
Returns a list of two PIL Images: one for RGB, one for ELA map.
|
68 |
+
This matches the structure of other forensic tools.
|
69 |
+
"""
|
70 |
+
from PIL import Image
|
71 |
+
|
72 |
+
# Ensure the image is in RGB numpy format
|
73 |
+
if img_np_og.ndim == 2:
|
74 |
+
img_np_og = cv2.cvtColor(img_np_og, cv2.COLOR_GRAY2RGB)
|
75 |
|
76 |
+
hybrid_array = generate_ela_hybrid(img_np_og, quality=quality, scale_factor=scale_factor)
|
77 |
+
visualizations = visualize_hybrid(hybrid_array)
|
78 |
+
|
79 |
+
# Return list of PIL Images for Gradio compatibility
|
80 |
+
return visualizations
|