Spaces:
Runtime error
Runtime error
Commit
·
8ddfa6e
1
Parent(s):
8b4f9a0
change model loading to pipeline function
Browse files
app.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
from distutils.command.upload import upload
|
2 |
-
from io import StringIO
|
3 |
import pandas as pd
|
4 |
import streamlit as st
|
5 |
|
6 |
from transformers import AutoTokenizer, TFAutoModelForQuestionAnswering
|
|
|
7 |
|
8 |
|
9 |
@st.cache
|
@@ -21,6 +21,11 @@ def load_model_tokenizer():
|
|
21 |
return model, tokenizer
|
22 |
|
23 |
|
|
|
|
|
|
|
|
|
|
|
24 |
# Page config
|
25 |
title = "Recipe Improver"
|
26 |
icon = "🍣"
|
@@ -34,7 +39,8 @@ if uploaded_file is not None:
|
|
34 |
st.write(df.head())
|
35 |
|
36 |
# Load tokenizer and model
|
37 |
-
|
|
|
38 |
st.write("Model and tokenizer successfully loaded.")
|
39 |
|
40 |
# Pre-process data from csv file
|
|
|
1 |
from distutils.command.upload import upload
|
|
|
2 |
import pandas as pd
|
3 |
import streamlit as st
|
4 |
|
5 |
from transformers import AutoTokenizer, TFAutoModelForQuestionAnswering
|
6 |
+
from transformers import pipeline
|
7 |
|
8 |
|
9 |
@st.cache
|
|
|
21 |
return model, tokenizer
|
22 |
|
23 |
|
24 |
+
@st.cache
|
25 |
+
def load_pipeline(checkpoint):
|
26 |
+
return pipeline("question-answering", model=checkpoint)
|
27 |
+
|
28 |
+
|
29 |
# Page config
|
30 |
title = "Recipe Improver"
|
31 |
icon = "🍣"
|
|
|
39 |
st.write(df.head())
|
40 |
|
41 |
# Load tokenizer and model
|
42 |
+
checkpoint = "aidan-o-brien/recipe-improver"
|
43 |
+
question_answer = load_pipeline(checkpoint)
|
44 |
st.write("Model and tokenizer successfully loaded.")
|
45 |
|
46 |
# Pre-process data from csv file
|