Skip to main content

Convert a picture to InChI

Project description

Image2InChI

descirption

This is the repository for Image2InChI, an image-to-graph model that translates a molecular image to its InChI.

Quick Start

Installation

Install Image2InChI with pip

pip install Image2InChI

Example

Predict based on a picture

from image2inchi.model import Image2InChI

model = Image2InChI(chk_pt='/weight/chk_pt.pth')

inchi_pred = model.pred_one('/data/aaa.png')
print(inchi_pred)

Using the pred_batch(), pass in a folder path to predict This function runs the Image2InChI model on all images in a given directory and saves the results in results.csv in the same directory. Each line of the output file contains the image file name and the InChI representation of the described molecule.

from image2inchi.model import Image2InChI

model = Image2InChI(chk_pt='/weight/chk_pt.pth')

inchi_df = model.pred_batch('/data/bms_test')
print(inchi_df)

Public Dataset

Validate using a publicly available dataset

from image2inchi.model import Image2InChI, test_bms1000, test_jpo, test_clef, test_uob, test_uspto

model = Image2InChI(chk_pt='/weight/chk_pt.pth')

test_bms1000(model)
test_jpo(model)
test_clef(model)
test_uob(model)
test_uspto(model)

You can use the test_public_dataset() to verify the above

from image2inchi.model import Image2InChI, test_public_dataset

model = Image2InChI(chk_pt='/weight/chk_pt.pth')
test_public_dataset(model)

Evaluation

scoring metrics can be obtained using the Scorer.scoring(). The function needs to pass in two iterable parameters, parameter 1 is the InChI label and parameter 2 is the predicted InChI.

from image2inchi.utils import Scorer

inchi_list = []  # InChI label list
inchi_pred_list = []  # predicted InChI list
inchi_acc, morgan_fp, mcs, lcs = Scorer.scoring(inchi_list, inchi_pred_list)
print(f'result: inchi_acc - {inchi_acc}, morgan_fp - {morgan_fp}, mcs - {mcs}, lcs - {lcs}')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Image2InChI-2.0.3.tar.gz (47.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Image2InChI-2.0.3-py3-none-any.whl (50.8 MB view details)

Uploaded Python 3

File details

Details for the file Image2InChI-2.0.3.tar.gz.

File metadata

  • Download URL: Image2InChI-2.0.3.tar.gz
  • Upload date:
  • Size: 47.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for Image2InChI-2.0.3.tar.gz
Algorithm Hash digest
SHA256 3ec7d40a1d480d5ccd24947f9d869f77368074b118f49bf9927a42a44a2234ba
MD5 dc7b46da9fb593e796da56d4015226be
BLAKE2b-256 9b0ccd2723558ae668025bdc3a67d8bc60778c8b1cfd781bb6b7fda4b9fe5760

See more details on using hashes here.

File details

Details for the file Image2InChI-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: Image2InChI-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 50.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for Image2InChI-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c32c76e1e561213660b60ed9de6e20994325172edf496287c29e7aafa1440e4a
MD5 ad5a247a1a50eff79a6b6ccd75bcca9a
BLAKE2b-256 e02d0d5767532cf9e0d2683dcaf6dba72a11721af68678931af1a002624bdfa5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page