Spaces:
Sleeping
Sleeping
Initial commit
Browse files- README.md +3 -4
- app.py +26 -0
- requirements.txt +2 -0
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
title: PaperClassifier
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.17.0
|
8 |
app_file: app.py
|
@@ -10,4 +10,3 @@ pinned: false
|
|
10 |
license: mit
|
11 |
---
|
12 |
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
title: PaperClassifier
|
3 |
+
emoji: π
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: gray
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.17.0
|
8 |
app_file: app.py
|
|
|
10 |
license: mit
|
11 |
---
|
12 |
|
|
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForMaskedLM, pipeline
|
2 |
+
import streamlit as st
|
3 |
+
|
4 |
+
|
5 |
+
@st.cache_data
|
6 |
+
def prepare():
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained("oracat/bert-paper-classifier")
|
8 |
+
model = AutoModelForSequenceClassification.from_pretrained("oracat/bert-paper-classifier")
|
9 |
+
|
10 |
+
|
11 |
+
def process(text):
|
12 |
+
pipe = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
13 |
+
result = pipe(text)[0]
|
14 |
+
return results['label']
|
15 |
+
|
16 |
+
|
17 |
+
prepare()
|
18 |
+
|
19 |
+
st.markdown("### Hello, paper classifier!")
|
20 |
+
|
21 |
+
title = st.text_input("Enter the title...")
|
22 |
+
abstract = st.text_area("... and maybe the abstract of the paper you want to classify")
|
23 |
+
|
24 |
+
text = "\n".join([title, abstract])
|
25 |
+
|
26 |
+
st.markdown(f"{process(text)}")
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|