CoolFace
Apppublic

Jamari/promptable-content-moderation

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
App README

Promptable Content Moderation with Moondream

Welcome to the future of content moderation with Moondream 2B, a powerful and lightweight vision-language model that enables detection and moderation of video content using natural language prompts.

Try it now.

Features

  • Content moderation through natural language prompts
  • Multiple visualization styles
  • Intelligent scene detection and tracking:
  • DeepSORT tracking with scene-aware reset
  • Persistent moderation across frames
  • Smart tracker reset at scene boundaries
  • Optional grid-based detection for improved accuracy on complex scenes
  • Frame-by-frame processing with IoU-based merging
  • Web-compatible output format
  • Test mode (process only first X seconds)
  • Advanced moderation analysis with multiple visualization plots

Examples

PromptOutput
"white cigarette"[image]
"gun"[image]
"confederate flag"[image]

Requirements

Python Dependencies

For Windows users, before installing other requirements, first install PyTorch with CUDA support:

bash
pip install torch==2.5.1+cu121 torchvision==0.20.1+cu121 --index-url https://download.pytorch.org/whl/cu121

Then install the remaining dependencies:

bash
pip install -r requirements.txt

System Requirements

  • FFmpeg (required for video processing)
  • libvips (required for image processing)

Installation by platform:

Installation

  1. 1.Clone this repository and create a new virtual environment:
bash
git clone https://github.com/vikhyat/moondream/blob/main/recipes/promptable-video-redaction
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. 1.Install Python dependencies:
bash
pip install -r requirements.txt
  1. 1.Install ffmpeg and libvips:
  2. 2.On Ubuntu/Debian: sudo apt-get install ffmpeg libvips
  3. 3.On macOS: brew install ffmpeg
  4. 4.On Windows: Download from ffmpeg.org
Downloading libvips for Windows requires some additional steps, see here

Usage

The easiest way to use this tool is through its web interface, which provides a user-friendly experience for video content moderation.

Web Interface

  1. 1.Start the web interface:
bash
python app.py
  1. 1.Open the provided URL in your browser (typically <http://localhost:7860>)
  1. 1.Use the interface to:
  2. 2.Upload your video file
  3. 3.Specify content to moderate (e.g., "face", "cigarette", "gun")
  4. 4.Choose redaction style (default: obfuscated-pixel)
  5. 5.OPTIONAL: Configure advanced settings
  6. 6.Processing speed/quality
  7. 7.Grid size for detection
  8. 8.Test mode for quick validation (default: on, 3 seconds)
  9. 9.Process the video and download results
  10. 10.Analyze detection patterns with visualization tools

Output Files

The tool generates two types of output files in the outputs directory:

  1. 1.Processed Videos:
  2. 2.Format: [style]_[content_type]_[original_filename].mp4
  3. 3.Example: censor_inappropriate_video.mp4
  1. 1.Detection Data:
  2. 2.Format: [style]_[content_type]_[original_filename]_detections.json
  3. 3.Contains frame-by-frame detection information
  4. 4.Used for visualization and analysis

Technical Details

Scene Detection and Tracking

The tool uses advanced scene detection and object tracking:

  1. 1.Scene Detection:
  2. 2.Powered by PySceneDetect's ContentDetector
  3. 3.Automatically identifies scene changes in videos
  4. 4.Configurable detection threshold (default: 30.0)
  5. 5.Helps maintain tracking accuracy across scene boundaries
  1. 1.Object Tracking:
  2. 2.DeepSORT tracking for consistent object identification
  3. 3.Automatic tracker reset at scene changes
  4. 4.Maintains object identity within scenes
  5. 5.Prevents tracking errors across scene boundaries
  1. 1.Integration Benefits:
  2. 2.More accurate object tracking
  3. 3.Better handling of scene transitions
  4. 4.Reduced false positives in tracking
  5. 5.Improved tracking consistency

Best Practices

  • Use test mode for initial configuration
  • Enable grid-based detection for complex scenes
  • Choose appropriate redaction style based on content type:
  • Censor: Complete content blocking
  • Blur styles: Less intrusive moderation
  • Bounding Box: Content review and analysis
  • Monitor system resources during processing
  • Use appropriate processing quality settings based on your needs

Notes

  • Processing time depends on video length, resolution, GPU availability, and chosen settings
  • GPU is strongly recommended for faster processing
  • Grid-based detection increases accuracy but requires more processing time (each grid cell is processed independently)
  • Test mode processes only first X seconds (default: 3 seconds) for quick validation