{"id":28762244,"url":"https://github.com/armanshadyan/bacteria-detection","last_synced_at":"2026-04-05T08:32:45.163Z","repository":{"id":293859322,"uuid":"985337890","full_name":"ArmanShadyan/Bacteria-Detection","owner":"ArmanShadyan","description":"Deep learning-powered tool for detecting and analyzing bacteria in microscope images. Designed for microbiology research, it identifies bacteria, counts them, and calculates coverage area with high precision. Supports real-time video processing, single-image analysis, batch processing, and model training.","archived":false,"fork":false,"pushed_at":"2025-05-17T14:57:34.000Z","size":6888,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-17T08:07:33.077Z","etag":null,"topics":["mediapipe","numpy","object-detection","opencv","python","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ArmanShadyan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-17T14:53:15.000Z","updated_at":"2025-05-23T17:39:44.000Z","dependencies_parsed_at":"2025-05-17T15:47:30.961Z","dependency_job_id":null,"html_url":"https://github.com/ArmanShadyan/Bacteria-Detection","commit_stats":null,"previous_names":["armanshadyan/bacteria-detection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ArmanShadyan/Bacteria-Detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArmanShadyan%2FBacteria-Detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArmanShadyan%2FBacteria-Detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArmanShadyan%2FBacteria-Detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArmanShadyan%2FBacteria-Detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArmanShadyan","download_url":"https://codeload.github.com/ArmanShadyan/Bacteria-Detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArmanShadyan%2FBacteria-Detection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260318700,"owners_count":22991120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mediapipe","numpy","object-detection","opencv","python","pytorch"],"created_at":"2025-06-17T08:07:32.843Z","updated_at":"2025-10-12T02:15:56.377Z","avatar_url":"https://github.com/ArmanShadyan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Bacteria Detection \n---\n![Pipeline](assets/demo.gif)\n\nOverview\n---\nThis application is designed for detecting and analyzing bacteria in microscope images or real-time video feeds. It uses a U-Net style convolutional neural network (CNN) for bacteria segmentation, combined with image preprocessing techniques to enhance detection accuracy. The application supports multiple modes: real-time camera feed processing, single image analysis, batch image processing, and model training.\n\nFeatures\n---\n* Real-time Bacteria Detection: Process video feeds from a camera to detect and count bacteria with real-time visualization.\n* Single Image Processing: Analyze individual microscope images to identify bacteria and calculate coverage.\n* Batch Processing: Process multiple images in a directory and generate a detailed detection report.\n* Model Training: Train the bacteria segmentation model using labeled datasets.\n* Preprocessing: Enhance images using techniques like Gaussian blur, adaptive thresholding, and CLAHE for better detection.\n\nRequirements\n---\n```\npip install torch torchvision opencv-python numpy matplotlib mediapipe pillow\n```\n\nInstallation\n---\n1. Clone the repository:\n```\ngit clone https://github.com/your-repo/bacteria-detection.git\ncd bacteria-detection\n```\n2. Create a virtual environment (optional but recommended):\n```\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n3. Install the required dependencies:\n```\npip install torch torchvision opencv-python numpy matplotlib mediapipe pillow\n```\n\nUsage\n---\nThe application supports four modes: camera, image, batch, and train. Run the script using the command-line interface.\n\nCommand-Line Arguments\n---\n* --mode: Operation mode (camera, image, batch, or train). Default: camera.\n* --model: Path to a pre-trained model file (optional).\n* --input: Path to input image or directory (required for image and batch modes).\n* --output: Output directory for batch processing results. Default: output.\n* --train_dir: Directory containing training images (required for train mode).\n* --val_dir: Directory containing validation images (required for train mode).\n* --epochs: Number of training epochs (default: 10).\n\nExamples\n---\n1. Real-time Camera Processing:\n```\npython detection.py --mode camera --model models/bacteria_model.pth\n```\nThis starts the camera feed, detects bacteria, and displays the count, coverage, and FPS in real-time. Press q to exit.\n\n2. Single Image Processing:\n```\npython detection.py --mode image --input path/to/image.jpg --model models/bacteria_model.pth\n```\nThis processes a single image and displays the original and detected images side-by-side with bacteria count and coverage.\n\n3. Batch Processing:\n```\npython detection.py --mode batch --input path/to/input_dir --output path/to/output_dir --model models/bacteria_model.pth\n```\nThis processes all images in the input directory, saves detected images to the output directory, and generates a detection_report.txt with results.\n\n4. Training the Model:\n```\npython detection.py --mode train --train_dir path/to/train_dir --val_dir path/to/val_dir --epochs 10\n```\nThis trains the model, saves it to models/bacteria_model.pth, and plots the training history.\n\nNotes\n---\n* The application assumes input images are in .png, .jpg, .jpeg, or .tif format.\n* For training, ensure the training and validation directories contain properly labeled data (currently uses input images as targets for demonstration).\n* The model expects input images to be resized to 224x224 pixels and normalized using ImageNet statistics.\n* Ensure a CUDA-compatible GPU is available for faster processing; otherwise, it defaults to CPU.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmanshadyan%2Fbacteria-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farmanshadyan%2Fbacteria-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmanshadyan%2Fbacteria-detection/lists"}