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
ModelZoo
ResNet50_tensorflow
Commits
3e34dbde
Commit
3e34dbde
authored
Mar 26, 2018
by
Fahim Mannan
Browse files
deeplab_demo notebook py2 and py3 support
parent
08af7775
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
research/deeplab/deeplab_demo.ipynb
research/deeplab/deeplab_demo.ipynb
+10
-10
No files found.
research/deeplab/deeplab_demo.ipynb
View file @
3e34dbde
...
...
@@ -31,10 +31,10 @@
"#@title Imports\n",
"\n",
"import os\n",
"import
String
IO\n",
"
from io
import
Bytes
IO\n",
"import tarfile\n",
"import tempfile\n",
"import urllib\n",
"
from six.moves
import urllib\n",
"\n",
"from matplotlib import gridspec\n",
"from matplotlib import pyplot as plt\n",
...
...
@@ -238,13 +238,13 @@
"tf.gfile.MakeDirs(model_dir)\n",
"\n",
"download_path = os.path.join(model_dir, _TARBALL_NAME)\n",
"print
'downloading model, this might take a while...'\n",
"urllib.urlretrieve(_DOWNLOAD_URL_PREFIX + _MODEL_URLS[MODEL_NAME],\n",
"print
(
'downloading model, this might take a while...'
)
\n",
"urllib.
request.
urlretrieve(_DOWNLOAD_URL_PREFIX + _MODEL_URLS[MODEL_NAME],\n",
" download_path)\n",
"print
'download completed! loading DeepLab model...'\n",
"print
(
'download completed! loading DeepLab model...'
)
\n",
"\n",
"MODEL = DeepLabModel(download_path)\n",
"print
'model loaded successfully!'"
"print
(
'model loaded successfully!'
)
"
]
},
{
...
...
@@ -292,14 +292,14 @@
"def run_visualization(url):\n",
" \"\"\"Inferences DeepLab model and visualizes result.\"\"\"\n",
" try:\n",
" f = urllib.urlopen(url)\n",
" f = urllib.
request.
urlopen(url)\n",
" jpeg_str = f.read()\n",
" orignal_im = Image.open(
StringIO.String
IO(jpeg_str))\n",
" orignal_im = Image.open(
Bytes
IO(jpeg_str))\n",
" except IOError:\n",
" print
'Cannot retrieve image. Please check url: ' + url\n",
" print
(
'Cannot retrieve image. Please check url: ' + url
)
\n",
" return\n",
"\n",
" print
'running deeplab on image %s...' % url\n",
" print
(
'running deeplab on image %s...' % url
)
\n",
" resized_im, seg_map = MODEL.run(orignal_im)\n",
"\n",
" vis_segmentation(resized_im, seg_map)\n",
...
...
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