pip install transformers gradio rdkit torch
pip install torch_scatter torch_sparse torch_geometric
import gradio as gr
from transformers import AutoModel
def predict_smiles(name):
device = 'cpu'
smiles = name
assert isinstance(smiles, str), 'smiles must be str'
smiles = smiles.strip()
if ';' in smiles:
smiles = smiles.split(";")
elif ' ' in smiles:
smiles = smiles.split(" ")
elif ',' in smiles:
smiles = smiles.split(",")
else:
smiles = [smiles]
model = AutoModel.from_pretrained("Huhujingjing/custom-mxm", trust_remote_code=True).to(device)
output, df = model.predict_smiles(smiles)
return output, df
iface = gr.Interface(fn=predict_smiles, inputs="text", outputs=["text", "dataframe"])
iface.launch(share=True)
- Downloads last month
- 3
Inference API (serverless) does not yet support model repos that contain custom code.