decimer 2.6.0__tar.gz → 2.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/DECIMER_EfficinetNetV2_Transfomer_Trainer.py +3 -3
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/Predictor_usingCheckpoints.py +1 -1
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/Repack_model.py +4 -4
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/Utils/Create_image_tokenizer.py +1 -1
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/__init__.py +29 -29
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/config.py +3 -3
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/decimer.py +2 -2
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/efficientnetv2/effnetv2_model.py +1 -1
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/utils.py +9 -6
- {decimer-2.6.0/decimer.egg-info → decimer-2.7.0}/PKG-INFO +3 -3
- {decimer-2.6.0 → decimer-2.7.0}/README.md +1 -1
- {decimer-2.6.0 → decimer-2.7.0/decimer.egg-info}/PKG-INFO +3 -3
- {decimer-2.6.0 → decimer-2.7.0}/decimer.egg-info/SOURCES.txt +1 -0
- decimer-2.7.0/decimer.egg-info/entry_points.txt +2 -0
- {decimer-2.6.0 → decimer-2.7.0}/decimer.egg-info/requires.txt +1 -1
- {decimer-2.6.0 → decimer-2.7.0}/setup.py +55 -52
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/Efficient_Net_encoder.py +0 -0
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/Transformer_decoder.py +0 -0
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/Utils/Create_TFrecord_From_pickles.py +0 -0
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/efficientnetv2/effnetv2_configs.py +0 -0
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/efficientnetv2/hparams.py +0 -0
- {decimer-2.6.0 → decimer-2.7.0}/DECIMER/efficientnetv2/utils.py +0 -0
- {decimer-2.6.0 → decimer-2.7.0}/LICENSE +0 -0
- {decimer-2.6.0 → decimer-2.7.0}/decimer.egg-info/dependency_links.txt +0 -0
- {decimer-2.6.0 → decimer-2.7.0}/decimer.egg-info/top_level.txt +0 -0
- {decimer-2.6.0 → decimer-2.7.0}/setup.cfg +0 -0
|
@@ -250,7 +250,7 @@ def prepare_for_training(lr_config, encoder_config, transformer_config, verbose=
|
|
|
250
250
|
transformer_config["d_model"], lr_config["warm_steps"]
|
|
251
251
|
)
|
|
252
252
|
|
|
253
|
-
#
|
|
253
|
+
# Instantiate an optimizer
|
|
254
254
|
optimizer = tf.keras.optimizers.Adam(
|
|
255
255
|
lr_scheduler, beta_1=0.9, beta_2=0.98, epsilon=1e-9
|
|
256
256
|
)
|
|
@@ -323,7 +323,7 @@ if ckpt_manager.latest_checkpoint:
|
|
|
323
323
|
start_epoch = int(ckpt_manager.latest_checkpoint.split("-")[-1])
|
|
324
324
|
|
|
325
325
|
|
|
326
|
-
# Main training step
|
|
326
|
+
# Main training step function
|
|
327
327
|
def train_step(image_batch, selfies_batch):
|
|
328
328
|
"""Main training step function.
|
|
329
329
|
|
|
@@ -376,7 +376,7 @@ def dist_train_step(image_batch, selfies_batch):
|
|
|
376
376
|
|
|
377
377
|
|
|
378
378
|
"""
|
|
379
|
-
# Main validation step
|
|
379
|
+
# Main validation step function
|
|
380
380
|
def validation_step(image_batch, selfies_batch):
|
|
381
381
|
|
|
382
382
|
selfies_batch_input = selfies_batch[:, :-1]
|
|
@@ -140,7 +140,7 @@ class DECIMER_Predictor(tf.Module):
|
|
|
140
140
|
It loads the saved checkpoint and the necessary tokenizers. The
|
|
141
141
|
inference begins with the start token (<start>) and ends when the
|
|
142
142
|
end token(<end>) is met. This class can only work with tf.Tensor
|
|
143
|
-
objects. The strings
|
|
143
|
+
objects. The strings should get transformed into np.arrays before
|
|
144
144
|
feeding them into this class.
|
|
145
145
|
"""
|
|
146
146
|
|
|
@@ -150,7 +150,7 @@ class DECIMER_Predictor(tf.Module):
|
|
|
150
150
|
|
|
151
151
|
Args:
|
|
152
152
|
encoder (tf.keras.model): The encoder model
|
|
153
|
-
tokenizer (tf.keras.tokenizer): Output tokenizer, defines which
|
|
153
|
+
tokenizer (tf.keras.tokenizer): Output tokenizer, defines which character is assigned to what token
|
|
154
154
|
transformer (tf.keras.model): The transformer model
|
|
155
155
|
max_length (int): Maximum length of a string which can get predicted
|
|
156
156
|
"""
|
|
@@ -160,7 +160,7 @@ class DECIMER_Predictor(tf.Module):
|
|
|
160
160
|
self.max_length = max_length
|
|
161
161
|
|
|
162
162
|
def __call__(self, Decoded_image):
|
|
163
|
-
"""This
|
|
163
|
+
"""This function takes in the Decoded image as input and makes the
|
|
164
164
|
predicted list of tokens and return the tokens as tf.Tensor array.
|
|
165
165
|
Before feeding the input array we must define start and the end tokens.
|
|
166
166
|
|
|
@@ -225,7 +225,7 @@ class ExportDECIMERPredictor(tf.Module):
|
|
|
225
225
|
|
|
226
226
|
@tf.function
|
|
227
227
|
def __call__(self, Decoded_Image):
|
|
228
|
-
"""This
|
|
228
|
+
"""This function calls the __call__function from the translator class.
|
|
229
229
|
In the tf.function only the output sentence is returned. Thanks to the
|
|
230
230
|
non-strict execution in tf.function any unnecessary values are never
|
|
231
231
|
computed.
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""DECIMER V2.6.0 Python Package. ============================
|
|
3
|
-
|
|
4
|
-
This repository contains DECIMER-V2,Deep lEarning for Chemical ImagE Recognition) project
|
|
5
|
-
was launched to address the OCSR problem with the latest computational intelligence methods
|
|
6
|
-
to provide an automated open-source software solution.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Typical usage example:
|
|
10
|
-
|
|
11
|
-
from decimer import predict_SMILES
|
|
12
|
-
|
|
13
|
-
# Chemical depiction to SMILES translation
|
|
14
|
-
image_path = "path/to/imagefile"
|
|
15
|
-
SMILES = predict_SMILES(image_path)
|
|
16
|
-
print(SMILES)
|
|
17
|
-
|
|
18
|
-
For comments, bug reports or feature ideas,
|
|
19
|
-
please raise a issue on the Github repository.
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
__version__ = "2.6.0"
|
|
23
|
-
|
|
24
|
-
__all__ = [
|
|
25
|
-
"DECIMER",
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
from .decimer import predict_SMILES
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""DECIMER V2.6.0 Python Package. ============================
|
|
3
|
+
|
|
4
|
+
This repository contains DECIMER-V2,Deep lEarning for Chemical ImagE Recognition) project
|
|
5
|
+
was launched to address the OCSR problem with the latest computational intelligence methods
|
|
6
|
+
to provide an automated open-source software solution.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Typical usage example:
|
|
10
|
+
|
|
11
|
+
from decimer import predict_SMILES
|
|
12
|
+
|
|
13
|
+
# Chemical depiction to SMILES translation
|
|
14
|
+
image_path = "path/to/imagefile"
|
|
15
|
+
SMILES = predict_SMILES(image_path)
|
|
16
|
+
print(SMILES)
|
|
17
|
+
|
|
18
|
+
For comments, bug reports or feature ideas,
|
|
19
|
+
please raise a issue on the Github repository.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
__version__ = "2.6.0"
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"DECIMER",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
from .decimer import predict_SMILES
|
|
@@ -232,7 +232,7 @@ class Config:
|
|
|
232
232
|
defined configurations.
|
|
233
233
|
|
|
234
234
|
Args:
|
|
235
|
-
image_embedding_dim (int): Embedding
|
|
235
|
+
image_embedding_dim (int): Embedding dimension of the input image
|
|
236
236
|
preprocessing_fn (method): Efficient Net preprocessing function for input image
|
|
237
237
|
backbone_fn (method): Calls Efficient-Net V2 as backbone for encoder
|
|
238
238
|
image_shape (int): Shape of the input image
|
|
@@ -267,7 +267,7 @@ class Config:
|
|
|
267
267
|
n_transformer_layers (int): Number of layers present in the transformer model
|
|
268
268
|
transformer_d_dff (int): Transformer feed forward upwards projection size
|
|
269
269
|
transformer_n_heads (int): Number of heads present in the transformer model
|
|
270
|
-
image_embedding_dim (int): Total number of dimension the image gets
|
|
270
|
+
image_embedding_dim (int): Total number of dimension the image gets embedded
|
|
271
271
|
dropout_rate (float, optional): Fraction of the input units to drop. Defaults to 0.1.
|
|
272
272
|
"""
|
|
273
273
|
self.transformer_config = dict(
|
|
@@ -330,7 +330,7 @@ def prepare_models(encoder_config, transformer_config, replica_batch_size, verbo
|
|
|
330
330
|
[type]: Optimizer, Encoder model and the Transformer
|
|
331
331
|
"""
|
|
332
332
|
|
|
333
|
-
#
|
|
333
|
+
# Instantiate an optimizer
|
|
334
334
|
optimizer = tf.keras.optimizers.Adam(learning_rate=0.00051)
|
|
335
335
|
|
|
336
336
|
# Instantiate the encoder model
|
|
@@ -71,7 +71,7 @@ tokenizer, DECIMER_V2, DECIMER_Hand_drawn = get_models(model_urls)
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
def detokenize_output(predicted_array: int) -> str:
|
|
74
|
-
"""This function takes the
|
|
74
|
+
"""This function takes the predicted tokens from the DECIMER model and
|
|
75
75
|
returns the decoded SMILES string.
|
|
76
76
|
|
|
77
77
|
Args:
|
|
@@ -117,7 +117,7 @@ def detokenize_output_add_confidence(
|
|
|
117
117
|
decoded_prediction_with_confidence = list(
|
|
118
118
|
[(utils.decoder(tok), conf) for tok, conf in prediction_with_confidence_]
|
|
119
119
|
)
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
return decoded_prediction_with_confidence
|
|
122
122
|
|
|
123
123
|
|
|
@@ -76,13 +76,17 @@ def ensure_models(default_path: str, model_urls: dict) -> dict:
|
|
|
76
76
|
dict: A dictionary containing model names as keys and their local paths as values
|
|
77
77
|
"""
|
|
78
78
|
model_paths = {}
|
|
79
|
-
|
|
79
|
+
# Store st_size of each model
|
|
80
|
+
model_sizes = {
|
|
81
|
+
"DECIMER": 28080309,
|
|
82
|
+
"DECIMER_HandDrawn": 28080328,
|
|
83
|
+
}
|
|
80
84
|
for model_name, model_url in model_urls.items():
|
|
81
85
|
model_path = os.path.join(default_path, f"{model_name}_model")
|
|
82
|
-
if (
|
|
83
|
-
os.path.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
if os.path.exists(model_path) and os.stat(
|
|
87
|
+
os.path.join(model_path, "saved_model.pb")
|
|
88
|
+
).st_size != model_sizes.get(model_name):
|
|
89
|
+
print(f"Working with model {model_name}")
|
|
86
90
|
shutil.rmtree(model_path)
|
|
87
91
|
config.download_trained_weights(model_url, default_path)
|
|
88
92
|
elif not os.path.exists(model_path):
|
|
@@ -90,5 +94,4 @@ def ensure_models(default_path: str, model_urls: dict) -> dict:
|
|
|
90
94
|
|
|
91
95
|
# Store the model path
|
|
92
96
|
model_paths[model_name] = model_path
|
|
93
|
-
|
|
94
97
|
return model_paths
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: decimer
|
|
3
|
-
Version: 2.
|
|
4
|
-
Summary: DECIMER 2.
|
|
3
|
+
Version: 2.7.0
|
|
4
|
+
Summary: DECIMER 2.6.0: Deep Learning for Chemical Image Recognition using Efficient-Net V2 + Transformer
|
|
5
5
|
Home-page: https://github.com/Kohulan/DECIMER-Image_Transformer
|
|
6
6
|
Author: Kohulan Rajan
|
|
7
7
|
Author-email: kohulan.rajan@uni-jena.de
|
|
@@ -111,7 +111,7 @@ print(SMILES)
|
|
|
111
111
|
- This project is licensed under the MIT License - see the [LICENSE](https://raw.githubusercontent.com/Kohulan/DECIMER-Image_Transformer/master/LICENSE?token=AHKLIF3EULMCUKCFUHIPBMDARSMDO) file for details
|
|
112
112
|
|
|
113
113
|
## Citation
|
|
114
|
-
- Rajan K, Brinkhaus HO, Agea MI, Zielesny A, Steinbeck C
|
|
114
|
+
- Rajan K, Brinkhaus HO, Agea MI, Zielesny A, Steinbeck C DECIMER.ai - An open platform for automated optical chemical structure identification, segmentation and recognition in scientific publications. Nat. Commun. 14, 5045 (2023). https://doi.org/10.1038/s41467-023-40782-0
|
|
115
115
|
- Rajan, K., Zielesny, A. & Steinbeck, C. DECIMER 1.0: deep learning for chemical image recognition using transformers. J Cheminform 13, 61 (2021). https://doi.org/10.1186/s13321-021-00538-8
|
|
116
116
|
|
|
117
117
|
## References
|
|
@@ -87,7 +87,7 @@ print(SMILES)
|
|
|
87
87
|
- This project is licensed under the MIT License - see the [LICENSE](https://raw.githubusercontent.com/Kohulan/DECIMER-Image_Transformer/master/LICENSE?token=AHKLIF3EULMCUKCFUHIPBMDARSMDO) file for details
|
|
88
88
|
|
|
89
89
|
## Citation
|
|
90
|
-
- Rajan K, Brinkhaus HO, Agea MI, Zielesny A, Steinbeck C
|
|
90
|
+
- Rajan K, Brinkhaus HO, Agea MI, Zielesny A, Steinbeck C DECIMER.ai - An open platform for automated optical chemical structure identification, segmentation and recognition in scientific publications. Nat. Commun. 14, 5045 (2023). https://doi.org/10.1038/s41467-023-40782-0
|
|
91
91
|
- Rajan, K., Zielesny, A. & Steinbeck, C. DECIMER 1.0: deep learning for chemical image recognition using transformers. J Cheminform 13, 61 (2021). https://doi.org/10.1186/s13321-021-00538-8
|
|
92
92
|
|
|
93
93
|
## References
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: decimer
|
|
3
|
-
Version: 2.
|
|
4
|
-
Summary: DECIMER 2.
|
|
3
|
+
Version: 2.7.0
|
|
4
|
+
Summary: DECIMER 2.6.0: Deep Learning for Chemical Image Recognition using Efficient-Net V2 + Transformer
|
|
5
5
|
Home-page: https://github.com/Kohulan/DECIMER-Image_Transformer
|
|
6
6
|
Author: Kohulan Rajan
|
|
7
7
|
Author-email: kohulan.rajan@uni-jena.de
|
|
@@ -111,7 +111,7 @@ print(SMILES)
|
|
|
111
111
|
- This project is licensed under the MIT License - see the [LICENSE](https://raw.githubusercontent.com/Kohulan/DECIMER-Image_Transformer/master/LICENSE?token=AHKLIF3EULMCUKCFUHIPBMDARSMDO) file for details
|
|
112
112
|
|
|
113
113
|
## Citation
|
|
114
|
-
- Rajan K, Brinkhaus HO, Agea MI, Zielesny A, Steinbeck C
|
|
114
|
+
- Rajan K, Brinkhaus HO, Agea MI, Zielesny A, Steinbeck C DECIMER.ai - An open platform for automated optical chemical structure identification, segmentation and recognition in scientific publications. Nat. Commun. 14, 5045 (2023). https://doi.org/10.1038/s41467-023-40782-0
|
|
115
115
|
- Rajan, K., Zielesny, A. & Steinbeck, C. DECIMER 1.0: deep learning for chemical image recognition using transformers. J Cheminform 13, 61 (2021). https://doi.org/10.1186/s13321-021-00538-8
|
|
116
116
|
|
|
117
117
|
## References
|
|
@@ -1,52 +1,55 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
import platform
|
|
3
|
-
|
|
4
|
-
import setuptools
|
|
5
|
-
|
|
6
|
-
if (
|
|
7
|
-
platform.processor() == "arm" or platform.processor() == "i386"
|
|
8
|
-
) and platform.system() == "Darwin":
|
|
9
|
-
tensorflow_os = "tensorflow-macos>=2.10.0"
|
|
10
|
-
else:
|
|
11
|
-
tensorflow_os = "tensorflow>=2.12.0"
|
|
12
|
-
|
|
13
|
-
with open("README.md", "r") as fh:
|
|
14
|
-
long_description = fh.read()
|
|
15
|
-
|
|
16
|
-
setuptools.setup(
|
|
17
|
-
name="decimer",
|
|
18
|
-
version="2.
|
|
19
|
-
author="Kohulan Rajan",
|
|
20
|
-
author_email="kohulan.rajan@uni-jena.de",
|
|
21
|
-
maintainer="Kohulan Rajan, Otto Brinkhaus ",
|
|
22
|
-
maintainer_email="kohulan.rajan@uni-jena.de, otto.brinkhaus@uni-jena.de",
|
|
23
|
-
description="DECIMER 2.
|
|
24
|
-
long_description=long_description,
|
|
25
|
-
long_description_content_type="text/markdown",
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"Programming Language :: Python :: 3
|
|
44
|
-
"Programming Language :: Python :: 3.
|
|
45
|
-
"Programming Language :: Python :: 3.
|
|
46
|
-
"Programming Language :: Python :: 3.
|
|
47
|
-
"Programming Language :: Python :: 3
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
import platform
|
|
3
|
+
|
|
4
|
+
import setuptools
|
|
5
|
+
|
|
6
|
+
if (
|
|
7
|
+
platform.processor() == "arm" or platform.processor() == "i386"
|
|
8
|
+
) and platform.system() == "Darwin":
|
|
9
|
+
tensorflow_os = "tensorflow-macos>=2.10.0,<=2.15.0"
|
|
10
|
+
else:
|
|
11
|
+
tensorflow_os = "tensorflow>=2.12.0,<=2.15.0"
|
|
12
|
+
|
|
13
|
+
with open("README.md", "r") as fh:
|
|
14
|
+
long_description = fh.read()
|
|
15
|
+
|
|
16
|
+
setuptools.setup(
|
|
17
|
+
name="decimer",
|
|
18
|
+
version="2.7.0",
|
|
19
|
+
author="Kohulan Rajan",
|
|
20
|
+
author_email="kohulan.rajan@uni-jena.de",
|
|
21
|
+
maintainer="Kohulan Rajan, Otto Brinkhaus ",
|
|
22
|
+
maintainer_email="kohulan.rajan@uni-jena.de, otto.brinkhaus@uni-jena.de",
|
|
23
|
+
description="DECIMER 2.6.0: Deep Learning for Chemical Image Recognition using Efficient-Net V2 + Transformer",
|
|
24
|
+
long_description=long_description,
|
|
25
|
+
long_description_content_type="text/markdown",
|
|
26
|
+
entry_points={
|
|
27
|
+
"console_scripts": ["decimer = DECIMER.decimer:main"],
|
|
28
|
+
},
|
|
29
|
+
url="https://github.com/Kohulan/DECIMER-Image_Transformer",
|
|
30
|
+
packages=setuptools.find_packages(),
|
|
31
|
+
license="MIT",
|
|
32
|
+
install_requires=[
|
|
33
|
+
tensorflow_os,
|
|
34
|
+
"opencv-python",
|
|
35
|
+
"pystow",
|
|
36
|
+
"pillow-heif",
|
|
37
|
+
"efficientnet",
|
|
38
|
+
"selfies",
|
|
39
|
+
"pyyaml",
|
|
40
|
+
],
|
|
41
|
+
package_data={"DECIMER": ["repack/*.*", "efficientnetv2/*.*", "Utils/*.*"]},
|
|
42
|
+
classifiers=[
|
|
43
|
+
"Programming Language :: Python :: 3",
|
|
44
|
+
"Programming Language :: Python :: 3.5",
|
|
45
|
+
"Programming Language :: Python :: 3.6",
|
|
46
|
+
"Programming Language :: Python :: 3.7",
|
|
47
|
+
"Programming Language :: Python :: 3.8",
|
|
48
|
+
"Programming Language :: Python :: 3.9",
|
|
49
|
+
"Programming Language :: Python :: 3.10",
|
|
50
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
51
|
+
"License :: OSI Approved :: MIT License",
|
|
52
|
+
"Operating System :: OS Independent",
|
|
53
|
+
],
|
|
54
|
+
python_requires=">=3.5",
|
|
55
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|