-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hoon Kim
authored and
Hoon Kim
committed
Mar 11, 2019
1 parent
61f0b7a
commit 5ce036e
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import requests, os | ||
|
||
def download_file_from_google_drive(id, destination): | ||
URL = "https://docs.google.com/uc?export=download" | ||
|
||
session = requests.Session() | ||
|
||
response = session.get(URL, params = { 'id' : id }, stream = True) | ||
token = get_confirm_token(response) | ||
|
||
if token: | ||
params = { 'id' : id, 'confirm' : token } | ||
response = session.get(URL, params = params, stream = True) | ||
|
||
save_response_content(response, destination) | ||
|
||
def get_confirm_token(response): | ||
for key, value in response.cookies.items(): | ||
if key.startswith('download_warning'): | ||
return value | ||
|
||
return None | ||
|
||
def save_response_content(response, destination): | ||
CHUNK_SIZE = 32768 | ||
|
||
with open(destination, "wb") as f: | ||
for chunk in response.iter_content(CHUNK_SIZE): | ||
if chunk: # filter out keep-alive new chunks | ||
f.write(chunk) | ||
|
||
if __name__ == "__main__": | ||
print("Downloading pretrained model...") | ||
file_id = str("1ZNJSAN-96CVUakwtd1YMW70t2YXSVIdn") | ||
destination = str("./checkpoints/gtaCrash.1.0.t-1.8.zip") | ||
download_file_from_google_drive(file_id, destination) | ||
print("Download completed!") | ||
|
||
print("Unzipping pretrained model...") | ||
os.system("unzip ./checkpoints/gtaCrash.1.0.t-1.8.zip -d ./checkpoints") | ||
print("Unzipping completed!") | ||
|
||
os.system("rm ./checkpoints/gtaCrash.1.0.t-1.8.zip") | ||
print("Zip file removed") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters