Aller au contenu
ModelPrésentéExterne
Télécharger

Pid Line Segmentation Unet Resnet34

This model is a U-Net architecture with a ResNet34 encoder, fine-tuned for P&ID (Piping and Instrumentation Diagram) line segmentation.

TypeOtherVersionRevision e9d2c11

Source du modèle

Type
Other
Taille du fichier
93,4–280 MB
Version
vRevision e9d2c11
Mis à jour
27 sept. 2026
Téléchargements
9
Tâches
Segmentation d'image
Source
Hugging Face

Description de la source

P&ID Line Segmentation Model (U-Net with ResNet34 Backbone)

This model is a U-Net architecture with a ResNet34 encoder, fine-tuned for P&ID (Piping and Instrumentation Diagram) line segmentation.

Model Details

  • Architecture: U-Net with resnet34 backbone.
  • Input size: 1024x1024 pixels.
  • Output: Binary mask (single class for lines).
  • Loss Function: Combined Dice Loss and Focal Loss.

Performance (on Test Set)

  • Test Loss: 0.5721
  • Test Dice Score: 0.9413
  • Test IoU Score: 0.8908

Usage

This model can be loaded using segmentation_models_pytorch.

import torch
import segmentation_models_pytorch as smp
from huggingface_hub import hf_hub_download

# Define the model architecture
model = smp.Unet(
    encoder_name="resnet34",
    encoder_weights=None, # Weights are loaded from the saved state_dict
    in_channels=3,
    classes=1,
    activation="sigmoid"
)

# Download and load state_dict
model_path = hf_hub_download(repo_id="Frimpong1/pid-line-segmentation-unet-resnet34", filename="pytorch_model.bin")
model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
model.eval()

# Example of using the model (assuming you have an image_tensor preprocessed)
# image_tensor = ... # (C, H, W) float32 tensor, normalized
# with torch.no_grad():
#     prediction = model(image_tensor.unsqueeze(0)) # Add batch dimension
#     mask = (prediction.squeeze(0).cpu().numpy() > 0.5).astype(float)

Training Details

  • Epochs Trained: 20
  • Batch Size: 4
  • Learning Rate: 0.0001
  • Optimizer: Adam

License

(Specify your license here, e.g., MIT)

Sources

1 source
Hugging FacePrincipalVersion e9d2c11f786b15839e24b0565e1964781482eceb
huggingface.co/Frimpong1/pid-line-segmentation-unet-resnet34/tree/e9d2c11f786b15839e24b0565e1964781482eceb

Vérifié 27 sept.

Artefacts du modèle

2 artefacts

best_model_line_mask.pth

pth · 280 MB · SHA-256 79da896d88f7…2877 · Hugging Face

Télécharger

pytorch_model.bin

bin · 93,4 MB · SHA-256 f9f31a8a02b6…8c14 · Hugging Face

Télécharger

Extraits de sources

2 extraits

--- library_name: transformers tags: - image-segmentation - unet - resnet - pid - computer-vision --- # P&ID Line Segmentation Model (U-Net with ResNet34 Backbone) This model is a U-Net architecture with a ResNet34 encoder, fine-tuned for P&ID (Piping and Instrumentation Diagram) line segmentation. ## Model Details - **Architecture**: U-Net with `resnet34` backbone. - **Input size**: `1024x1024` pixels. - **Output**: Binary mask (single class for lines). - **Loss Function**: Combined Dice Loss and Focal Loss. ## Performance (on Test Set) - **Test Loss**: 0.5721 - **Test Dice Score**: 0.9413 - **Test IoU Score**: 0.8908 ## Usage This model can be loaded using `segmentation_models_pytorch`. ```python import torch import segmentation_models_pytorch as smp from huggingface_hub import hf_hub_download # Define the model architecture model = smp.Unet( encoder_name="resnet34", encoder_weights=None, # Weights are loaded from the saved state_dict in_channels=3, classes=1, activation="sigmoid" ) # Download and load state_dict model_path = hf_hub_download(repo_id="Frimpong1/pid-line-segmentation-unet-resnet34", filename="pytorch_model.bin") model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu'))) model.eval() # Example of using the model (assuming you have an image_tensor preprocessed) # image_tensor = ... # (C, H, W) float32 tensor, normalized # with torch.no_grad(): # prediction = model(image_tensor.unsqueeze(0)) # Add batch dimension # mask = (prediction.squeeze(0).cpu().numpy() > 0.5).astype(float) ``` ## Training Details - **Epochs Trained**: 20 - **Batch Size**: 4 - **Learning Rate**: 0.0001 - **Optimizer**: Adam ## License (Specify your license here, e.g., MIT)

Source context: 9 downloads · 1 likes · Pipeline image-segmentation · Library transformers · Repo Frimpong1/pid-line-segmentation-unet-resnet34