Spaces:
Runtime error
Runtime error
Update forensics/ela_hybrid.py
Browse files- forensics/ela_hybrid.py +10 -10
forensics/ela_hybrid.py
CHANGED
|
@@ -61,20 +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 |
-
def generate_hybrid_ela_func(
|
| 66 |
"""
|
| 67 |
-
Returns a list of
|
| 68 |
-
This matches the structure of other forensic tools.
|
| 69 |
"""
|
| 70 |
from PIL import Image
|
|
|
|
| 71 |
|
| 72 |
-
#
|
| 73 |
-
if
|
| 74 |
-
|
| 75 |
|
| 76 |
-
|
|
|
|
| 77 |
visualizations = visualize_hybrid(hybrid_array)
|
| 78 |
-
|
| 79 |
-
# Return list of PIL Images for Gradio compatibility
|
| 80 |
-
return visualizations
|
|
|
|
| 61 |
ela_image = Image.fromarray((hybrid_array[:, :, 3:] * 255).astype(np.uint8))
|
| 62 |
|
| 63 |
return [rgb_image, ela_image]
|
| 64 |
+
# ela_hybrid.py
|
| 65 |
|
| 66 |
+
def generate_hybrid_ela_func(img_input):
|
| 67 |
"""
|
| 68 |
+
Returns a list of 2 PIL Images: [Original RGB Image, Hybrid ELA Output].
|
|
|
|
| 69 |
"""
|
| 70 |
from PIL import Image
|
| 71 |
+
import numpy as np
|
| 72 |
|
| 73 |
+
# Convert input to numpy array if needed
|
| 74 |
+
if not isinstance(img_input, np.ndarray):
|
| 75 |
+
img_input = np.array(img_input) # Ensure numpy format
|
| 76 |
|
| 77 |
+
# Generate ELA
|
| 78 |
+
hybrid_array = generate_ela_hybrid(img_input, quality=75, scale_factor=100)
|
| 79 |
visualizations = visualize_hybrid(hybrid_array)
|
| 80 |
+
return list(visualizations) # Returns [RGB PIL Image, ELA PIL Image]
|
|
|
|
|
|