Browse Source

Workaround pytorch/pytorch#40013

Lutz Roeder 5 years ago
parent
commit
9989411c61
3 changed files with 48 additions and 39 deletions
  1. 30 30
      test/models.json
  2. 14 5
      tools/pytorch
  3. 4 4
      tools/tf

+ 30 - 30
test/models.json

@@ -3677,28 +3677,28 @@
   {
     "type":   "pytorch",
     "target": "alexnet.pkl.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "format": "PyTorch v0.1.10",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "alexnet.zip.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "format": "PyTorch v1.6",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "alexnet.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "format": "TorchScript v1.6",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "alexnet_traced.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "format": "TorchScript v1.6",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
@@ -3767,27 +3767,27 @@
   {
     "type":   "pytorch",
     "target": "densenet161.pkl.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "format": "PyTorch v0.1.10",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "densenet161.zip.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "densenet161.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "action": "skip-render",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "densenet161_traced.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "action": "skip-render",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
@@ -3807,26 +3807,26 @@
   {
     "type":   "pytorch",
     "target": "inception_v3.pkl.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "format": "PyTorch v0.1.10",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "inception_v3.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "inception_v3.zip.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "inception_v3_traced.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
@@ -3930,20 +3930,20 @@
   {
     "type":   "pytorch",
     "target": "mobilenet_v2.pkl.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "format": "PyTorch v0.1.10",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "mobilenet_v2.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "mobilenet_v2_traced.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
@@ -4033,26 +4033,26 @@
   {
     "type":   "pytorch",
     "target": "r3d_18.pkl.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "format": "PyTorch v0.1.10",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "r3d_18.zip.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "r3d_18.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "r3d_18_traced.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
@@ -4093,25 +4093,25 @@
   {
     "type":   "pytorch",
     "target": "resnet101.pkl.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "resnet101.zip.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "resnet101.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "resnet101_traced.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
@@ -4152,20 +4152,20 @@
   {
     "type":   "pytorch",
     "target": "shufflenet_v2_x1_0.pkl.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "format": "PyTorch v0.1.10",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "shufflenet_v2_x1_0.zip.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "shufflenet_v2_x1_0.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "action": "skip-render",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
@@ -4178,26 +4178,26 @@
   {
     "type":   "pytorch",
     "target": "squeezenet1_1.pkl.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "format": "PyTorch v0.1.10",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "squeezenet1_1.zip.pth",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "squeezenet1_1.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {
     "type":   "pytorch",
     "target": "squeezenet1_1_traced.pt",
-    "script": "./tools/pytorch sync install zoo",
+    "script": "./tools/pytorch zoo",
     "link":   "https://pytorch.org/docs/stable/torchvision/models.html"
   },
   {

+ 14 - 5
tools/pytorch

@@ -42,7 +42,7 @@ install() {
     bold "pytorch install"
     venv
     ${python} -m pip install --quiet --upgrade future protobuf scipy
-    ${python} -m pip install --quiet --upgrade --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
+    ${python} -m pip install --quiet --upgrade --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
     deactivate
 }
 
@@ -57,26 +57,35 @@ schema() {
 }
 
 metadata() {
-    [[ $(grep -U $'\x0D' ./src/pytorch-metadata.json) ]] && crlf=1
+    bold "pytorch metadata"
     venv
     export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
-    bold "pytorch metadata"
+    if [[ $(grep -U $'\x0D' ./src/pytorch-metadata.json) ]]; then crlf=1; else crlf=; fi
     ${python} ./tools/pytorch-script.py metadata
+    if [[ -n ${crlf} ]]; then
+        unix2dos --quiet --newfile ./src/pytorch-metadata.json ./src/pytorch-metadata.json
+    fi
+    deactivate
     bold "caffe2 metadata"
+    venv
+    if [[ $(grep -U $'\x0D' ./src/caffe2-metadata.json) ]]; then crlf=1; else crlf=; fi
     ${python} ./tools/caffe2-script.py metadata
-    deactivate
     if [[ -n ${crlf} ]]; then
-        unix2dos --quiet --newfile ./src/pytorch-metadata.json ./src/pytorch-metadata.json
         unix2dos --quiet --newfile ./src/caffe2-metadata.json ./src/caffe2-metadata.json
     fi
+    deactivate
 }
 
 zoo() {
     bold "pytorch zoo"
+    rm -rf "./third_party/env/pytorch"
     venv
+    ${python} -m pip install --quiet --upgrade future protobuf scipy
+    ${python} -m pip install --quiet --upgrade --pre torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
     export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
     ${python} ./tools/pytorch-script.py zoo
     deactivate
+    rm -rf "./third_party/env/pytorch"
 }
 
 while [ "$#" != 0 ]; do

+ 4 - 4
tools/tf

@@ -128,7 +128,6 @@ EOT
 
 metadata() {
     bold "tf metadata"
-    [[ $(grep -U $'\x0D' ./src/tf-metadata.json) ]] && crlf=1
     venv
     # case "${OSTYPE}" in
     #     linux*)
@@ -163,21 +162,22 @@ metadata() {
     #touch ${temp}/tensorflow/core/__init__.py
     #touch ${temp}/tensorflow/core/framework/__init__.py
     # export PYTHONPATH="${temp}:${PYTHONPATH}"
+    if [[ $(grep -U $'\x0D' ./src/tf-metadata.json) ]]; then crlf=1; else crlf=; fi
     export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
     ${python} ./tools/tf-script.py metadata
     # rm -rf ${temp}
-    deactivate
     if [[ -n ${crlf} ]]; then
         unix2dos --quiet --newfile ./src/tf-metadata.json ./src/tf-metadata.json
     fi
+    deactivate
     bold "keras metadata"
-    [[ $(grep -U $'\x0D' ./src/tf-metadata.json) ]] && crlf=1
     venv
+    if [[ $(grep -U $'\x0D' ./src/keras-metadata.json) ]]; then crlf=1; else crlf=; fi
     ${python} ./tools/keras-script.py metadata
-    deactivate
     if [[ -n ${crlf} ]]; then
         unix2dos --quiet --newfile ./src/keras-metadata.json ./src/keras-metadata.json
     fi
+    deactivate
 }
 
 zoo() {