|
from distutils.command.upload import upload
|
|
from io import StringIO
|
|
import pandas as pd
|
|
import streamlit as st
|
|
|
|
from transformers import AutoTokenizer, TFAutoModelForQuestionAnswering
|
|
|
|
|
|
@st.cache
|
|
def load_data(file):
|
|
df = pd.read_csv(file, encoding='utf-8', nrows=50)
|
|
return df
|
|
|
|
|
|
@st.cache
|
|
def load_model_tokenizer():
|
|
tokenizer_cp = "albert-base-v2"
|
|
model_cp = "aidan-o-brien/recipe-improver"
|
|
tokenizer = AutoTokenizer.from_pretrained(tokenizer_cp)
|
|
model = TFAutoModelForQuestionAnswering.from_pretrained(model_cp)
|
|
return model, tokenizer
|
|
|
|
|
|
|
|
title = "Recipe Improver"
|
|
icon = "馃崳"
|
|
st.set_page_config(page_title=title, page_icon=icon)
|
|
st.title(title)
|
|
|
|
|
|
uploaded_file = st.file_uploader("Choose a csv file", type="csv", key='file_uploader')
|
|
if uploaded_file is not None:
|
|
df = load_data(uploaded_file)
|
|
st.write(df.head())
|
|
|
|
|
|
model, tokenizer = load_model_tokenizer()
|
|
st.write("Model and tokenizer successfully loaded.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|