LPX55 commited on
Commit
999d675
Β·
2 Parent(s): ab4bfd9 ba1f85f

Merge remote-tracking branch 'upstream/main' into main

Browse files
Files changed (2) hide show
  1. README.md +2 -2
  2. app_mcp.old.py +82 -0
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
- title: MCP Toolkit - Deepfake Detection & Forensics
3
- description: MCP Server for Deepfake Detection & Digital Forensics Tools
4
  emoji: πŸš‘
5
  colorFrom: yellow
6
  colorTo: yellow
 
1
  ---
2
+ title: MCP Toolkit - Re-Thinking Deepfake Detection & Forensics
3
+ description: MCP Server for Project OpenSight's Deepfake Detection & Digital Forensics Tools
4
  emoji: πŸš‘
5
  colorFrom: yellow
6
  colorTo: yellow
app_mcp.old.py CHANGED
@@ -485,6 +485,88 @@ def simple_prediction(img):
485
  api_name="/simple_predict"
486
  )
487
  return result
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488
 
489
  with gr.Blocks(css="#post-gallery { overflow: hidden !important;} .grid-wrap{ overflow-y: hidden !important;} .ms-gr-ant-welcome-icon{ height:unset !important;} .tabs{margin-top:10px;}") as demo:
490
 
 
485
  api_name="/simple_predict"
486
  )
487
  return result
488
+ with gr.Blocks(css="#post-gallery { overflow: hidden !important;} .grid-wrap{ overflow-y: hidden !important;} .ms-gr-ant-welcome-icon{ height:unset !important;} .tabs{margin-top:10px;}") as demo:
489
+ with ms.Application() as app:
490
+ with antd.ConfigProvider():
491
+ antdx.Welcome(
492
+ icon="https://cdn-avatars.huggingface.co/v1/production/uploads/639daf827270667011153fbc/WpeSFhuB81DY-1TjNUmV_.png",
493
+ title="Welcome to Project OpenSight",
494
+ description="The OpenSight aims to be an open-source SOTA generated image detection model. This HF Space is not only an introduction but a educational playground for the public to evaluate and challenge current open source models. **Space will be upgraded shortly; inference on all 6 models should take about 1.2~ seconds.** "
495
+ )
496
+ with gr.Tab("πŸ‘€ Rethinking Detection Models: Multi-Model, Multi-Strategy Ensemble Team and Agentic Pipelines"):
497
+ gr.Markdown("# Open Source Detection Models Found on the Hub\n\n - **IMPORTANT UPDATE REGARDING YOUR DATA AND PRIVACY: [PLEASE REFER TO THE MCP SERVER HACKATHON SUBMISSION FOR CRUCIAL DETAILS](https://huggingface.co/spaces/Agents-MCP-Hackathon/mcp-deepfake-forensics).** ")
498
+
499
+ with gr.Row():
500
+ with gr.Column(scale=1):
501
+ image_input = gr.Image(label="Upload Image to Analyze", sources=['upload', 'webcam'], type='pil')
502
+ with gr.Accordion("Settings (Optional)", open=False, elem_id="settings_accordion"):
503
+ augment_checkboxgroup = gr.CheckboxGroup(["rotate", "add_noise", "sharpen"], label="Augmentation Methods")
504
+ rotate_slider = gr.Slider(0, 45, value=2, step=1, label="Rotate Degrees", visible=False)
505
+ noise_slider = gr.Slider(0, 50, value=4, step=1, label="Noise Level", visible=False)
506
+ sharpen_slider = gr.Slider(0, 50, value=11, step=1, label="Sharpen Strength", visible=False)
507
+ confidence_slider = gr.Slider(0.0, 1.0, value=0.75, step=0.05, label="Confidence Threshold")
508
+ inputs = [image_input, confidence_slider, augment_checkboxgroup, rotate_slider, noise_slider, sharpen_slider]
509
+ predict_button = gr.Button("Predict")
510
+ augment_button = gr.Button("Augment & Predict")
511
+ image_output = gr.Image(label="Processed Image", visible=False)
512
+
513
+
514
+ with gr.Column(scale=2):
515
+ # Use Gradio-native Dataframe to display results with headers
516
+ results_table = gr.Dataframe(
517
+ label="Model Predictions",
518
+ headers=["Model", "Contributor", "AI Score", "Real Score", "Label"],
519
+ datatype=["str", "str", "number", "number", "str"]
520
+ )
521
+ forensics_gallery = gr.Gallery(label="Post Processed Images", visible=True, columns=[4], rows=[2], container=False, height="auto", object_fit="contain", elem_id="post-gallery")
522
+ with gr.Accordion("Debug Output (Raw JSON)", open=False):
523
+ debug_json = gr.JSON(label="Raw Model Results")
524
+ consensus_md = gr.Markdown(label="Consensus", value="")
525
+
526
+ outputs = [image_output, forensics_gallery, results_table, debug_json, consensus_md]
527
+
528
+ # Show/hide rotate slider based on selected augmentation method
529
+ augment_checkboxgroup.change(lambda methods: gr.update(visible="rotate" in methods), inputs=[augment_checkboxgroup], outputs=[rotate_slider])
530
+ augment_checkboxgroup.change(lambda methods: gr.update(visible="add_noise" in methods), inputs=[augment_checkboxgroup], outputs=[noise_slider])
531
+ augment_checkboxgroup.change(lambda methods: gr.update(visible="sharpen" in methods), inputs=[augment_checkboxgroup], outputs=[sharpen_slider])
532
+
533
+ predict_button.click(
534
+ fn=predict_image_with_json,
535
+ inputs=inputs,
536
+ outputs=outputs,
537
+ api_name="/predict"
538
+ )
539
+ augment_button.click( # Connect Augment button to the function
540
+ fn=predict_image_with_json,
541
+ inputs=[
542
+ image_input,
543
+ confidence_slider,
544
+ gr.CheckboxGroup(["rotate", "add_noise", "sharpen"], value=["rotate", "add_noise", "sharpen"], visible=False), # Default values
545
+ rotate_slider,
546
+ noise_slider,
547
+ sharpen_slider
548
+ ],
549
+ outputs=outputs,
550
+ api_name="/augment"
551
+ )
552
+ with gr.Tab("πŸ™ˆ Project Introduction"):
553
+ gr.Markdown(QUICK_INTRO)
554
+
555
+ with gr.Tab("πŸ‘‘ Community Forensics Preview"):
556
+ # temp_space = gr.load("aiwithoutborders-xyz/OpenSight-Community-Forensics-Preview", src="spaces")
557
+ gr.Markdown("Community Forensics Preview coming soon!") # Placeholder for now
558
+ with gr.Tab("πŸ₯‡ Leaderboard"):
559
+ gr.Markdown("# AI Generated / Deepfake Detection Models Leaderboard: Soonβ„’")
560
+
561
+ with gr.Tab("Wavelet Blocking Noise Estimation", visible=False):
562
+ gr.Interface(
563
+ fn=wavelet_blocking_noise_estimation,
564
+ inputs=[gr.Image(type="pil"), gr.Slider(1, 32, value=8, step=1, label="Block Size")],
565
+ outputs=gr.Image(type="pil"),
566
+ title="Wavelet-Based Noise Analysis",
567
+ description="Analyzes image noise patterns using wavelet decomposition. This tool helps detect compression artifacts and artificial noise patterns that may indicate image manipulation. Higher noise levels in specific regions can reveal areas of potential tampering.",
568
+ api_name="/tool_waveletnoise"
569
+ )
570
 
571
  with gr.Blocks(css="#post-gallery { overflow: hidden !important;} .grid-wrap{ overflow-y: hidden !important;} .ms-gr-ant-welcome-icon{ height:unset !important;} .tabs{margin-top:10px;}") as demo:
572