Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Packages
signaturizer
Commits
e617fae1
Commit
e617fae1
authored
Jul 02, 2020
by
Martino Bertoni
🌋
Browse files
updated reference url, fixed local model logic
parent
8c73651f
Changes
1
Hide whitespace changes
Inline
Side-by-side
signaturizer/signaturizer.py
View file @
e617fae1
...
...
@@ -18,8 +18,8 @@ class Signaturizer(object):
"""Class loading TF-hub module and performing predictions."""
def
__init__
(
self
,
model_name
,
base_url
=
"
file:///aloy/web_checker/exported_smilespreds
/"
,
tf_version
=
1
,
verbose
=
True
):
base_url
=
"
http://chemicalchecker.com/api/db/getSignaturizer
/"
,
version
=
'v1'
,
local
=
False
,
tf_version
=
'1'
,
verbose
=
True
):
"""Initialize the Signaturizer.
Args:
...
...
@@ -30,6 +30,9 @@ class Signaturizer(object):
- 'GLOBAL' to get the global (i.e. horizontally stacked)
bioactivity signature.
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.
verbose(bool): If True some more information will be printed.
"""
...
...
@@ -47,15 +50,19 @@ class Signaturizer(object):
self
.
graph
=
tf
.
Graph
()
with
self
.
graph
.
as_default
():
for
model
in
models
:
if
os
.
path
.
isdir
(
model
):
if
self
.
verbose
:
print
(
'LOADING local:'
,
model
)
spec
=
hub
.
create_module_spec_from_saved_model
(
model
)
module
=
hub
.
Module
(
spec
,
tags
=
[
'serve'
])
if
local
:
if
os
.
path
.
isdir
(
model
):
if
self
.
verbose
:
print
(
'LOADING local:'
,
model
)
spec
=
hub
.
create_module_spec_from_saved_model
(
model
)
module
=
hub
.
Module
(
spec
,
tags
=
[
'serve'
])
else
:
raise
Exception
(
'Module path not found!'
)
else
:
url
=
base_url
+
'%s/%s'
%
(
version
,
model
)
if
self
.
verbose
:
print
(
'LOADING remote:'
,
base_url
+
mode
l
)
module
=
hub
.
Module
(
base_url
+
mode
l
,
tags
=
[
'serve'
])
print
(
'LOADING remote:'
,
ur
l
)
module
=
hub
.
Module
(
ur
l
,
tags
=
[
'serve'
])
self
.
modules
.
append
(
module
)
self
.
model_names
.
append
(
model
)
...
...
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