Views
No views yet
| Metric | Value |
|---|---|
| Dice Score | 99.77% |
| IoU Score | 99.54% |
| F1 Score | 99.77% |
| Precision | 99.54% |
| Recall | 100.00% |
| Training Loss | 0.0162 |
| Validation Loss | 0.0139 |
concreate-crack-segmentation/
├── Concreate_Crack_Segmentation.ipynb # Main notebook
├── Dataset/
│ ├── images/ # 800 concrete images (256x256)
│ └── masks/ # Corresponding crack masks
├── unet_model_weights.pth # Trained model weights
├── model_config.json # Model configuration
├── training_history.json # Training metrics history
├── training_history.png # Training plots
├── predictions_visualization.png # Sample predictions
├── requirements.txt # Dependencies
├── README.md # This file
├── model_card.md # Model card for HF
└── inference.py # Inference scripttorch==2.0.0
torchvision==0.15.0
Pillow==9.5.0
numpy==1.24.3
opencv-python==4.8.0.74
matplotlib==3.7.2
tqdm==4.66.11from PIL import Image
2import torch
3from inference import predict_crack_segmentation
4
5# Make prediction
6image_path = "path/to/image.jpg"
7prediction = predict_crack_segmentation(image_path, threshold=0.5)1# Mount Google Drive and run notebook cells in order
2# Dataset path: /MyDrive/computer vision course/projects/Concreate Crack Segmentation/Dataset/1import torch
2from model import ImprovedUNet
3
4model = ImprovedUNet(in_channels=3, out_channels=1, depth=4, start_filters=64)
5model.load_state_dict(torch.load('unet_model_weights.pth'))
6model.eval()1from PIL import Image
2import torchvision.transforms as transforms
3
4image = Image.open('concrete.jpg').convert('RGB')
5image = transforms.Resize((256, 256))(image)
6image_tensor = transforms.ToTensor()(image).unsqueeze(0)
7
8with torch.no_grad():
9 prediction = model(image_tensor)
10
11segmentation_mask = prediction.squeeze().numpy()1from torch.utils.data import DataLoader
2from dataset_class import CrackDataset
3
4dataset = CrackDataset(images_path, masks_path, transform=val_transform)
5loader = DataLoader(dataset, batch_size=32, shuffle=False)
6
7predictions = []
8for images, masks in loader:
9 with torch.no_grad():
10 preds = model(images)
11 predictions.extend(preds.cpu().numpy())1# Modify these in the notebook:
2BATCH_SIZE = 16 # Change batch size
3NUM_EPOCHS = 25 # Change max epochs
4LEARNING_RATE = 2e-3 # Change learning rate
5IMG_WIDTH = IMG_HEIGHT = 256 # Change image size1# In CombinedLoss:
2bce_weight = 0.4 # Weight for BCE loss
3dice_weight = 0.6 # Weight for Dice loss
4# Adjust for different focus (higher dice_weight → more focus on segmentation)num_workers=0 in DataLoader (already implemented)