aseifert's picture
Update app.py
4ab024c
raw
history blame
681 Bytes
import subprocess
import streamlit as st
p = subprocess.Popen(["pip", "freeze"], stdout=subprocess.PIPE)
output = p.communicate()[0]
st.code(output.decode("utf-8"))
MODEL_NAME = "stas/mt5-tiny-random"
from transformers import AutoTokenizer
from fastT5 import export_and_get_onnx_model, get_onnx_model # this line will throw an error
model = export_and_get_onnx_model(MODEL_NAME)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
tokenized = tokenizer("Will this work?", return_tensors="pt")
tokens = model.generate(
input_ids=tokenized["input_ids"],
attention_mask=tokenized["attention_mask"],
)
st.write(tokenizer.decode(tokens.squeeze(), skip_special_tokens=True))