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 name iface = gr.Interface(fn=greet, inputs="text", outputs="text") iface.launch()