firstdemo / app.py
sadgaj's picture
Update app.py
2b734c6
raw
history blame
607 Bytes
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
def greet(name):
tokenizer = AutoTokenizer.from_pretrained("zjunlp/MolGen")
model = AutoModelForSeq2SeqLM.from_pretrained("zjunlp/MolGen")
sf_input = tokenizer(name, return_tensors="pt")
# beam search
molecules = model.generate(input_ids=sf_input["input_ids"],
sf_output = [tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=True).replace(" ","") for g in molecules]
return sf_output
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()