Commit e617fae1 authored by Martino Bertoni's avatar Martino Bertoni 🌋
Browse files

updated reference url, fixed local model logic

parent 8c73651f
...@@ -18,8 +18,8 @@ class Signaturizer(object): ...@@ -18,8 +18,8 @@ class Signaturizer(object):
"""Class loading TF-hub module and performing predictions.""" """Class loading TF-hub module and performing predictions."""
def __init__(self, model_name, def __init__(self, model_name,
base_url="file:///aloy/web_checker/exported_smilespreds/", base_url="http://chemicalchecker.com/api/db/getSignaturizer/",
tf_version=1, verbose=True): version='v1', local=False, tf_version='1', verbose=True):
"""Initialize the Signaturizer. """Initialize the Signaturizer.
Args: Args:
...@@ -30,6 +30,9 @@ class Signaturizer(object): ...@@ -30,6 +30,9 @@ class Signaturizer(object):
- 'GLOBAL' to get the global (i.e. horizontally stacked) - 'GLOBAL' to get the global (i.e. horizontally stacked)
bioactivity signature. bioactivity signature.
base_url(str): The ChemicalChecker getModel API URL. base_url(str): The ChemicalChecker getModel API URL.
version(int): Signaturizer version.
local(bool): Wethere the specified model_name shoudl be
interpreted as a path to a local model.
tf_version(int): The Tesorflow version. tf_version(int): The Tesorflow version.
verbose(bool): If True some more information will be printed. verbose(bool): If True some more information will be printed.
""" """
...@@ -47,15 +50,19 @@ class Signaturizer(object): ...@@ -47,15 +50,19 @@ class Signaturizer(object):
self.graph = tf.Graph() self.graph = tf.Graph()
with self.graph.as_default(): with self.graph.as_default():
for model in models: for model in models:
if os.path.isdir(model): if local:
if self.verbose: if os.path.isdir(model):
print('LOADING local:', model) if self.verbose:
spec = hub.create_module_spec_from_saved_model(model) print('LOADING local:', model)
module = hub.Module(spec, tags=['serve']) spec = hub.create_module_spec_from_saved_model(model)
module = hub.Module(spec, tags=['serve'])
else:
raise Exception('Module path not found!')
else: else:
url = base_url + '%s/%s' % (version, model)
if self.verbose: if self.verbose:
print('LOADING remote:', base_url + model) print('LOADING remote:', url)
module = hub.Module(base_url + model, tags=['serve']) module = hub.Module(url, tags=['serve'])
self.modules.append(module) self.modules.append(module)
self.model_names.append(model) self.model_names.append(model)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment