soohyeon02 commited on
Commit
0406b75
1 Parent(s): 1410ce3

chore: setting

Browse files
Files changed (6) hide show
  1. app.py +15 -0
  2. config.json +110 -0
  3. preprocessor_config.json +18 -0
  4. pytorch_model.bin +3 -0
  5. sample_image.png +0 -0
  6. tf_model.h5 +3 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import SegformerFeatureExtractor, SegformerForSemanticSegmentation
2
+ from PIL import Image
3
+ import requests
4
+
5
+ feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b0-finetuned-cityscapes-1024-1024")
6
+ model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b0-finetuned-cityscapes-1024-1024")
7
+
8
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
9
+ image = Image.open(requests.get(url, stream=True).raw)
10
+
11
+ inputs = feature_extractor(images=image, return_tensors="pt")
12
+ outputs = model(**inputs)
13
+ logits = outputs.logits # shape (batch_size, num_labels, height/4, width/4)
14
+
15
+
config.json ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SegformerForSemanticSegmentation"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.0,
6
+ "classifier_dropout_prob": 0.1,
7
+ "decoder_hidden_size": 256,
8
+ "depths": [
9
+ 2,
10
+ 2,
11
+ 2,
12
+ 2
13
+ ],
14
+ "downsampling_rates": [
15
+ 1,
16
+ 4,
17
+ 8,
18
+ 16
19
+ ],
20
+ "drop_path_rate": 0.1,
21
+ "hidden_act": "gelu",
22
+ "hidden_dropout_prob": 0.0,
23
+ "hidden_sizes": [
24
+ 32,
25
+ 64,
26
+ 160,
27
+ 256
28
+ ],
29
+ "id2label": {
30
+ "0": "road",
31
+ "1": "sidewalk",
32
+ "2": "building",
33
+ "3": "wall",
34
+ "4": "fence",
35
+ "5": "pole",
36
+ "6": "traffic light",
37
+ "7": "traffic sign",
38
+ "8": "vegetation",
39
+ "9": "terrain",
40
+ "10": "sky",
41
+ "11": "person",
42
+ "12": "rider",
43
+ "13": "car",
44
+ "14": "truck",
45
+ "15": "bus",
46
+ "16": "train",
47
+ "17": "motorcycle",
48
+ "18": "bicycle"
49
+ },
50
+ "image_size": 224,
51
+ "initializer_range": 0.02,
52
+ "label2id": {
53
+ "bicycle": 18,
54
+ "building": 2,
55
+ "bus": 15,
56
+ "car": 13,
57
+ "fence": 4,
58
+ "motorcycle": 17,
59
+ "person": 11,
60
+ "pole": 5,
61
+ "rider": 12,
62
+ "road": 0,
63
+ "sidewalk": 1,
64
+ "sky": 10,
65
+ "terrain": 9,
66
+ "traffic light": 6,
67
+ "traffic sign": 7,
68
+ "train": 16,
69
+ "truck": 14,
70
+ "vegetation": 8,
71
+ "wall": 3
72
+ },
73
+ "layer_norm_eps": 1e-06,
74
+ "mlp_ratios": [
75
+ 4,
76
+ 4,
77
+ 4,
78
+ 4
79
+ ],
80
+ "model_type": "segformer",
81
+ "num_attention_heads": [
82
+ 1,
83
+ 2,
84
+ 5,
85
+ 8
86
+ ],
87
+ "num_channels": 3,
88
+ "num_encoder_blocks": 4,
89
+ "patch_sizes": [
90
+ 7,
91
+ 3,
92
+ 3,
93
+ 3
94
+ ],
95
+ "reshape_last_stage": true,
96
+ "sr_ratios": [
97
+ 8,
98
+ 4,
99
+ 2,
100
+ 1
101
+ ],
102
+ "strides": [
103
+ 4,
104
+ 2,
105
+ 2,
106
+ 2
107
+ ],
108
+ "torch_dtype": "float32",
109
+ "transformers_version": "4.12.0.dev0"
110
+ }
preprocessor_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": true,
3
+ "do_resize": true,
4
+ "feature_extractor_type": "SegformerFeatureExtractor",
5
+ "image_mean": [
6
+ 0.485,
7
+ 0.456,
8
+ 0.406
9
+ ],
10
+ "image_std": [
11
+ 0.229,
12
+ 0.224,
13
+ 0.225
14
+ ],
15
+ "reduce_labels": false,
16
+ "resample": 2,
17
+ "size": 512
18
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:027ed78d8ff9c535df5a66361c92b9673cca3cb923cbeb8c5802385b6b93194c
3
+ size 14957601
sample_image.png ADDED
tf_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc6105da7857b3c35b7e9032f008177840ea16a8ed36c08a2a51b094a41b3b49
3
+ size 15151028