You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Pothole-Finetuned-YoloV8

This is a fine-tuned YOLOv8 model specifically trained for pothole detection in road images. The model has been trained on thousands of pothole images and achieves over 95% accuracy in detecting potholes across various road conditions and environments.

Model Description

  • Model Type: Object Detection (YOLOv8)
  • Task: Pothole Detection in Road Images
  • Training Data: Thousands of annotated pothole images
  • Accuracy: >95%
  • Use Cases: Road infrastructure monitoring, automated road quality assessment, municipal road maintenance

Performance

  • Overall Accuracy: >95%
  • Robust Performance: Works across different lighting conditions, road types, and pothole sizes
  • Real-time Detection: Optimized for fast inference suitable for real-time applications

Training Details

  • Base Model: YOLOv8
  • Fine-tuning Dataset: Custom pothole dataset with thousands of annotated images
  • Training Environment: High-performance GPU infrastructure
  • Optimization: Model optimized for both accuracy and inference speed

Use Cases

  • Road Maintenance: Automated detection of potholes for municipal road maintenance
  • Infrastructure Monitoring: Large-scale road quality assessment
  • Fleet Management: Real-time pothole detection for vehicle navigation
  • Research: Academic and industrial research in road infrastructure analysis

πŸš€ Usage

Installation

pip install ultralytics opencv-python pillow

Basic Inference

from ultralytics import YOLO
import cv2
from PIL import Image
import numpy as np

# Load the model
model = YOLO("cazzz307/Pothole-Finetuned-YoloV8")

# Single image inference
def detect_potholes_image(image_path, output_path=None):
    """
    Detect potholes in a single image
    
    Args:
        image_path (str): Path to input image
        output_path (str): Path to save annotated image (optional)
    
    Returns:
        results: Detection results
    """
    results = model(image_path)
    
    # Print detection results
    for result in results:
        boxes = result.boxes
        if boxes is not None:
            print(f"Found {len(boxes)} potholes")
            for box in boxes:
                confidence = box.conf[0].item()
                print(f"Pothole detected with confidence: {confidence:.2f}")
    
    # Save annotated image if output path provided
    if output_path:
        annotated_frame = results[0].plot()
        cv2.imwrite(output_path, annotated_frame)
        print(f"Annotated image saved to: {output_path}")
    
    return results

# Video inference
def detect_potholes_video(video_path, output_path=None):
    """
    Detect potholes in a video
    
    Args:
        video_path (str): Path to input video
        output_path (str): Path to save annotated video (optional)
    """
    cap = cv2.VideoCapture(video_path)
    
    # Get video properties for output
    if output_path:
        fourcc = cv2.VideoWriter_fourcc(*'mp4v')
        fps = int(cap.get(cv2.CAP_PROP_FPS))
        width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
        height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
        out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
    
    frame_count = 0
    total_detections = 0
    
    while cap.isOpened():
        success, frame = cap.read()
        if not success:
            break
            
        # Run inference
        results = model(frame)
        
        # Count detections
        for result in results:
            if result.boxes is not None:
                total_detections += len(result.boxes)
        
        # Annotate frame
        annotated_frame = results[0].plot()
        
        # Save frame if output path provided
        if output_path:
            out.write(annotated_frame)
        
        # Display frame (optional)
        cv2.imshow("Pothole Detection", annotated_frame)
        if cv2.waitKey(1) & 0xFF == ord("q"):
            break
            
        frame_count += 1
    
    cap.release()
    if output_path:
        out.release()
    cv2.destroyAllWindows()
    
    print(f"Processed {frame_count} frames")
    print(f"Total potholes detected: {total_detections}")

# Batch processing for multiple images
def detect_potholes_batch(image_folder, output_folder=None):
    """
    Process multiple images in a folder
    
    Args:
        image_folder (str): Path to folder containing images
        output_folder (str): Path to save annotated images (optional)
    """
    import os
    import glob
    
    image_extensions = ['*.jpg', '*.jpeg', '*.png', '*.bmp', '*.tiff']
    image_files = []
    
    for ext in image_extensions:
        image_files.extend(glob.glob(os.path.join(image_folder, ext)))
        image_files.extend(glob.glob(os.path.join(image_folder, ext.upper())))
    
    total_detections = 0
    processed_images = 0
    
    for image_path in image_files:
        try:
            results = model(image_path)
            
            # Count detections
            for result in results:
                if result.boxes is not None:
                    total_detections += len(result.boxes)
                    print(f"{os.path.basename(image_path)}: {len(result.boxes)} potholes detected")
            
            # Save annotated image if output folder provided
            if output_folder:
                os.makedirs(output_folder, exist_ok=True)
                annotated_frame = results[0].plot()
                output_path = os.path.join(output_folder, f"annotated_{os.path.basename(image_path)}")
                cv2.imwrite(output_path, annotated_frame)
            
            processed_images += 1
            
        except Exception as e:
            print(f"Error processing {image_path}: {str(e)}")
    
    print(f"\nBatch processing complete:")
    print(f"Processed images: {processed_images}")
    print(f"Total potholes detected: {total_detections}")

# Example usage
if __name__ == "__main__":
    # Single image
    results = detect_potholes_image("road_image.jpg", "annotated_road.jpg")
    
    # Video processing
    # detect_potholes_video("road_video.mp4", "annotated_road_video.mp4")
    
    # Batch processing
    # detect_potholes_batch("road_images/", "annotated_images/")

Advanced Usage with Custom Parameters

from ultralytics import YOLO

# Load model
model = YOLO("cazzz307/Pothole-Finetuned-YoloV8")

# Advanced inference with custom parameters
def advanced_pothole_detection(image_path, confidence_threshold=0.5, iou_threshold=0.45):
    """
    Advanced pothole detection with custom parameters
    
    Args:
        image_path (str): Path to input image
        confidence_threshold (float): Confidence threshold for detections
        iou_threshold (float): IoU threshold for NMS
    
    Returns:
        dict: Detection results with detailed information
    """
    results = model(
        image_path,
        conf=confidence_threshold,
        iou=iou_threshold,
        verbose=False
    )
    
    detection_info = {
        'total_potholes': 0,
        'high_confidence_potholes': 0,
        'detections': []
    }
    
    for result in results:
        if result.boxes is not None:
            detection_info['total_potholes'] = len(result.boxes)
            
            for box in result.boxes:
                confidence = box.conf[0].item()
                bbox = box.xyxy[0].tolist()  # [x1, y1, x2, y2]
                
                detection_info['detections'].append({
                    'confidence': confidence,
                    'bbox': bbox,
                    'area': (bbox[2] - bbox[0]) * (bbox[3] - bbox[1])
                })
                
                if confidence > 0.8:
                    detection_info['high_confidence_potholes'] += 1
    
    return detection_info

# Example usage
image_path = "test_road.jpg"
results = advanced_pothole_detection(image_path, confidence_threshold=0.6)
print(f"Total potholes: {results['total_potholes']}")
print(f"High confidence potholes: {results['high_confidence_potholes']}")

Model Limitations

  • Weather Conditions: Performance may vary in extreme weather conditions (heavy rain, snow)
  • Image Quality: Best performance on clear, well-lit images
  • Pothole Size: Optimized for medium to large potholes; very small potholes may be missed
  • Road Types: Trained primarily on asphalt roads; performance on other surfaces may vary

Applications

  1. Municipal Road Maintenance: Automated pothole detection for city road departments
  2. Fleet Management: Real-time road quality assessment for vehicle routing
  3. Infrastructure Monitoring: Large-scale road condition surveys
  4. Research Applications: Academic studies on road infrastructure degradation
  5. Mobile Applications: Smartphone-based pothole reporting systems

License

This model is released under the Apache 2.0 License.

Acknowledgments

  • Built upon the excellent YOLOv8 architecture by Ultralytics
  • Trained using custom pothole dataset with thousands of annotated images
  • Optimized for real-world road infrastructure applications
Downloads last month
38
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Space using cazzz307/Pothole-Finetuned-YoloV8 1

Collection including cazzz307/Pothole-Finetuned-YoloV8