Fabrice-TIERCELIN commited on
Commit
67efc35
1 Parent(s): 1b20dc8

Delete clipseg/Tables.ipynb

Browse files
Files changed (1) hide show
  1. clipseg/Tables.ipynb +0 -349
clipseg/Tables.ipynb DELETED
@@ -1,349 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "metadata": {},
7
- "outputs": [],
8
- "source": [
9
- "%load_ext autoreload\n",
10
- "%autoreload 2\n",
11
- "\n",
12
- "import clip\n",
13
- "from evaluation_utils import norm, denorm\n",
14
- "from general_utils import *\n",
15
- "from datasets.lvis_oneshot3 import LVIS_OneShot3, LVIS_OneShot"
16
- ]
17
- },
18
- {
19
- "cell_type": "markdown",
20
- "metadata": {},
21
- "source": [
22
- "# PhraseCut"
23
- ]
24
- },
25
- {
26
- "cell_type": "code",
27
- "execution_count": null,
28
- "metadata": {},
29
- "outputs": [],
30
- "source": [
31
- "pc = experiment('experiments/phrasecut.yaml', nums=':6').dataframe()"
32
- ]
33
- },
34
- {
35
- "cell_type": "code",
36
- "execution_count": null,
37
- "metadata": {},
38
- "outputs": [],
39
- "source": [
40
- "tab1 = pc[['name', 'pc_miou_best', 'pc_fgiou_best', 'pc_ap']]"
41
- ]
42
- },
43
- {
44
- "cell_type": "code",
45
- "execution_count": null,
46
- "metadata": {},
47
- "outputs": [],
48
- "source": [
49
- "cols = ['pc_miou_0.3', 'pc_fgiou_0.3', 'pc_ap']\n",
50
- "tab1 = pc[['name'] + cols]\n",
51
- "for k in cols:\n",
52
- " tab1.loc[:, k] = (100 * tab1.loc[:, k]).round(1)\n",
53
- "tab1.loc[:, 'name'] = ['CLIPSeg (PC+)', 'CLIPSeg (PC, $D=128$)', 'CLIPSeg (PC)', 'CLIP-Deconv', 'ViTSeg (PC+)', 'ViTSeg (PC)']\n",
54
- "tab1.insert(1, 't', [0.3]*tab1.shape[0])\n",
55
- "print(tab1.to_latex(header=False, index=False))"
56
- ]
57
- },
58
- {
59
- "cell_type": "markdown",
60
- "metadata": {},
61
- "source": [
62
- "For 0.1 threshold"
63
- ]
64
- },
65
- {
66
- "cell_type": "code",
67
- "execution_count": null,
68
- "metadata": {},
69
- "outputs": [],
70
- "source": [
71
- "cols = ['pc_miou_0.1', 'pc_fgiou_0.1', 'pc_ap']\n",
72
- "tab1 = pc[['name'] + cols]\n",
73
- "for k in cols:\n",
74
- " tab1.loc[:, k] = (100 * tab1.loc[:, k]).round(1)\n",
75
- "tab1.loc[:, 'name'] = ['CLIPSeg (PC+)', 'CLIPSeg (PC, $D=128$)', 'CLIPSeg (PC)', 'CLIP-Deconv', 'ViTSeg (PC+)', 'ViTSeg (PC)']\n",
76
- "tab1.insert(1, 't', [0.1]*tab1.shape[0])\n",
77
- "print(tab1.to_latex(header=False, index=False))"
78
- ]
79
- },
80
- {
81
- "cell_type": "markdown",
82
- "metadata": {},
83
- "source": [
84
- "# One-shot"
85
- ]
86
- },
87
- {
88
- "cell_type": "markdown",
89
- "metadata": {},
90
- "source": [
91
- "### Pascal"
92
- ]
93
- },
94
- {
95
- "cell_type": "code",
96
- "execution_count": null,
97
- "metadata": {},
98
- "outputs": [],
99
- "source": [
100
- "pas = experiment('experiments/pascal_1shot.yaml', nums=':19').dataframe()"
101
- ]
102
- },
103
- {
104
- "cell_type": "code",
105
- "execution_count": null,
106
- "metadata": {},
107
- "outputs": [],
108
- "source": [
109
- "pas[['name', 'pas_h2_miou_0.3', 'pas_h2_biniou_0.3', 'pas_h2_ap', 'pas_h2_fgiou_ct']]"
110
- ]
111
- },
112
- {
113
- "cell_type": "code",
114
- "execution_count": null,
115
- "metadata": {},
116
- "outputs": [],
117
- "source": [
118
- "pas = experiment('experiments/pascal_1shot.yaml', nums=':8').dataframe()\n",
119
- "tab1 = pas[['pas_h2_miou_0.3', 'pas_h2_biniou_0.3', 'pas_h2_ap']]\n",
120
- "print('CLIPSeg (PC+) & 0.3 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[0:4].mean(0).values), '\\\\\\\\')\n",
121
- "print('CLIPSeg (PC) & 0.3 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[4:8].mean(0).values), '\\\\\\\\')\n",
122
- "\n",
123
- "pas = experiment('experiments/pascal_1shot.yaml', nums='12:16').dataframe()\n",
124
- "tab1 = pas[['pas_h2_miou_0.2', 'pas_h2_biniou_0.2', 'pas_h2_ap']]\n",
125
- "print('CLIP-Deconv (PC+) & 0.2 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[0:4].mean(0).values), '\\\\\\\\')\n",
126
- "\n",
127
- "pas = experiment('experiments/pascal_1shot.yaml', nums='16:20').dataframe()\n",
128
- "tab1 = pas[['pas_t_miou_0.2', 'pas_t_biniou_0.2', 'pas_t_ap']]\n",
129
- "print('ViTSeg (PC+) & 0.2 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[0:4].mean(0).values), '\\\\\\\\')"
130
- ]
131
- },
132
- {
133
- "cell_type": "markdown",
134
- "metadata": {},
135
- "source": [
136
- "#### Pascal Zero-shot (in one-shot setting)\n",
137
- "\n",
138
- "Using the same setting as one-shot (hence different from the other zero-shot benchmark)"
139
- ]
140
- },
141
- {
142
- "cell_type": "code",
143
- "execution_count": null,
144
- "metadata": {},
145
- "outputs": [],
146
- "source": [
147
- "pas = experiment('experiments/pascal_1shot.yaml', nums=':8').dataframe()\n",
148
- "tab1 = pas[['pas_t_miou_0.3', 'pas_t_biniou_0.3', 'pas_t_ap']]\n",
149
- "print('CLIPSeg (PC+) & 0.3 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[0:4].mean(0).values), '\\\\\\\\')\n",
150
- "print('CLIPSeg (PC) & 0.3 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[4:8].mean(0).values), '\\\\\\\\')\n",
151
- "\n",
152
- "pas = experiment('experiments/pascal_1shot.yaml', nums='12:16').dataframe()\n",
153
- "tab1 = pas[['pas_t_miou_0.3', 'pas_t_biniou_0.3', 'pas_t_ap']]\n",
154
- "print('CLIP-Deconv (PC+) & 0.3 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[0:4].mean(0).values), '\\\\\\\\')\n",
155
- "\n",
156
- "pas = experiment('experiments/pascal_1shot.yaml', nums='16:20').dataframe()\n",
157
- "tab1 = pas[['pas_t_miou_0.2', 'pas_t_biniou_0.2', 'pas_t_ap']]\n",
158
- "print('ViTSeg (PC+) & 0.2 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[0:4].mean(0).values), '\\\\\\\\')"
159
- ]
160
- },
161
- {
162
- "cell_type": "code",
163
- "execution_count": null,
164
- "metadata": {},
165
- "outputs": [],
166
- "source": [
167
- "# without fixed thresholds...\n",
168
- "\n",
169
- "pas = experiment('experiments/pascal_1shot.yaml', nums=':8').dataframe()\n",
170
- "tab1 = pas[['pas_t_best_miou', 'pas_t_best_biniou', 'pas_t_ap']]\n",
171
- "print('CLIPSeg (PC+) & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[0:4].mean(0).values), '\\\\\\\\')\n",
172
- "print('CLIPSeg (PC) & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[4:8].mean(0).values), '\\\\\\\\')\n",
173
- "\n",
174
- "pas = experiment('experiments/pascal_1shot.yaml', nums='12:16').dataframe()\n",
175
- "tab1 = pas[['pas_t_best_miou', 'pas_t_best_biniou', 'pas_t_ap']]\n",
176
- "print('CLIP-Deconv (PC+) & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[0:4].mean(0).values), '\\\\\\\\')"
177
- ]
178
- },
179
- {
180
- "cell_type": "markdown",
181
- "metadata": {},
182
- "source": [
183
- "### COCO"
184
- ]
185
- },
186
- {
187
- "cell_type": "code",
188
- "execution_count": null,
189
- "metadata": {},
190
- "outputs": [],
191
- "source": [
192
- "coco = experiment('experiments/coco.yaml', nums=':29').dataframe()"
193
- ]
194
- },
195
- {
196
- "cell_type": "code",
197
- "execution_count": null,
198
- "metadata": {},
199
- "outputs": [],
200
- "source": [
201
- "tab1 = coco[['coco_h2_miou_0.1', 'coco_h2_biniou_0.1', 'coco_h2_ap']]\n",
202
- "tab2 = coco[['coco_h2_miou_0.2', 'coco_h2_biniou_0.2', 'coco_h2_ap']]\n",
203
- "tab3 = coco[['coco_h2_miou_best', 'coco_h2_biniou_best', 'coco_h2_ap']]\n",
204
- "print('CLIPSeg (COCO) & 0.1 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[:4].mean(0).values), '\\\\\\\\')\n",
205
- "print('CLIPSeg (COCO+N) & 0.1 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[4:8].mean(0).values), '\\\\\\\\')\n",
206
- "print('CLIP-Deconv (COCO+N) & 0.1 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[12:16].mean(0).values), '\\\\\\\\')\n",
207
- "print('ViTSeg (COCO) & 0.1 & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[8:12].mean(0).values), '\\\\\\\\')"
208
- ]
209
- },
210
- {
211
- "cell_type": "markdown",
212
- "metadata": {},
213
- "source": [
214
- "# Zero-shot"
215
- ]
216
- },
217
- {
218
- "cell_type": "code",
219
- "execution_count": null,
220
- "metadata": {},
221
- "outputs": [],
222
- "source": [
223
- "zs = experiment('experiments/pascal_0shot.yaml', nums=':11').dataframe()"
224
- ]
225
- },
226
- {
227
- "cell_type": "code",
228
- "execution_count": null,
229
- "metadata": {},
230
- "outputs": [],
231
- "source": [
232
- "\n",
233
- "tab1 = zs[['pas_zs_seen', 'pas_zs_unseen']]\n",
234
- "print('CLIPSeg (PC+) & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[8:9].values[0].tolist() + tab1[10:11].values[0].tolist()), '\\\\\\\\')\n",
235
- "print('CLIP-Deconv & CLIP & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[2:3].values[0].tolist() + tab1[3:4].values[0].tolist()), '\\\\\\\\')\n",
236
- "print('ViTSeg & ImageNet-1K & ' + ' & '.join(f'{x*100:.1f}' for x in tab1[4:5].values[0].tolist() + tab1[5:6].values[0].tolist()), '\\\\\\\\')"
237
- ]
238
- },
239
- {
240
- "cell_type": "markdown",
241
- "metadata": {},
242
- "source": [
243
- "# Ablation"
244
- ]
245
- },
246
- {
247
- "cell_type": "code",
248
- "execution_count": null,
249
- "metadata": {},
250
- "outputs": [],
251
- "source": [
252
- "ablation = experiment('experiments/ablation.yaml', nums=':8').dataframe()"
253
- ]
254
- },
255
- {
256
- "cell_type": "code",
257
- "execution_count": null,
258
- "metadata": {},
259
- "outputs": [],
260
- "source": [
261
- "tab1 = ablation[['name', 'pc_miou_best', 'pc_ap', 'pc-vis_miou_best', 'pc-vis_ap']]\n",
262
- "for k in ['pc_miou_best', 'pc_ap', 'pc-vis_miou_best', 'pc-vis_ap']:\n",
263
- " tab1.loc[:, k] = (100 * tab1.loc[:, k]).round(1)\n",
264
- "tab1.loc[:, 'name'] = ['CLIPSeg', 'no CLIP pre-training', 'no-negatives', '50% negatives', 'no visual', '$D=16$', 'only layer 3', 'highlight mask']"
265
- ]
266
- },
267
- {
268
- "cell_type": "code",
269
- "execution_count": null,
270
- "metadata": {},
271
- "outputs": [],
272
- "source": [
273
- "print(tab1.loc[[0,1,4,5,6,7],:].to_latex(header=False, index=False))"
274
- ]
275
- },
276
- {
277
- "cell_type": "code",
278
- "execution_count": null,
279
- "metadata": {},
280
- "outputs": [],
281
- "source": [
282
- "print(tab1.loc[[0,1,4,5,6,7],:].to_latex(header=False, index=False))"
283
- ]
284
- },
285
- {
286
- "cell_type": "markdown",
287
- "metadata": {},
288
- "source": [
289
- "# Generalization"
290
- ]
291
- },
292
- {
293
- "cell_type": "code",
294
- "execution_count": null,
295
- "metadata": {},
296
- "outputs": [],
297
- "source": [
298
- "generalization = experiment('experiments/generalize.yaml').dataframe()"
299
- ]
300
- },
301
- {
302
- "cell_type": "code",
303
- "execution_count": null,
304
- "metadata": {},
305
- "outputs": [],
306
- "source": [
307
- "gen = generalization[['aff_best_fgiou', 'aff_ap', 'ability_best_fgiou', 'ability_ap', 'part_best_fgiou', 'part_ap']].values"
308
- ]
309
- },
310
- {
311
- "cell_type": "code",
312
- "execution_count": null,
313
- "metadata": {},
314
- "outputs": [],
315
- "source": [
316
- "print(\n",
317
- " 'CLIPSeg (PC+) & ' + ' & '.join(f'{x*100:.1f}' for x in gen[1]) + ' \\\\\\\\ \\n' + \\\n",
318
- " 'CLIPSeg (LVIS) & ' + ' & '.join(f'{x*100:.1f}' for x in gen[0]) + ' \\\\\\\\ \\n' + \\\n",
319
- " 'CLIP-Deconv & ' + ' & '.join(f'{x*100:.1f}' for x in gen[2]) + ' \\\\\\\\ \\n' + \\\n",
320
- " 'VITSeg & ' + ' & '.join(f'{x*100:.1f}' for x in gen[3]) + ' \\\\\\\\'\n",
321
- ")"
322
- ]
323
- }
324
- ],
325
- "metadata": {
326
- "interpreter": {
327
- "hash": "800ed241f7db2bd3aa6942aa3be6809cdb30ee6b0a9e773dfecfa9fef1f4c586"
328
- },
329
- "kernelspec": {
330
- "display_name": "env2",
331
- "language": "python",
332
- "name": "env2"
333
- },
334
- "language_info": {
335
- "codemirror_mode": {
336
- "name": "ipython",
337
- "version": 3
338
- },
339
- "file_extension": ".py",
340
- "mimetype": "text/x-python",
341
- "name": "python",
342
- "nbconvert_exporter": "python",
343
- "pygments_lexer": "ipython3",
344
- "version": "3.8.8"
345
- }
346
- },
347
- "nbformat": 4,
348
- "nbformat_minor": 4
349
- }