LPX
commited on
Commit
·
a7003f1
1
Parent(s):
62c8661
refactor: ensemble monitoring and weight optimization agents, refactor minmax processing function, and update requirements
Browse files- agents/{monitoring_agents.py → ensemble_team.py} +0 -0
- agents/{weight_management.py → ensemble_weights.py} +0 -0
- app_mcp.py +5 -5
- requirements.txt +2 -1
- utils/minmax.py +13 -1
agents/{monitoring_agents.py → ensemble_team.py}
RENAMED
File without changes
|
agents/{weight_management.py → ensemble_weights.py}
RENAMED
File without changes
|
app_mcp.py
CHANGED
@@ -12,17 +12,17 @@ import io
|
|
12 |
import logging
|
13 |
from utils.utils import softmax, augment_image, convert_pil_to_bytes
|
14 |
from utils.gradient import gradient_processing
|
15 |
-
from utils.minmax import
|
16 |
from utils.ela import genELA as ELA
|
17 |
from utils.wavelet import wavelet_blocking_noise_estimation
|
18 |
from utils.bitplane import bit_plane_extractor
|
19 |
from utils.hf_logger import log_inference_data
|
20 |
from utils.text_content import QUICK_INTRO, IMPLEMENTATION
|
21 |
-
from agents.
|
22 |
from agents.smart_agents import ContextualIntelligenceAgent, ForensicAnomalyDetectionAgent
|
23 |
|
24 |
from forensics.registry import register_model, MODEL_REGISTRY, ModelEntry
|
25 |
-
from agents.
|
26 |
from dotenv import load_dotenv
|
27 |
import json
|
28 |
from huggingface_hub import CommitScheduler
|
@@ -361,7 +361,7 @@ def predict_image_with_json(img, confidence_threshold, augment_methods, rotate_d
|
|
361 |
|
362 |
# 6. Perform forensic processing
|
363 |
gradient_image = gradient_processing(img_np_og) # Added gradient processing
|
364 |
-
minmax_image =
|
365 |
bitplane_image = bit_plane_extractor(img_np_og)
|
366 |
|
367 |
|
@@ -617,7 +617,7 @@ with gr.Blocks(css="#post-gallery { overflow: hidden !important;} .grid-wrap{ ov
|
|
617 |
)
|
618 |
with gr.Tab("MinMax Processing", visible=False):
|
619 |
gr.Interface(
|
620 |
-
fn=
|
621 |
inputs=[
|
622 |
gr.Image(type="pil", label="Input Image"),
|
623 |
gr.Radio([0, 1, 2, 3, 4], label="Channel (0:Grayscale, 1:Blue, 2:Green, 3:Red, 4:RGB Norm)", value=4),
|
|
|
12 |
import logging
|
13 |
from utils.utils import softmax, augment_image, convert_pil_to_bytes
|
14 |
from utils.gradient import gradient_processing
|
15 |
+
from utils.minmax import minmax_process
|
16 |
from utils.ela import genELA as ELA
|
17 |
from utils.wavelet import wavelet_blocking_noise_estimation
|
18 |
from utils.bitplane import bit_plane_extractor
|
19 |
from utils.hf_logger import log_inference_data
|
20 |
from utils.text_content import QUICK_INTRO, IMPLEMENTATION
|
21 |
+
from agents.ensemble_team import EnsembleMonitorAgent, WeightOptimizationAgent, SystemHealthAgent
|
22 |
from agents.smart_agents import ContextualIntelligenceAgent, ForensicAnomalyDetectionAgent
|
23 |
|
24 |
from forensics.registry import register_model, MODEL_REGISTRY, ModelEntry
|
25 |
+
from agents.ensemble_weights import ModelWeightManager
|
26 |
from dotenv import load_dotenv
|
27 |
import json
|
28 |
from huggingface_hub import CommitScheduler
|
|
|
361 |
|
362 |
# 6. Perform forensic processing
|
363 |
gradient_image = gradient_processing(img_np_og) # Added gradient processing
|
364 |
+
minmax_image = minmax_process(img_np_og) # Added MinMax processing
|
365 |
bitplane_image = bit_plane_extractor(img_np_og)
|
366 |
|
367 |
|
|
|
617 |
)
|
618 |
with gr.Tab("MinMax Processing", visible=False):
|
619 |
gr.Interface(
|
620 |
+
fn=minmax_process,
|
621 |
inputs=[
|
622 |
gr.Image(type="pil", label="Input Image"),
|
623 |
gr.Radio([0, 1, 2, 3, 4], label="Channel (0:Grayscale, 1:Blue, 2:Green, 3:Red, 4:RGB Norm)", value=4),
|
requirements.txt
CHANGED
@@ -15,4 +15,5 @@ pyexiftool
|
|
15 |
psutil
|
16 |
datasets
|
17 |
Pillow
|
18 |
-
python-dotenv
|
|
|
|
15 |
psutil
|
16 |
datasets
|
17 |
Pillow
|
18 |
+
python-dotenv
|
19 |
+
smolagents[all]
|
utils/minmax.py
CHANGED
@@ -27,7 +27,19 @@ def blk_filter(img, radius):
|
|
27 |
)
|
28 |
return cv.normalize(result, None, 0, 127, cv.NORM_MINMAX, cv.CV_8UC1)
|
29 |
|
30 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
if not isinstance(image, np.ndarray):
|
32 |
image = np.array(image) # Ensure image is a NumPy array
|
33 |
if channel == 0:
|
|
|
27 |
)
|
28 |
return cv.normalize(result, None, 0, 127, cv.NORM_MINMAX, cv.CV_8UC1)
|
29 |
|
30 |
+
def minmax_process(image, channel=4, radius=2):
|
31 |
+
"""
|
32 |
+
Analyzes local pixel value deviations in an image to detect potential manipulation by comparing each pixel with its neighbors. This forensic technique helps identify areas where pixel values deviate significantly from their local context, which can indicate digital tampering or editing.
|
33 |
+
|
34 |
+
Args:
|
35 |
+
image: Union[np.ndarray, Image.Image]: Input image to process
|
36 |
+
channel (int): Channel to process (0:Grayscale, 1:Blue, 2:Green, 3:Red, 4:RGB Norm)
|
37 |
+
radius (int): Radius for block filtering
|
38 |
+
Returns:
|
39 |
+
PIL.Image.Image: The processed image showing minmax deviations.
|
40 |
+
Raises:
|
41 |
+
ValueError: If the input image is invalid or channel/radius parameters are out of valid range.
|
42 |
+
"""
|
43 |
if not isinstance(image, np.ndarray):
|
44 |
image = np.array(image) # Ensure image is a NumPy array
|
45 |
if channel == 0:
|