Downloads · 30 days
12
14% of all-time downloads
Frimpong1/pid-line-segmentation-unet-resnet34
pid-line-segmentation-unet-resnet34 is a image segmentation model from Frimpong1. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. It is set up for transformers.
This model is a U-Net architecture with a ResNet34 encoder, fine-tuned for P&ID (Piping and Instrumentation Diagram) line segmentation.
Downloads · 30 days
12
14% of all-time downloads
All-time downloads
86
Public
Repo size
391 MB
Likes
1
Public
Click a slice to open those files.
.pth294 MB · 75%
From the Hugging Face model README
This model is a U-Net architecture with a ResNet34 encoder, fine-tuned for P&ID (Piping and Instrumentation Diagram) line segmentation.
resnet34 backbone.1024x1024 pixels.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)
(Specify your license here, e.g., MIT)