CoolFace
Apppublic

jithin14/SAM-2-RedSpiderMites

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

Hugging Face Gradio Demo: Red Spider Mite Detection

This application detects potential red spider mite infections on leaves in videos.

How it Works

  1. 1.Upload a video or select an example.
  2. 2.Click the "Detect" button.
  3. 3.The application processes every 100th frame.
  4. 4.It uses SAM 2 (Segment Anything Model 2) to generate masks for potential objects.
  5. 5.Masks are filtered based on:
  6. 6.Non-Maximum Suppression (NMS) to remove overlaps.
  7. 7.Aspect Ratio (to remove likely branches).
  8. 8.Color (HSV range check within the mask).
  9. 9.Sharpness (Laplacian variance).
  10. 10.Segments passing all filters are classified as 'Infected' or 'Not Infected' using a fine-tuned MobileNetV3 model.
  11. 11.Results are displayed in two galleries:
  12. 12.Top: Cropped images of the filtered leaf segments with their classification.
  13. 13.Bottom: Full processed frames showing bounding boxes around detected infected leaves.

Setup (Local)

  1. 1.Ensure Python 3.9+ is installed.
  2. 2.Clone the repository (if not already done).
  3. 3.Install dependencies: pip install -r requirements.txt
  4. 4.Run the app: python app.py
  5. 5.Open the local URL provided in your browser.

Files

  • app.py: Main Gradio application script.
  • requirements.txt: Python dependencies.
  • checkpoints/: Contains the SAM 2 model checkpoint.
  • models/: Contains the classification model.
  • sam2/: Contains the necessary SAM 2 library source code.
  • test_videos/: Contains example videos for the demo.
  • README.md: This file.
  • LICENSE: Copied license file.
  • .gitignore: Standard Python gitignore.