Update fragment_embedder.py
Browse files- fragment_embedder.py +7 -5
fragment_embedder.py
CHANGED
|
@@ -14,11 +14,11 @@ CHUNKSIZE = 1024
|
|
| 14 |
|
| 15 |
class FragmentEmbedder(object):
|
| 16 |
def __init__(self):
|
| 17 |
-
|
| 18 |
url = 'https://huggingface.co/ligdis/fpred/resolve/main/morgan_descriptor.joblib' # The URL of the file you want to load
|
| 19 |
with urllib.request.urlopen(url) as response: # Download the file
|
| 20 |
self.morgan_desc = joblib.load(BytesIO(response.read()))
|
| 21 |
-
|
| 22 |
url = 'https://huggingface.co/ligdis/fpred/resolve/main/physchem_descriptor.joblib' # The URL of the file you want to load
|
| 23 |
with urllib.request.urlopen(url) as response: # Download the file
|
| 24 |
self.physchem_desc = joblib.load(BytesIO(response.read()))
|
|
@@ -28,12 +28,13 @@ class FragmentEmbedder(object):
|
|
| 28 |
yield l[i : i + n]
|
| 29 |
|
| 30 |
def encoder_inference(self, X):
|
| 31 |
-
# sess = rt.InferenceSession(os.path.join(self.models_dir, "encoder_model.onnx"))
|
| 32 |
url = 'https://huggingface.co/ligdis/fpred/resolve/main/encoder_model.onnx'
|
| 33 |
response = requests.get(url)
|
| 34 |
model_bytes = BytesIO(response.content) # Create a file-like object from the byte data
|
| 35 |
-
sess = rt.InferenceSession(model_bytes)
|
| 36 |
-
|
|
|
|
| 37 |
input_name = sess.get_inputs()[0].name
|
| 38 |
output_name = sess.get_outputs()[0].name
|
| 39 |
output_data = sess.run(
|
|
@@ -54,3 +55,4 @@ class FragmentEmbedder(object):
|
|
| 54 |
else:
|
| 55 |
X = np.vstack([X, X_o])
|
| 56 |
return X
|
|
|
|
|
|
| 14 |
|
| 15 |
class FragmentEmbedder(object):
|
| 16 |
def __init__(self):
|
| 17 |
+
|
| 18 |
url = 'https://huggingface.co/ligdis/fpred/resolve/main/morgan_descriptor.joblib' # The URL of the file you want to load
|
| 19 |
with urllib.request.urlopen(url) as response: # Download the file
|
| 20 |
self.morgan_desc = joblib.load(BytesIO(response.read()))
|
| 21 |
+
|
| 22 |
url = 'https://huggingface.co/ligdis/fpred/resolve/main/physchem_descriptor.joblib' # The URL of the file you want to load
|
| 23 |
with urllib.request.urlopen(url) as response: # Download the file
|
| 24 |
self.physchem_desc = joblib.load(BytesIO(response.read()))
|
|
|
|
| 28 |
yield l[i : i + n]
|
| 29 |
|
| 30 |
def encoder_inference(self, X):
|
| 31 |
+
# sess = rt.InferenceSession(os.path.join(self.models_dir, "encoder_model.onnx"))
|
| 32 |
url = 'https://huggingface.co/ligdis/fpred/resolve/main/encoder_model.onnx'
|
| 33 |
response = requests.get(url)
|
| 34 |
model_bytes = BytesIO(response.content) # Create a file-like object from the byte data
|
| 35 |
+
sess = rt.InferenceSession(model_bytes.read())
|
| 36 |
+
|
| 37 |
+
|
| 38 |
input_name = sess.get_inputs()[0].name
|
| 39 |
output_name = sess.get_outputs()[0].name
|
| 40 |
output_data = sess.run(
|
|
|
|
| 55 |
else:
|
| 56 |
X = np.vstack([X, X_o])
|
| 57 |
return X
|
| 58 |
+
|