Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
b1123cfd
Unverified
Commit
b1123cfd
authored
Feb 15, 2024
by
Philip Meier
Committed by
GitHub
Feb 15, 2024
Browse files
cleanup download utils (#8273)
parent
f21c6bd8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
17 deletions
+5
-17
torchvision/datasets/utils.py
torchvision/datasets/utils.py
+5
-17
No files found.
torchvision/datasets/utils.py
View file @
b1123cfd
...
@@ -12,7 +12,7 @@ import urllib
...
@@ -12,7 +12,7 @@ import urllib
import
urllib.error
import
urllib.error
import
urllib.request
import
urllib.request
import
zipfile
import
zipfile
from
typing
import
Any
,
Callable
,
Dict
,
IO
,
Iterable
,
Iterator
,
List
,
Optional
,
Tuple
,
TypeVar
,
Union
from
typing
import
Any
,
Callable
,
Dict
,
IO
,
Iterable
,
List
,
Optional
,
Tuple
,
TypeVar
,
Union
from
urllib.parse
import
urlparse
from
urllib.parse
import
urlparse
import
numpy
as
np
import
numpy
as
np
...
@@ -24,24 +24,12 @@ from .._internally_replaced_utils import _download_file_from_remote_location, _i
...
@@ -24,24 +24,12 @@ from .._internally_replaced_utils import _download_file_from_remote_location, _i
USER_AGENT
=
"pytorch/vision"
USER_AGENT
=
"pytorch/vision"
def
_save_response_content
(
content
:
Iterator
[
bytes
],
destination
:
Union
[
str
,
pathlib
.
Path
],
length
:
Optional
[
int
]
=
None
,
)
->
None
:
with
open
(
destination
,
"wb"
)
as
fh
,
tqdm
(
total
=
length
)
as
pbar
:
for
chunk
in
content
:
# filter out keep-alive new chunks
if
not
chunk
:
continue
fh
.
write
(
chunk
)
pbar
.
update
(
len
(
chunk
))
def
_urlretrieve
(
url
:
str
,
filename
:
Union
[
str
,
pathlib
.
Path
],
chunk_size
:
int
=
1024
*
32
)
->
None
:
def
_urlretrieve
(
url
:
str
,
filename
:
Union
[
str
,
pathlib
.
Path
],
chunk_size
:
int
=
1024
*
32
)
->
None
:
with
urllib
.
request
.
urlopen
(
urllib
.
request
.
Request
(
url
,
headers
=
{
"User-Agent"
:
USER_AGENT
}))
as
response
:
with
urllib
.
request
.
urlopen
(
urllib
.
request
.
Request
(
url
,
headers
=
{
"User-Agent"
:
USER_AGENT
}))
as
response
:
_save_response_content
(
iter
(
lambda
:
response
.
read
(
chunk_size
),
b
""
),
filename
,
length
=
response
.
length
)
with
open
(
filename
,
"wb"
)
as
fh
,
tqdm
(
total
=
response
.
length
)
as
pbar
:
while
chunk
:
=
response
.
read
(
chunk_size
):
fh
.
write
(
chunk
)
pbar
.
update
(
len
(
chunk
))
def
calculate_md5
(
fpath
:
Union
[
str
,
pathlib
.
Path
],
chunk_size
:
int
=
1024
*
1024
)
->
str
:
def
calculate_md5
(
fpath
:
Union
[
str
,
pathlib
.
Path
],
chunk_size
:
int
=
1024
*
1024
)
->
str
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment