File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -39,9 +39,14 @@ These models are extracted from Torch7 models and currently used in the project.
39
39
40
40
** Original Torch7 models**
41
41
42
+ Manually download the model files.
42
43
- Download pretrained networks via the following [ link] ( https://drive.google.com/open?id=1ENgQm9TgabE1R99zhNf5q6meBvX6WFuq ) .
43
44
- Unzip and store the model files under ` models ` .
44
45
46
+ Automatically downloads pretrained networks and unzips them.
47
+ - Requires requests (` pip install requests ` )
48
+ - ` bash download_models.sh `
49
+
45
50
` converter.py ` shows how to convert Torch7 models to PyTorch models.
46
51
47
52
### Example 1: Transfer the style of a style photo to a content photo.
Original file line number Diff line number Diff line change
1
+ # Download code taken from Code taken from https://stackoverflow.com/questions/25010369/wget-curl-large-file-from-google-drive/39225039#39225039
2
+ import requests
3
+
4
+ def download_file_from_google_drive (id , destination ):
5
+ URL = "https://docs.google.com/uc?export=download"
6
+
7
+ session = requests .Session ()
8
+
9
+ response = session .get (URL , params = { 'id' : id }, stream = True )
10
+ token = get_confirm_token (response )
11
+
12
+ if token :
13
+ params = { 'id' : id , 'confirm' : token }
14
+ response = session .get (URL , params = params , stream = True )
15
+
16
+ save_response_content (response , destination )
17
+
18
+ def get_confirm_token (response ):
19
+ for key , value in response .cookies .items ():
20
+ if key .startswith ('download_warning' ):
21
+ return value
22
+
23
+ return None
24
+
25
+ def save_response_content (response , destination ):
26
+ CHUNK_SIZE = 32768
27
+
28
+ with open (destination , "wb" ) as f :
29
+ for chunk in response .iter_content (CHUNK_SIZE ):
30
+ if chunk : # filter out keep-alive new chunks
31
+ f .write (chunk )
32
+
33
+ file_id = '1ENgQm9TgabE1R99zhNf5q6meBvX6WFuq'
34
+ destination = './models.zip'
35
+ download_file_from_google_drive (file_id , destination )
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ python download_models.py
3
+ unzip models.zip
You can’t perform that action at this time.
0 commit comments