Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,30 +18,19 @@ if text1:
|
|
| 18 |
out = pipe(text1)
|
| 19 |
st.json(out)
|
| 20 |
|
|
|
|
| 21 |
API_TOKEN = os.getenv('My_Token')
|
| 22 |
-
|
| 23 |
inference = InferenceApi(repo_id="bert-base-uncased", token=API_TOKEN)
|
| 24 |
|
| 25 |
-
# The goal of life is [MASK]
|
| 26 |
text2 = st.text_area("enter some text 222")
|
| 27 |
if text2:
|
| 28 |
res = inference(inputs=text2)
|
| 29 |
st.json(res)
|
| 30 |
|
|
|
|
| 31 |
dataset = load_dataset("merve/poetry", streaming=True)
|
| 32 |
df = pd.DataFrame.from_dict(dataset["train"])
|
| 33 |
st.write(df)
|
| 34 |
|
| 35 |
-
# import streamlit as st
|
| 36 |
-
|
| 37 |
-
# # adding the text that will show in the text box as default
|
| 38 |
-
# default_value = "See how a modern neural network auto-completes your text 🤗 This site, built by the Hugging Face team, lets you write a whole document directly from your browser, and you can trigger the Transformer anywhere using the Tab key. Its like having a smart machine that completes your thoughts 😀 Get started by typing a custom snippet, check out the repository, or try one of the examples. Have fun!"
|
| 39 |
-
|
| 40 |
-
# sent = st.text_area("Text", default_value, height = 275)
|
| 41 |
-
# max_length = st.sidebar.slider("Max Length", min_value = 10, max_value=30)
|
| 42 |
-
# temperature = st.sidebar.slider("Temperature", value = 1.0, min_value = 0.0, max_value=1.0, step=0.05)
|
| 43 |
-
# top_k = st.sidebar.slider("Top-k", min_value = 0, max_value=5, value = 0)
|
| 44 |
-
# top_p = st.sidebar.slider("Top-p", min_value = 0.0, max_value=1.0, step = 0.05, value = 0.9)
|
| 45 |
-
# num_return_sequences = st.sidebar.number_input('Number of Return Sequences', min_value=1, max_value=5, value=1, step=1)
|
| 46 |
-
|
| 47 |
-
|
|
|
|
| 18 |
out = pipe(text1)
|
| 19 |
st.json(out)
|
| 20 |
|
| 21 |
+
# 获取秘钥
|
| 22 |
API_TOKEN = os.getenv('My_Token')
|
| 23 |
+
# 通过 inference api 可以访问其他 hub 中托管的模型的能力
|
| 24 |
inference = InferenceApi(repo_id="bert-base-uncased", token=API_TOKEN)
|
| 25 |
|
| 26 |
+
# 测试用例: The goal of life is [MASK]
|
| 27 |
text2 = st.text_area("enter some text 222")
|
| 28 |
if text2:
|
| 29 |
res = inference(inputs=text2)
|
| 30 |
st.json(res)
|
| 31 |
|
| 32 |
+
# 还可以使用 dataset 库用来从数据集的 hub 中获取数据集
|
| 33 |
dataset = load_dataset("merve/poetry", streaming=True)
|
| 34 |
df = pd.DataFrame.from_dict(dataset["train"])
|
| 35 |
st.write(df)
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|