一、2D化学结构识别:

0、【2022综述】Review of techniques and models used in optical chemical structure recognition in images and scanned documents

Review of techniques and models used in optical chemical structure recognition in images and scanned documents | Journal of Cheminformatics | Full Text

1、在线转换网址:DECIMER Web Application

它对应的代码地址为:GitHub - Kohulan/DECIMER_Short_Communication

2、https://github.com/Kohulan/DECIMER-Image_Transformer

这里我用的是2,按照readme上面的做就可以了

3、Img2Mol: inferring molecules from pictures(也挺好的)

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

4、Automated Recognition of Chemical Molecule Images Based on an Improved TNT Model(2022)

Applied Sciences | Free Full-Text | Automated Recognition of Chemical Molecule Images Based on an Improved TNT Model

没有代码

备注:我测试过,其实并有没有很好地能确定image2SMILES转换的model,也不知道怎么判断这个转换后的SMILES与原始的image之间的置信度(因为一个 very invalid的分子也可以转为SMILES)


这里的3比2好用,但是3最好使用local-cddd,因为不使用本地的,还需要联网,可能会出现很多错误,

conda env create -f environment.local-cddd.yml
conda activate img2mol
pip install .

然后:

If you are working with the local CDDD installation, please * download and unzip the CDDD model and 将 directory default_model to path/to/anaconda3/envs/img2mol/lib/python3.6/site-packages/cddd/data/


先看下文件目录:

这里需要注意一点,我这里将这个文件夹当成了子文件夹放入了文件中,所以可能会引起import的错误,所以这里需要右键文件夹,然后,make directory as Source root

直接上代码:

image2smiles2image.py的代码:

其中input_images是生成器G生成的image;
image2smiles_all.csv是是G生成的image然后转为所有的的smiles
image2smiles_validity.csv是是G生成的image然后转为有效的smiles
image2smiles_unvalidity.csv是是G生成的image然后转为无效的的smiles
image2smiles2image:是G生成的image然后转为smiles再转为image的文件夹

command:

# python image2smiles2image.py --input_images_path ../../eval_output_images/QM9/generator_images --image2smiles2image_save_path ../../eval_output_images/QM9/image2smiles2image/ --image2smiles_all ../../eval_output_images/QM9/image2smiles_all.csv --image2smiles_validity ../../eval_output_images/QM9/image2smiles_validity.csv --image2smiles_unvalidity ../../eval_output_images/QM9/image2smiles_unvalidity.csv

code:


from DECIMER import predict_SMILESimport glob
import os
import csv
from rdkit import Chem
from rdkit.Chem.Draw import rdMolDraw2D
import argparse# Get all png files under the input folder
parser = argparse.ArgumentParser(description='Testing script', add_help=False)
parser.add_argument('--input_images_path', default='../../eval_output_images/QM9/generator_images', help='Input images folder')
parser.add_argument('--image2smiles2image_save_path', default='../../eval_output_images/QM9/image2smiles2image/')
parser.add_argument('--image2smiles_all', default='../../eval_output_images/QM9/image2smiles_all.csv')
parser.add_argument('--image2smiles_validity', default='../../eval_output_images/QM9/image2smiles_validity.csv')
parser.add_argument('--image2smiles_unvalidity', default='../../eval_output_images/QM9/image2smiles_unvalidity.csv')
args = parser.parse_args()input_img_path = glob.glob(args.input_images_path + "/*.[jp][pn]g")
image2smiles2image_save_path = args.image2smiles2image_save_pathdef mkdir(path):folder = os.path.exists(path)if not folder:  # 判断是否存在文件夹如果不存在则创建为文件夹os.makedirs(path)  # makedirs 创建文件时如果路径不存在会创建这个路径print("--- create new folder...  ---")else:print("---  There is this folder!  ---")
mkdir(image2smiles2image_save_path)i = 0
unrecover_images = 0
for file in input_img_path:# 在windows下使用“\\”,在linux下使用“/”,注意切换file_name = file.split('\\')[-1]### 下面为处理图片的过程SMILES = predict_SMILES(file)i = i + 1print("The current process image ", i ," is :", file, ", And the SMILES is :", SMILES)#----------------------- 1、save the Validity image2SMILES ------------------------------------# 1. 创建文件对象f_validity = open(args.image2smiles_all, 'a', newline='', encoding='utf-8')# 2. 基于文件对象构建 csv写入对象csv_writer_validity = csv.writer(f_validity)# ----------------------- 1.2、save the All image2SMILES ------------------------------------f_all = open(args.image2smiles_validity, 'a', newline='', encoding='utf-8')csv_writer_all = csv.writer(f_all)csv_writer_all.writerow([SMILES])f_all.close()# ----------------------- 2、save the image2SMILES2image ------------------------------try:mol = Chem.MolFromSmiles(SMILES)drawer = rdMolDraw2D.MolDraw2DCairo(256, 256)opts = rdMolDraw2D.MolDrawOptions()# 设置杆的粗细opts.bondLineWidth = 3# 设置字母的大小opts.minFontSize = 15drawer.SetDrawOptions(opts)rdMolDraw2D.PrepareAndDrawMolecule(drawer, mol)drawer.FinishDrawing()img_save_path = str(image2smiles2image_save_path + file_name)drawer.WriteDrawingText(img_save_path)# 4. 写入csv文件内容csv_writer_validity.writerow([SMILES])# 5. 关闭文件f_validity.close()# 不能从SMILES转换为分子结构图片except Exception as e:unrecover_images = unrecover_images + 1print("The current process image ", i ," is :", file, ", And the SMILES is :", SMILES, " is not un-validity !")# ----------------------- 2.2、save the image2SMILES_wrong ------------------------------------f_unvalidity = open(args.image2smiles_unvalidity, 'a', newline='', encoding='utf-8')csv_writer_unvalidity = csv.writer(f_unvalidity)write_in = ("The un-rational image is :", file, ", And the SMILES is :", SMILES)csv_writer_unvalidity.writerow([write_in])f_unvalidity.close()print("The totel images is :", i ," , And the unrecover_images is :", unrecover_images, ", And the success rate is:", (i-unrecover_images)/i)

生成的分子图像是否可以识别为SMILES,然后再将识别后的SMILES转换为图像?相关推荐

  1. Word控件Spire.Doc 转换教程(十一):如何将 HTML 转换为图像

    Spire.Doc 可以帮助用户使用 C#/VB.NET 将HTML 转换为 Image.该解决方案使用户可以随时随地通过手机.MP4播放器.PSP.iPad.iTouch等便携式设备阅读HTML.按 ...

  2. OCR大突破:Facebook推出大规模图像文字检测识别系统——Rosetta

    作者 | Fedor Borisyuk,Albert Gordo,Viswanath Sivakumar 译者 | 林椿眄 编辑 | 非主流 出品 | AI科技大本营 [导读]OCR(Optical ...

  3. 基于飞桨 DeepLabV3+实现人体肾组织图像中肾小球识别

    基于飞桨 DeepLabV3+实现人体肾组织图像中肾小球识别 一.项目背景 估计显示,地球上有超过70亿人,银河系中有3000亿颗恒星.相比之下,成年人体内含有37万亿个细胞.确定这些细胞之间的功能和 ...

  4. python提取人物特征_基于图像人物面部表情识别的特征提取优化方法与流程

    本发明涉及一种基于图像人物面部表情识别的特征提取优化方法,主要利用基于统计特征提取的二维主成分分析法和改进的粒子群算法优化图像矩阵的解,属于图像处理.模式识别和计算机视觉交叉技术应用领域. 背景技术: ...

  5. 个人永久性免费-Excel催化剂功能第86波-人工智能之图像OCR文本识别全覆盖

    在上一年中,Excel催化剂已经送上一波人工智能系列功能,鉴于部分高端用户的需求,再次给予实现了复杂的图像OCR识别,包含几乎所有日常场景,让公司个人手头的图像非结构化数据瞬间变为可进行结构化处理分析 ...

  6. 利用TensorFlow搭建CNN,DNN网络实现图像手写识别,总结。

    利用TensorFlow搭建CNN,DNN网络实现图像手写识别,总结. 摘要 一.神经网络与卷积网络的对比 1.数据处理 2.对获取到的数据进行归一化和独热编码 二.开始我们的tensorflow神经 ...

  7. amber中生成小分子模板

    第一步:生成小分子模板 蛋白质中各氨基酸残基的力参数是预先存在的,但是很多模拟过程会涉及配体分子,这些有机小分子有很高的多样性,他们的力参数和静电信息不可能预存在库文件中,需要根据需要自己计算生成模板 ...

  8. 【Journal of Computer-Aided Design Computer Graphics】基于生成对抗网络的行人重识别方法研究综述

    文章目录 引言 数据集介绍 基于GAN的行人重识别方法分类 2.1基于风格转换的方法 2.2基于数据增强的方法 2.3基于不变性特征学习的方法 3 基于GAN的方法性能对比分析 总结 引言 对于行人检 ...

  9. python识别几何图形拼成的图案_自动驾驶汽车视觉- 图像特征提取与匹配技术

    Feature detection and matching Email: williamhyin@outlook.com 特征提取和匹配是许多计算机视觉应用中的一个重要任务,广泛运用在运动结构.图像 ...

  10. java 验证码图片识别_JavaSE图像验证码简单识别程序详解

    本文为大家分享了JavaSE图像验证码简单识别程序,供大家参考,具体内容如下 首先你应该对图片进行样本采集,然后将样本进行灰度处理,也就是变成黑白两色. 然后你就可以使用该类,对目标文件进行分析.具体 ...

最新文章

  1. Mysql 操作技巧
  2. Kafka压力测试(写入MQ消息压测和消费MQ消息压测)
  3. C#网络编程示例(note)
  4. sql order by 结合case when then
  5. 前端把信息放在弹框里显示出来_jsp + js + 前端弹出框
  6. mysql从挂了数据怎么恢复_详解MySQL误操作后怎样进行数据恢复
  7. Java基础篇:如何应用接口?
  8. 字节跳动教育裁员处理还是挺仗义的!
  9. delphi之鼠标模拟
  10. 【知识分享】常见的Kepware冗余功能介绍
  11. 【017】【毕业设计】基于51单片机的频率计设计的Proteus仿真与实物设计
  12. 计算机网络技术实训课程报告,大学网络技术基础课程的实训报告怎么写?
  13. android 修改ip的scope的作用,Android Netd分析
  14. 什么叫做股票实时行情接口api?
  15. 陈丹青版画作品首次元宇宙拍卖明日揭幕!
  16. Google 认证之GMS 认证
  17. AndroidStudio子线程更新UI的几种方式
  18. obj文件和mtl文件格式说明
  19. 【转】从P1到P7——我在淘宝这7年
  20. Git 出现not registered inyour account 解决办法

热门文章

  1. 什么是云中台系统_什么是云中的超融合?
  2. 计算机的硬盘u盘属于什么,移动硬盘和机械硬盘有什么区别?
  3. The root link base_link has an inertia specified in the URDF, but KDL does not support a root ...
  4. ROSERROR : The root link_base has an inertia specified in the URDF, but KDL does not support ...
  5. win10无法访问ubuntu共享文件夹(smbd出错排查)
  6. Spring Cloud Gateway 服务网关的部署与使用详细介绍
  7. 数据库服务器的安装与配置
  8. html作品实验报告,html网页制作实验报告.docx
  9. x264去方块滤波函数解析(二)
  10. mysql支付账单怎么设计_订单与支付设计