Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
datasets:
|
| 3 |
+
- gOLIVES/CRACKS
|
| 4 |
+
---
|
| 5 |
+
# UNet for Seisemic Image Detection
|
| 6 |
+
## Usage
|
| 7 |
+
This model is based on the UNet model with a ResNet50 encoder. To load the model weights and use the model, you can run the following code:
|
| 8 |
+
```python
|
| 9 |
+
from torchinfo import summary
|
| 10 |
+
from safetensors.torch import load_file
|
| 11 |
+
import segmentation_models_pytorch as smp
|
| 12 |
+
from huggingface_hub import hf_hub_download
|
| 13 |
+
import torch
|
| 14 |
+
|
| 15 |
+
# Define the device
|
| 16 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 17 |
+
|
| 18 |
+
# Create the model
|
| 19 |
+
model = smp.Unet(encoder_name="resnet50", encoder_weights=None, in_channels=3, classes=1)
|
| 20 |
+
|
| 21 |
+
# Download the model weights from Hugging Face Hub
|
| 22 |
+
weights_path = hf_hub_download(
|
| 23 |
+
repo_id="gOLIVES/UNet_Synth2CRACKS",
|
| 24 |
+
filename="model.safetensors",
|
| 25 |
+
cache_dir="./cache_dir"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Load weights
|
| 29 |
+
weights = load_file(weights_path, device=device)
|
| 30 |
+
model.load_state_dict(weights)
|
| 31 |
+
|
| 32 |
+
# Move model to device
|
| 33 |
+
model = model.to(device)
|
| 34 |
+
|
| 35 |
+
# Display model summary
|
| 36 |
+
summary(model, (1, 3, 256, 256))
|
| 37 |
+
```
|