Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
ViToolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wu, Jiantao (PG/R - Comp Sci & Elec Eng)
ViToolkit
Commits
dc2a6f5e
Commit
dc2a6f5e
authored
1 year ago
by
gent
Browse files
Options
Downloads
Patches
Plain Diff
scheme5
parent
c46b1316
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vitookit/datasets/ffcv_transform.py
+11
-1
11 additions, 1 deletion
vitookit/datasets/ffcv_transform.py
vitookit/evaluation/eval_image_retrieval.py
+8
-7
8 additions, 7 deletions
vitookit/evaluation/eval_image_retrieval.py
with
19 additions
and
8 deletions
vitookit/datasets/ffcv_transform.py
+
11
−
1
View file @
dc2a6f5e
...
...
@@ -55,7 +55,17 @@ class DynamicResolution:
dict
(
res
=
160
,
lower_scale
=
0.08
,
upper_scale
=
0.4624
),
dict
(
res
=
192
,
lower_scale
=
0.08
,
upper_scale
=
0.7056
),
dict
(
res
=
224
,
lower_scale
=
0.08
,
upper_scale
=
1
),
]
],
4
:[
dict
(
res
=
160
,
lower_scale
=
0.20
,
upper_scale
=
0.634
),
dict
(
res
=
192
,
lower_scale
=
0.137
,
upper_scale
=
0.81
),
dict
(
res
=
224
,
lower_scale
=
0.08
,
upper_scale
=
1
),
],
5
:
[
dict
(
res
=
160
,
lower_scale
=
0.20
,
upper_scale
=
1
),
dict
(
res
=
192
,
lower_scale
=
0.137
,
upper_scale
=
1
),
dict
(
res
=
224
,
lower_scale
=
0.08
,
upper_scale
=
1
),
],
}
self
.
scheme
=
schemes
[
scheme
]
...
...
This diff is collapsed.
Click to expand it.
vitookit/evaluation/eval_image_retrieval.py
+
8
−
7
View file @
dc2a6f5e
...
...
@@ -20,13 +20,14 @@ import torch.distributed as dist
import
torch.backends.cudnn
as
cudnn
import
numpy
as
np
from
vitookit.utils.helper
import
load_pretrained_weights
import
vitookit.utils
from
vitookit.utils.metric
import
compute_map
import
vitookit.utils.misc
as
misc
from
vitookit.models
import
vision_transformer
as
vits
,
vision_transformer_rel
as
vits_rel
from
torch
import
nn
from
PIL
import
Image
,
ImageFile
from
torchvision
import
vitookit
.
models
as
torchvision_models
from
torchvision
import
transforms
as
pth_transforms
from
eval_knn
import
extract_features
,
ReturnIndexDatasetWrap
...
...
@@ -91,10 +92,10 @@ if __name__ == '__main__':
parser
.
add_argument
(
'
--data_location
'
,
default
=
'
/path/to/revisited_paris_oxford/
'
,
type
=
str
)
parser
.
add_argument
(
'
--bn
'
,
default
=
False
,
action
=
'
store_true
'
)
parser
.
add_argument
(
'
--data_set
'
,
default
=
'
roxford5k
'
,
type
=
str
,
choices
=
[
'
roxford5k
'
,
'
rparis6k
'
])
parser
.
add_argument
(
'
--multiscale
'
,
default
=
False
,
type
=
utils
.
bool_flag
)
parser
.
add_argument
(
'
--multiscale
'
,
default
=
False
,
action
=
'
store_true
'
)
parser
.
add_argument
(
'
--imsize
'
,
default
=
224
,
type
=
int
,
help
=
'
Image size
'
)
parser
.
add_argument
(
'
-w
'
,
'
--pretrained_weights
'
,
default
=
''
,
type
=
str
,
help
=
"
Path to pretrained weights to evaluate.
"
)
parser
.
add_argument
(
'
--use_cuda
'
,
default
=
True
,
type
=
utils
.
bool_flag
)
parser
.
add_argument
(
'
--use_cuda
'
,
default
=
True
,
action
=
'
store_true
'
)
parser
.
add_argument
(
'
--arch
'
,
default
=
'
vit_small
'
,
type
=
str
,
choices
=
[
'
vit_tiny
'
,
'
vit_small
'
,
'
vit_base
'
,
'
vit_large
'
],
help
=
'
Architecture.
'
)
parser
.
add_argument
(
'
--patch_size
'
,
default
=
16
,
type
=
int
,
help
=
'
Patch resolution of the model.
'
)
...
...
@@ -110,7 +111,7 @@ if __name__ == '__main__':
args
=
parser
.
parse_args
()
misc
.
init_distributed_mode
(
args
)
print
(
"
git:
\n
{}
\n
"
.
format
(
utils
.
get_sha
()))
print
(
"
git:
\n
{}
\n
"
.
format
(
misc
.
get_sha
()))
print
(
"
\n
"
.
join
(
"
%s: %s
"
%
(
k
,
str
(
v
))
for
k
,
v
in
sorted
(
dict
(
vars
(
args
)).
items
())))
cudnn
.
benchmark
=
True
...
...
@@ -194,7 +195,7 @@ if __name__ == '__main__':
g
[
'
ok
'
]
=
np
.
concatenate
([
gnd
[
i
][
'
easy
'
],
gnd
[
i
][
'
hard
'
]])
g
[
'
junk
'
]
=
np
.
concatenate
([
gnd
[
i
][
'
junk
'
]])
gnd_t
.
append
(
g
)
mapM
,
apsM
,
mprM
,
prsM
=
misc
.
compute_map
(
ranks
,
gnd_t
,
ks
)
mapM
,
apsM
,
mprM
,
prsM
=
compute_map
(
ranks
,
gnd_t
,
ks
)
# search for hard
gnd_t
=
[]
for
i
in
range
(
len
(
gnd
)):
...
...
@@ -202,7 +203,7 @@ if __name__ == '__main__':
g
[
'
ok
'
]
=
np
.
concatenate
([
gnd
[
i
][
'
hard
'
]])
g
[
'
junk
'
]
=
np
.
concatenate
([
gnd
[
i
][
'
junk
'
],
gnd
[
i
][
'
easy
'
]])
gnd_t
.
append
(
g
)
mapH
,
apsH
,
mprH
,
prsH
=
misc
.
compute_map
(
ranks
,
gnd_t
,
ks
)
mapH
,
apsH
,
mprH
,
prsH
=
compute_map
(
ranks
,
gnd_t
,
ks
)
print
(
'
>> {}: mAP M: {}, H: {}
'
.
format
(
args
.
data_set
,
np
.
around
(
mapM
*
100
,
decimals
=
2
),
np
.
around
(
mapH
*
100
,
decimals
=
2
)))
print
(
'
>> {}: mP@k{} M: {}, H: {}
'
.
format
(
args
.
data_set
,
np
.
array
(
ks
),
np
.
around
(
mprM
*
100
,
decimals
=
2
),
np
.
around
(
mprH
*
100
,
decimals
=
2
)))
log_stats
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment