rawalkhirodkar commited on
Commit
c98003f
·
0 Parent(s):

Add initial commit

Browse files
.gitattributes ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.png filter=lfs diff=lfs merge=lfs -text
37
+ *.pt2 filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Sapiens Segmentation
3
+ emoji: 🌍
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 4.42.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: cc-by-nc-4.0
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import cv2
3
+ import gradio as gr
4
+ import numpy as np
5
+ import spaces
6
+ import torch
7
+ import torch.nn.functional as F
8
+ from gradio.themes.utils import sizes
9
+ from torchvision import transforms
10
+ from PIL import Image
11
+ import tempfile
12
+ from classes_and_palettes import GOLIATH_PALETTE, GOLIATH_CLASSES
13
+
14
+ class Config:
15
+ ASSETS_DIR = os.path.join(os.path.dirname(__file__), 'assets')
16
+ CHECKPOINTS_DIR = os.path.join(ASSETS_DIR, "checkpoints")
17
+ CHECKPOINTS = {
18
+ "0.3b": "sapiens_0.3b_goliath_best_goliath_mIoU_7673_epoch_194_torchscript.pt2",
19
+ "0.6b": "sapiens_0.6b_goliath_best_goliath_mIoU_7777_epoch_178_torchscript.pt2",
20
+ "1b": "sapiens_1b_goliath_best_goliath_mIoU_7994_epoch_151_torchscript.pt2",
21
+ }
22
+
23
+ class ModelManager:
24
+ @staticmethod
25
+ def load_model(checkpoint_name: str):
26
+ checkpoint_path = os.path.join(Config.CHECKPOINTS_DIR, Config.CHECKPOINTS[checkpoint_name])
27
+ model = torch.jit.load(checkpoint_path)
28
+ model.eval()
29
+ model.to("cuda")
30
+ return model
31
+
32
+ @staticmethod
33
+ @torch.inference_mode()
34
+ def run_model(model, input_tensor, height, width):
35
+ output = model(input_tensor)
36
+ output = F.interpolate(output, size=(height, width), mode="bilinear", align_corners=False)
37
+ _, preds = torch.max(output, 1)
38
+ return preds
39
+
40
+ class ImageProcessor:
41
+ def __init__(self):
42
+ self.transform_fn = transforms.Compose([
43
+ transforms.Resize((1024, 768)),
44
+ transforms.ToTensor(),
45
+ transforms.Normalize(mean=[123.5/255, 116.5/255, 103.5/255], std=[58.5/255, 57.0/255, 57.5/255]),
46
+ ])
47
+
48
+ @spaces.GPU
49
+ def process_image(self, image: Image.Image, model_name: str):
50
+ model = ModelManager.load_model(model_name)
51
+ input_tensor = self.transform_fn(image).unsqueeze(0).to("cuda")
52
+
53
+ preds = ModelManager.run_model(model, input_tensor, image.height, image.width)
54
+ mask = preds.squeeze(0).cpu().numpy()
55
+
56
+ # Visualize the segmentation
57
+ blended_image = self.visualize_pred_with_overlay(image, mask)
58
+
59
+ # Create downloadable .npy file
60
+ npy_path = tempfile.mktemp(suffix='.npy')
61
+ np.save(npy_path, mask)
62
+
63
+ return blended_image, npy_path
64
+
65
+ @staticmethod
66
+ def visualize_pred_with_overlay(img, sem_seg, alpha=0.5):
67
+ img_np = np.array(img.convert("RGB"))
68
+ sem_seg = np.array(sem_seg)
69
+
70
+ num_classes = len(GOLIATH_CLASSES)
71
+ ids = np.unique(sem_seg)[::-1]
72
+ legal_indices = ids < num_classes
73
+ ids = ids[legal_indices]
74
+ labels = np.array(ids, dtype=np.int64)
75
+
76
+ colors = [GOLIATH_PALETTE[label] for label in labels]
77
+
78
+ overlay = np.zeros((*sem_seg.shape, 3), dtype=np.uint8)
79
+
80
+ for label, color in zip(labels, colors):
81
+ overlay[sem_seg == label, :] = color
82
+
83
+ blended = np.uint8(img_np * (1 - alpha) + overlay * alpha)
84
+ return Image.fromarray(blended)
85
+
86
+ class GradioInterface:
87
+ def __init__(self):
88
+ self.image_processor = ImageProcessor()
89
+
90
+ def create_interface(self):
91
+ app_styles = """
92
+ <style>
93
+ /* Global Styles */
94
+ body, #root {
95
+ font-family: Helvetica, Arial, sans-serif;
96
+ background-color: #1a1a1a;
97
+ color: #fafafa;
98
+ }
99
+ /* Header Styles */
100
+ .app-header {
101
+ background: linear-gradient(45deg, #1a1a1a 0%, #333333 100%);
102
+ padding: 24px;
103
+ border-radius: 8px;
104
+ margin-bottom: 24px;
105
+ text-align: center;
106
+ }
107
+ .app-title {
108
+ font-size: 48px;
109
+ margin: 0;
110
+ color: #fafafa;
111
+ }
112
+ .app-subtitle {
113
+ font-size: 24px;
114
+ margin: 8px 0 16px;
115
+ color: #fafafa;
116
+ }
117
+ .app-description {
118
+ font-size: 16px;
119
+ line-height: 1.6;
120
+ opacity: 0.8;
121
+ margin-bottom: 24px;
122
+ }
123
+ /* Button Styles */
124
+ .publication-links {
125
+ display: flex;
126
+ justify-content: center;
127
+ flex-wrap: wrap;
128
+ gap: 8px;
129
+ margin-bottom: 16px;
130
+ }
131
+ .publication-link {
132
+ display: inline-flex;
133
+ align-items: center;
134
+ padding: 8px 16px;
135
+ background-color: #333;
136
+ color: #fff !important;
137
+ text-decoration: none !important;
138
+ border-radius: 20px;
139
+ font-size: 14px;
140
+ transition: background-color 0.3s;
141
+ }
142
+ .publication-link:hover {
143
+ background-color: #555;
144
+ }
145
+ .publication-link i {
146
+ margin-right: 8px;
147
+ }
148
+ /* Content Styles */
149
+ .content-container {
150
+ background-color: #2a2a2a;
151
+ border-radius: 8px;
152
+ padding: 24px;
153
+ margin-bottom: 24px;
154
+ }
155
+ /* Image Styles */
156
+ /* Updated Image Styles */
157
+ .image-preview img {
158
+ max-width: 512px;
159
+ max-height: 512px;
160
+ margin: 0 auto;
161
+ border-radius: 4px;
162
+ display: block;
163
+ object-fit: contain;
164
+ }
165
+
166
+ /* Control Styles */
167
+ .control-panel {
168
+ background-color: #333;
169
+ padding: 16px;
170
+ border-radius: 8px;
171
+ margin-top: 16px;
172
+ }
173
+ /* Gradio Component Overrides */
174
+ .gr-button {
175
+ background-color: #4a4a4a;
176
+ color: #fff;
177
+ border: none;
178
+ border-radius: 4px;
179
+ padding: 8px 16px;
180
+ cursor: pointer;
181
+ transition: background-color 0.3s;
182
+ }
183
+ .gr-button:hover {
184
+ background-color: #5a5a5a;
185
+ }
186
+ .gr-input, .gr-dropdown {
187
+ background-color: #3a3a3a;
188
+ color: #fff;
189
+ border: 1px solid #4a4a4a;
190
+ border-radius: 4px;
191
+ padding: 8px;
192
+ }
193
+ .gr-form {
194
+ background-color: transparent;
195
+ }
196
+ .gr-panel {
197
+ border: none;
198
+ background-color: transparent;
199
+ }
200
+ /* Override any conflicting styles from Bulma */
201
+ .button.is-normal.is-rounded.is-dark {
202
+ color: #fff !important;
203
+ text-decoration: none !important;
204
+ }
205
+ </style>
206
+ """
207
+
208
+ header_html = f"""
209
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
210
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
211
+ {app_styles}
212
+ <div class="app-header">
213
+ <h1 class="app-title">Sapiens:Body-Part Segmentation</h1>
214
+ <h2 class="app-subtitle">ECCV 2024 (Oral)</h2>
215
+ <p class="app-description">
216
+ Meta presents Sapiens, foundation models for human tasks pretrained on 300 million human images.
217
+ This demo showcases the finetuned body-part segmentation model. <br>
218
+ </p>
219
+ <div class="publication-links">
220
+ <a href="https://arxiv.org/abs/2408.12569" class="publication-link">
221
+ <i class="fas fa-file-pdf"></i>arXiv
222
+ </a>
223
+ <a href="https://github.com/facebookresearch/sapiens" class="publication-link">
224
+ <i class="fab fa-github"></i>Code
225
+ </a>
226
+ <a href="https://about.meta.com/realitylabs/codecavatars/sapiens/" class="publication-link">
227
+ <i class="fas fa-globe"></i>Meta
228
+ </a>
229
+ <a href="https://rawalkhirodkar.github.io/sapiens" class="publication-link">
230
+ <i class="fas fa-chart-bar"></i>Results
231
+ </a>
232
+ </div>
233
+ <div class="publication-links">
234
+ <a href="https://huggingface.co/spaces/facebook/sapiens_pose" class="publication-link">
235
+ <i class="fas fa-user"></i>Demo-Pose
236
+ </a>
237
+ <a href="https://huggingface.co/spaces/facebook/sapiens_seg" class="publication-link">
238
+ <i class="fas fa-puzzle-piece"></i>Demo-Seg
239
+ </a>
240
+ <a href="https://huggingface.co/spaces/facebook/sapiens_depth" class="publication-link">
241
+ <i class="fas fa-cube"></i>Demo-Depth
242
+ </a>
243
+ <a href="https://huggingface.co/spaces/facebook/sapiens_normal" class="publication-link">
244
+ <i class="fas fa-vector-square"></i>Demo-Normal
245
+ </a>
246
+ </div>
247
+ </div>
248
+ """
249
+
250
+ js_func = """
251
+ function refresh() {
252
+ const url = new URL(window.location);
253
+ if (url.searchParams.get('__theme') !== 'dark') {
254
+ url.searchParams.set('__theme', 'dark');
255
+ window.location.href = url.href;
256
+ }
257
+ }
258
+ """
259
+
260
+ def process_image(image, model_name):
261
+ result, npy_path = self.image_processor.process_image(image, model_name)
262
+ return result, npy_path
263
+
264
+ with gr.Blocks(js=js_func, theme=gr.themes.Default()) as demo:
265
+ gr.HTML(header_html)
266
+ with gr.Row(elem_classes="content-container"):
267
+ with gr.Column():
268
+ input_image = gr.Image(label="Input Image", type="pil", format="png", elem_classes="image-preview")
269
+ model_name = gr.Dropdown(
270
+ label="Model Size",
271
+ choices=list(Config.CHECKPOINTS.keys()),
272
+ value="1b",
273
+ )
274
+ example_model = gr.Examples(
275
+ inputs=input_image,
276
+ examples_per_page=14,
277
+ examples=[
278
+ os.path.join(Config.ASSETS_DIR, "images", img)
279
+ for img in os.listdir(os.path.join(Config.ASSETS_DIR, "images"))
280
+ ],
281
+ )
282
+ with gr.Column():
283
+ result_image = gr.Image(label="Segmentation Result", type="pil", elem_classes="image-preview")
284
+ npy_output = gr.File(label="Segmentation (.npy)")
285
+ run_button = gr.Button("Run")
286
+ gr.Image(os.path.join(Config.ASSETS_DIR, "palette.jpg"), label="Class Palette", type="filepath", elem_classes="image-preview")
287
+
288
+ run_button.click(
289
+ fn=process_image,
290
+ inputs=[input_image, model_name],
291
+ outputs=[result_image, npy_output],
292
+ )
293
+
294
+ return demo
295
+
296
+ def main():
297
+ # Configure CUDA if available
298
+ if torch.cuda.is_available() and torch.cuda.get_device_properties(0).major >= 8:
299
+ torch.backends.cuda.matmul.allow_tf32 = True
300
+ torch.backends.cudnn.allow_tf32 = True
301
+
302
+ interface = GradioInterface()
303
+ demo = interface.create_interface()
304
+ demo.launch(share=False)
305
+
306
+ if __name__ == "__main__":
307
+ main()
assets/checkpoints/sapiens_0.3b_goliath_best_goliath_mIoU_7673_epoch_194_torchscript.pt2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:735a9a8d63fe8f3f6a4ca3d787de07e69b1f9708ad550e09bb33c9854b7eafbc
3
+ size 1358871599
assets/checkpoints/sapiens_0.6b_goliath_best_goliath_mIoU_7777_epoch_178_torchscript.pt2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86aa2cb9d7310ba1cb1971026889f1d10d80ddf655d6028aea060aae94d82082
3
+ size 2685144079
assets/checkpoints/sapiens_1b_goliath_best_goliath_mIoU_7994_epoch_151_torchscript.pt2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33bba30f3de8d9cfd44e4eaa4817b1bfdd98c188edfc87fa7cc031ba0f4edc17
3
+ size 4716314057
assets/checkpoints/sapiens_2b_goliath_best_goliath_mIoU_8131_epoch_200_torchscript.pt2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afe0970265f2af97f9eeb625036f147730d56820d6891803b13a278160c0f98a
3
+ size 8706620345
assets/images/68204.png ADDED

Git LFS Details

  • SHA256: 9b0268cb801ed164864a4b5f6d131e0ac5cc2fbd149a6467d5d0c97da47122c2
  • Pointer size: 132 Bytes
  • Size of remote file: 4.29 MB
assets/images/68210.png ADDED

Git LFS Details

  • SHA256: dbe5f80498af4ebd1ff09ae4184f37c20ba981e53bd554c3cc78d39ae0ee7fd7
  • Pointer size: 132 Bytes
  • Size of remote file: 3.93 MB
assets/images/68658.png ADDED

Git LFS Details

  • SHA256: 61a68b619bd17235e683324f2826ce0693322e45ab8c86f1c057851ecb333ac7
  • Pointer size: 132 Bytes
  • Size of remote file: 5.1 MB
assets/images/68666.png ADDED

Git LFS Details

  • SHA256: ea3047e6c2ccb485fdb3966aa2325e803cbf49c27c0bff00287b44bc16f18914
  • Pointer size: 132 Bytes
  • Size of remote file: 4.56 MB
assets/images/68691.png ADDED

Git LFS Details

  • SHA256: fae39e4055c1b297af7068cdddfeeba8d685363281b839d8c5afac1980204b57
  • Pointer size: 132 Bytes
  • Size of remote file: 3.74 MB
assets/images/68956.png ADDED

Git LFS Details

  • SHA256: eee1f27082b10999d0fa848121ecb06cda3386b1a864b9aa0f59ae78261f8908
  • Pointer size: 132 Bytes
  • Size of remote file: 4.15 MB
assets/images/pexels-amresh444-17315601.png ADDED

Git LFS Details

  • SHA256: 4e17ee1b229147e4b52e8348a6ef426bc9e9a2f90738e776e15b26b325abb9b3
  • Pointer size: 132 Bytes
  • Size of remote file: 3.5 MB
assets/images/pexels-gabby-k-6311686.png ADDED

Git LFS Details

  • SHA256: 3f10eded3fb05ab04b963f7b9fd2e183d8d4e81b20569b1c6b0653549639421f
  • Pointer size: 132 Bytes
  • Size of remote file: 3.65 MB
assets/images/pexels-julia-m-cameron-4145040.png ADDED

Git LFS Details

  • SHA256: 459cf0280667b028ffbca16aa11188780d7a0205c0defec02916ff3cbaeecb72
  • Pointer size: 132 Bytes
  • Size of remote file: 2.92 MB
assets/images/pexels-marcus-aurelius-6787357.png ADDED

Git LFS Details

  • SHA256: 7d35452f76492125eaf7d5783aa9fd6b0d5990ebe0579fe9dfd58a9d634f4955
  • Pointer size: 132 Bytes
  • Size of remote file: 3.3 MB
assets/images/pexels-mo-saeed-3616599-5409085.png ADDED

Git LFS Details

  • SHA256: 7c1ca7afd6c2a654e94ef59d5fb56fca4f3cde5fb5216f6b218c34a7b8c143dc
  • Pointer size: 132 Bytes
  • Size of remote file: 3.13 MB
assets/images/pexels-riedelmax-27355495.png ADDED

Git LFS Details

  • SHA256: 4141d2f5f718f162ea1f6710c06b28b5cb51fd69598fde35948f8f3491228164
  • Pointer size: 132 Bytes
  • Size of remote file: 3.73 MB
assets/images/pexels-sergeymakashin-5368660.png ADDED

Git LFS Details

  • SHA256: af8f5a8f26dd102d87d94c1be36ec903791fe8e6d951c68ebb9ebcfc6d7397bb
  • Pointer size: 132 Bytes
  • Size of remote file: 4.08 MB
assets/images/pexels-vinicius-wiesehofer-289347-4219918.png ADDED

Git LFS Details

  • SHA256: a6eef5eee15b81fe65ea95627e9a46040b9889466689b3c1ca6ed273e02fe84f
  • Pointer size: 132 Bytes
  • Size of remote file: 3.63 MB
assets/palette.jpg ADDED
classes_and_palettes.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ORIGINAL_GOLIATH_CLASSES = (
2
+ "Background",
3
+ "Apparel",
4
+ "Chair",
5
+ "Eyeglass_Frame",
6
+ "Eyeglass_Lenses",
7
+ "Face_Neck",
8
+ "Hair",
9
+ "Headset",
10
+ "Left_Foot",
11
+ "Left_Hand",
12
+ "Left_Lower_Arm",
13
+ "Left_Lower_Leg",
14
+ "Left_Shoe",
15
+ "Left_Sock",
16
+ "Left_Upper_Arm",
17
+ "Left_Upper_Leg",
18
+ "Lower_Clothing",
19
+ "Lower_Spandex",
20
+ "Right_Foot",
21
+ "Right_Hand",
22
+ "Right_Lower_Arm",
23
+ "Right_Lower_Leg",
24
+ "Right_Shoe",
25
+ "Right_Sock",
26
+ "Right_Upper_Arm",
27
+ "Right_Upper_Leg",
28
+ "Torso",
29
+ "Upper_Clothing",
30
+ "Visible_Badge",
31
+ "Lower_Lip",
32
+ "Upper_Lip",
33
+ "Lower_Teeth",
34
+ "Upper_Teeth",
35
+ "Tongue",
36
+ )
37
+
38
+ ORIGINAL_GOLIATH_PALETTE = [
39
+ [50, 50, 50],
40
+ [255, 218, 0],
41
+ [102, 204, 0],
42
+ [14, 0, 204],
43
+ [0, 204, 160],
44
+ [128, 200, 255],
45
+ [255, 0, 109],
46
+ [0, 255, 36],
47
+ [189, 0, 204],
48
+ [255, 0, 218],
49
+ [0, 160, 204],
50
+ [0, 255, 145],
51
+ [204, 0, 131],
52
+ [182, 0, 255],
53
+ [255, 109, 0],
54
+ [0, 255, 255],
55
+ [72, 0, 255],
56
+ [204, 43, 0],
57
+ [204, 131, 0],
58
+ [255, 0, 0],
59
+ [72, 255, 0],
60
+ [189, 204, 0],
61
+ [182, 255, 0],
62
+ [102, 0, 204],
63
+ [32, 72, 204],
64
+ [0, 145, 255],
65
+ [14, 204, 0],
66
+ [0, 128, 72],
67
+ [204, 0, 43],
68
+ [235, 205, 119],
69
+ [115, 227, 112],
70
+ [157, 113, 143],
71
+ [132, 93, 50],
72
+ [82, 21, 114],
73
+ ]
74
+
75
+ ## 6 classes to remove
76
+ REMOVE_CLASSES = (
77
+ "Eyeglass_Frame",
78
+ "Eyeglass_Lenses",
79
+ "Visible_Badge",
80
+ "Chair",
81
+ "Lower_Spandex",
82
+ "Headset",
83
+ )
84
+
85
+ ## 34 - 6 = 28 classes left
86
+ GOLIATH_CLASSES = tuple(
87
+ [x for x in ORIGINAL_GOLIATH_CLASSES if x not in REMOVE_CLASSES]
88
+ )
89
+ GOLIATH_PALETTE = [
90
+ ORIGINAL_GOLIATH_PALETTE[idx]
91
+ for idx in range(len(ORIGINAL_GOLIATH_CLASSES))
92
+ if ORIGINAL_GOLIATH_CLASSES[idx] not in REMOVE_CLASSES
93
+ ]
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ gradio
2
+ numpy
3
+ torch
4
+ torchvision
5
+ matplotlib
6
+ pillow
7
+ spaces
8
+ opencv-python