bayer-science-for-a-better-life / Img2Mol

Apache License 2.0
108 stars 41 forks source link

Try to batch convert the image to smiles #7

Closed CAVUling closed 2 years ago

CAVUling commented 2 years ago

Hi: I had 4k pictures need to translate the molecular depictions into their SMILES representation. I used the code with smiles_list = {} for i in picture_list: res = img2mol(filepath=picture_path + "/" + i, cddd_server=cddd_server) smile = res['smiles'] name = os.path.splitext(i)[0] smiles_list[name] = smile time.sleep(20) in example_inference.ipynb. I got the followed error `TimeoutError Traceback (most recent call last) ~/anaconda3/envs/img2mol/lib/python3.8/site-packages/urllib3/connection.py in _new_conn(self) 158 try: --> 159 conn = connection.create_connection( 160 (self._dns_host, self.port), self.timeout, **extra_kw

~/anaconda3/envs/img2mol/lib/python3.8/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options) 83 if err is not None: ---> 84 raise err 85

~/anaconda3/envs/img2mol/lib/python3.8/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options) 73 sock.bind(source_address) ---> 74 sock.connect(sa) 75 return sock

TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

NewConnectionError Traceback (most recent call last)`

djork commented 2 years ago

The call runs into a time-out from the CDDD decoder server. We provide the CDDD sever on http://ec2-18-157-240-87.eu-central-1.compute.amazonaws.com only for smaller tests, so such large batches are not processed properly. However, there are two ways to solve your problem. The easiest path forward is to use smaller batches of 500. Otherwise I would recommend you to install a local instance of the CDDD server. Have a look here: https://github.com/jrwnter/cddd BTW: I don't know in which context you use Img2Mol, but please consider the license terms. Neither the CDDD server nor the Img2Mol model are for commercial use.