FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
InternVideo/Data/InternVid/div_sampling.py at main · OpenGVLab/InternVideo · GitHub
OpenGVLab
/
InternVideo
Public
Notifications
You must be signed in to change notification settings
Fork
160
Star
2.4k
Code
Issues
143
Pull requests
4
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
InternVideo
/
Data
/
InternVid
/
div_sampling.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
14 lines (14 loc) · 651 Bytes
Breadcrumbs
InternVideo
/
Data
/
InternVid
/
div_sampling.py
Copy path
File metadata and controls
14 lines (14 loc) · 651 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from
collections
import
Counter
import
json
import
random
import
numpy
as
np
data
=
json
.
load
(
open
(
"/path/to/to_sample"
))
video_id
=
set
([
x
[
"video"
].
split
(
"/"
)[
-
1
][:
11
]
for
x
in
data
])
video_id_counter
=
Counter
([
x
[
"video"
].
split
(
"/"
)[
-
1
][:
11
]
for
x
in
data
])
sampling_weights
=
[
1.0
/
video_id_counter
[
x
[
"video"
].
split
(
"/"
)[
-
1
][:
11
]]
for
x
in
data
]
np
.
random
.
seed
(
42
)
sampling_weights
=
np
.
array
(
sampling_weights
)
sampling_weights
=
sampling_weights
/
sampling_weights
.
sum
()
sampled_index
=
np
.
random
.
choice
(
len
(
data
),
10647458
,
replace
=
False
,
p
=
sampling_weights
)
data
=
[
data
[
i
]
for
i
in
sampled_index
]
json
.
dump
(
data
,
open
(
"/path/to/sampled"
,
"w"
))
Back
|
FazBrowse Home
|
New Git URL