qubvel-hf HF Staff commited on
Commit
e1fb07f
·
verified ·
1 Parent(s): 36e46a5

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +94 -0
  2. albumentations_config_eval.json +1 -0
  3. config.json +13 -0
  4. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: segmentation-models-pytorch
3
+ license: mit
4
+ pipeline_tag: image-segmentation
5
+ tags:
6
+ - model_hub_mixin
7
+ - pytorch_model_hub_mixin
8
+ - segmentation-models-pytorch
9
+ - semantic-segmentation
10
+ - pytorch
11
+ - upernet
12
+ languages:
13
+ - python
14
+ ---
15
+ # UPerNet Model Card
16
+
17
+ Table of Contents:
18
+ - [Load trained model](#load-trained-model)
19
+ - [Model init parameters](#model-init-parameters)
20
+ - [Model metrics](#model-metrics)
21
+ - [Dataset](#dataset)
22
+
23
+ ## Load trained model
24
+
25
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/qubvel/segmentation_models.pytorch/blob/main/examples/upernet_inference_pretrained.ipynb)
26
+
27
+ 1. Install requirements.
28
+
29
+ ```bash
30
+ pip install -U segmentation_models_pytorch albumentations
31
+ ```
32
+
33
+ 2. Run inference.
34
+
35
+ ```python
36
+ import torch
37
+ import requests
38
+ import numpy as np
39
+ import albumentations as A
40
+ import segmentation_models_pytorch as smp
41
+
42
+ from PIL import Image
43
+
44
+ device = "cuda" if torch.cuda.is_available() else "cpu"
45
+
46
+ # Load pretrained model and preprocessing function
47
+ checkpoint = "smp-hub/upernet-convnext-tiny"
48
+ model = smp.from_pretrained(checkpoint).eval().to(device)
49
+ preprocessing = A.Compose.from_pretrained(checkpoint)
50
+
51
+ # Load image
52
+ url = "https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000001.jpg"
53
+ image = Image.open(requests.get(url, stream=True).raw)
54
+
55
+ # Preprocess image
56
+ np_image = np.array(image)
57
+ normalized_image = preprocessing(image=np_image)["image"]
58
+ input_tensor = torch.as_tensor(normalized_image)
59
+ input_tensor = input_tensor.permute(2, 0, 1).unsqueeze(0) # HWC -> BCHW
60
+ input_tensor = input_tensor.to(device)
61
+
62
+ # Perform inference
63
+ with torch.no_grad():
64
+ output_mask = model(input_tensor)
65
+
66
+ # Postprocess mask
67
+ mask = mask.argmax(1).cpu().numpy() # argmax over predicted classes (channels dim)
68
+ ```
69
+
70
+
71
+ ## Model init parameters
72
+ ```python
73
+ model_init_params = {
74
+ "encoder_name": "tu-convnext_tiny.in12k_ft_in1k",
75
+ "encoder_depth": 5,
76
+ "encoder_weights": None,
77
+ "decoder_channels": 512,
78
+ "decoder_use_norm": "batchnorm",
79
+ "in_channels": 3,
80
+ "classes": 150,
81
+ "activation": None,
82
+ "upsampling": 4,
83
+ "aux_params": None
84
+ }
85
+ ```
86
+
87
+ ## Dataset
88
+ Dataset name: [ADE20K](https://ade20k.csail.mit.edu/)
89
+
90
+ ## More Information
91
+ - Library: https://github.com/qubvel/segmentation_models.pytorch
92
+ - Docs: https://smp.readthedocs.io/en/latest/
93
+
94
+ This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin)
albumentations_config_eval.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"__version__": "2.0.5", "transform": {"__class_fullname__": "Compose", "p": 1.0, "transforms": [{"__class_fullname__": "Resize", "p": 1.0, "height": 512, "width": 512, "interpolation": 1, "mask_interpolation": 0}, {"__class_fullname__": "Normalize", "p": 1.0, "mean": [123.675, 116.28, 103.53], "std": [58.395, 57.12, 57.375], "max_pixel_value": 1.0, "normalization": "standard"}], "bbox_params": null, "keypoint_params": null, "additional_targets": {}, "is_check_shapes": true}}
config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_model_class": "UPerNet",
3
+ "activation": null,
4
+ "aux_params": null,
5
+ "classes": 150,
6
+ "decoder_channels": 512,
7
+ "decoder_use_norm": "batchnorm",
8
+ "encoder_depth": 5,
9
+ "encoder_name": "tu-convnext_tiny",
10
+ "encoder_weights": null,
11
+ "in_channels": 3,
12
+ "upsampling": 4
13
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a12664e196498a5b189e3fa42784ab655d0ab9fd4c8e4fde95ed3b855f0c7de
3
+ size 237353608