Skip to content
Snippets Groups Projects
Commit 73c665b3 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Removed download_function

Putting back the old path. I need to be able to debug it in my desktop

Added some documentation
parent 373dd226
No related branches found
No related tags found
1 merge request!7Replaced the download_model method to the new one implemented in bob.extension
Pipeline #
...@@ -6,7 +6,6 @@ import numpy ...@@ -6,7 +6,6 @@ import numpy
import tensorflow as tf import tensorflow as tf
import os import os
from bob.extension import rc from bob.extension import rc
from . import download_file
import logging import logging
import bob.extension.download import bob.extension.download
import bob.io.base import bob.io.base
...@@ -358,7 +357,7 @@ class DrGanMSUExtractor(object): ...@@ -358,7 +357,7 @@ class DrGanMSUExtractor(object):
"DR_GAN_model.zip") "DR_GAN_model.zip")
urls = [ urls = [
# This is a private link at Idiap to save bandwidth. # This is a private link at Idiap to save bandwidth.
"http://www.idiap.ch/private/wheels/gitlab/" "http://beatubulatest.lab.idiap.ch/private/wheels/gitlab/"
"DR_GAN_model.zip", "DR_GAN_model.zip",
] ]
......
...@@ -6,7 +6,6 @@ import numpy ...@@ -6,7 +6,6 @@ import numpy
import tensorflow as tf import tensorflow as tf
from bob.ip.color import gray_to_rgb from bob.ip.color import gray_to_rgb
from bob.io.image import to_matplotlib from bob.io.image import to_matplotlib
from . import download_file
from bob.extension import rc from bob.extension import rc
import bob.extension.download import bob.extension.download
import bob.io.base import bob.io.base
...@@ -77,7 +76,7 @@ class FaceNet(object): ...@@ -77,7 +76,7 @@ class FaceNet(object):
def __init__(self, def __init__(self,
model_path=rc["bob.ip.tensorflow_extractor.facenet_modelpath"], model_path=rc["bob.ip.tensorflow_extractor.facenet_modelpath"],
image_size=160, image_size=160,
**kwargs): **kwargs):
super(FaceNet, self).__init__() super(FaceNet, self).__init__()
self.model_path = model_path self.model_path = model_path
self.image_size = image_size self.image_size = image_size
...@@ -103,16 +102,14 @@ class FaceNet(object): ...@@ -103,16 +102,14 @@ class FaceNet(object):
"20170512-110547.zip") "20170512-110547.zip")
urls = [ urls = [
# This is a private link at Idiap to save bandwidth. # This is a private link at Idiap to save bandwidth.
"http://www.idiap.ch/private/wheels/gitlab/" "http://beatubulatest.lab.idiap.ch/private/wheels/gitlab/"
"facenet_model2_20170512-110547.zip", "facenet_model2_20170512-110547.zip",
# this works for everybody # this works for everybody
"https://drive.google.com/uc?export=download&id=" "https://drive.google.com/uc?export=download&id="
"0B5MzpY9kBtDVZ2RpVDYwWmxoSUk", "0B5MzpY9kBtDVZ2RpVDYwWmxoSUk",
] ]
bob.extension.download.download_and_unzip(urls, zip_file) bob.extension.download.download_and_unzip(urls, zip_file)
# code from https://github.com/davidsandberg/facenet # code from https://github.com/davidsandberg/facenet
model_exp = os.path.expanduser(self.model_path) model_exp = os.path.expanduser(self.model_path)
if (os.path.isfile(model_exp)): if (os.path.isfile(model_exp)):
...@@ -157,10 +154,20 @@ class FaceNet(object): ...@@ -157,10 +154,20 @@ class FaceNet(object):
@staticmethod @staticmethod
def get_rcvariable(): def get_rcvariable():
"""
Variable name used in the Bob Global Configuration System
https://www.idiap.ch/software/bob/docs/bob/bob.extension/stable/rc.html#global-configuration-system
"""
return "bob.ip.tensorflow_extractor.facenet_modelpath" return "bob.ip.tensorflow_extractor.facenet_modelpath"
@staticmethod @staticmethod
def get_modelpath(): def get_modelpath():
"""
Get default model path.
First we try the to search this path via Global Configuration System.
If we can not find it, we set the path in the directory `<project>/data`
"""
# Priority to the RC path # Priority to the RC path
model_path = rc[FaceNet.get_rcvariable()] model_path = rc[FaceNet.get_rcvariable()]
......
...@@ -26,37 +26,6 @@ def scratch_network(inputs, end_point="fc1", reuse=False): ...@@ -26,37 +26,6 @@ def scratch_network(inputs, end_point="fc1", reuse=False):
return end_points[end_point] return end_points[end_point]
def download_file(url, out_file):
"""Downloads a file from a given url
Parameters
----------
url : str
The url to download form.
out_file : str
Where to save the file.
"""
from bob.io.base import create_directories_safe
import os
create_directories_safe(os.path.dirname(out_file))
import sys
if sys.version_info[0] < 3:
# python2 technique for downloading a file
from urllib2 import urlopen
with open(out_file, 'wb') as f:
response = urlopen(url)
f.write(response.read())
else:
# python3 technique for downloading a file
from urllib.request import urlopen
from shutil import copyfileobj
with urlopen(url) as response:
with open(out_file, 'wb') as f:
copyfileobj(response, f)
def get_config(): def get_config():
"""Returns a string containing the configuration information. """Returns a string containing the configuration information.
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment