Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GenVQA
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vision
GenVQA
Commits
4863d27a
Commit
4863d27a
authored
8 years ago
by
tgupta6
Browse files
Options
Downloads
Patches
Plain Diff
freq_acc_plot modified to read in object_labels.json
parent
5a14825e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
object_attribute_classifier_cached_features/freq_acc_plot.py
+23
-15
23 additions, 15 deletions
object_attribute_classifier_cached_features/freq_acc_plot.py
with
23 additions
and
15 deletions
object_attribute_classifier_cached_features/freq_acc_plot.py
+
23
−
15
View file @
4863d27a
...
...
@@ -13,6 +13,10 @@ import constants
pp
=
pprint
.
PrettyPrinter
(
indent
=
4
)
if
__name__
==
'
__main__
'
:
print
'
Reading {}
'
.
format
(
constants
.
object_labels_json
)
with
open
(
constants
.
object_labels_json
)
as
file
:
object_labels_dict
=
ujson
.
load
(
file
)
print
'
Reading {}
'
.
format
(
constants
.
eval_regions_json
)
with
open
(
constants
.
regions_json
)
as
file
:
all_regions_data
=
ujson
.
load
(
file
)
...
...
@@ -32,37 +36,41 @@ if __name__=='__main__':
obj_train_freq_dict
=
dict
()
obj_test_freq_dict
=
dict
()
obj_hit_dict
=
dict
()
for
obj
in
object_labels_dict
.
keys
():
obj_train_freq_dict
[
obj
]
=
0
obj_test_freq_dict
[
obj
]
=
0
obj_hit_dict
[
obj
]
=
0
for
region_id
in
train_region_ids
:
region_data
=
all_regions_data
[
region_id
]
for
obj
in
region_data
[
'
object_names
'
]:
if
obj
not
in
obj_train_freq_dict
:
obj_train_freq_dict
[
obj
]
=
0
obj_train_freq_dict
[
obj
]
+=
1
obj_train_freq_dict
[
constants
.
unknown_token
]
+
=
1
else
:
obj_train_freq_dict
[
obj
]
+=
1
for
region_id
,
pred_dict
in
obj_pred_data
.
items
():
for
obj
in
pred_dict
[
'
gt
'
]:
if
obj
not
in
obj_hit_dict
:
obj_hit_dict
[
obj
]
=
0
if
obj
in
pred_dict
[
'
pred
'
]:
obj_hit_dict
[
obj
]
+=
1
if
obj
not
in
obj_test_freq_dict
:
obj_test_freq_dict
[
obj
]
=
1
else
:
if
obj
in
obj_test_freq_dict
:
obj_test_freq_dict
[
obj
]
+=
1
else
:
obj_test_freq_dict
[
constants
.
unknown_token
]
+=
1
AccFreqData
=
namedtuple
(
'
AccFreqData
'
,[
'
label
'
,
'
acc
'
,
'
hits
'
,
'
train_freq
'
,
'
test_freq
'
])
records
=
[]
for
obj
,
hits
in
obj_hit_dict
.
items
():
if
obj
not
in
obj_train_freq_dict
:
obj_train_freq_dict
[
obj
]
=
0
# if obj not in obj_train_freq_dict:
# obj_train_freq_dict[obj] = 0
if
obj
==
constants
.
unknown_token
:
pass
records
+=
[
AccFreqData
(
label
=
obj
,
acc
=
float
(
hits
+
1e-5
)
/
float
(
obj_test_freq_dict
[
obj
]
+
1e-5
),
...
...
@@ -81,7 +89,7 @@ if __name__=='__main__':
'
1000
'
:
0
,
'
5000
'
:
0
,
'
10000
'
:
0
,
'
many
'
:
0
,
'
many
'
:
0
,
}
rarity_counts
=
{
...
...
@@ -92,7 +100,7 @@ if __name__=='__main__':
'
1000
'
:
0
,
'
5000
'
:
0
,
'
10000
'
:
0
,
'
many
'
:
0
,
'
many
'
:
0
,
}
for
record
in
sorted_records
:
...
...
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