Spaces:
Runtime error
Runtime error
Poe Dator
commited on
Commit
·
075a493
1
Parent(s):
aaa85c8
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,10 +35,10 @@ class BertClassifier(nn.Module):
|
|
| 35 |
@st.cache(suppress_st_warning=True)
|
| 36 |
def build_model():
|
| 37 |
model = BertClassifier(n_classes=len(labels))
|
| 38 |
-
st.markdown("Model created")
|
| 39 |
model.load_state_dict(torch.load('model_weights_1.pt', map_location=torch.device('cpu')))
|
| 40 |
model.eval()
|
| 41 |
-
st.markdown("Model weights loaded")
|
| 42 |
return model
|
| 43 |
|
| 44 |
def inference(txt):
|
|
@@ -87,11 +87,21 @@ def infer_and_display_result(txt):
|
|
| 87 |
|
| 88 |
|
| 89 |
st.title('Big-data cloud application for actionable scientific article topic analytics using in-memory computing and stuff.')
|
|
|
|
| 90 |
image = Image.open('dilbert_big_data.jpg')
|
| 91 |
st.image(image)
|
| 92 |
st.write('test application for ML-2 class, YSDA-2022' )
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
text1 = st.text_area("ENTER ARTICLE TITLE HERE")
|
| 97 |
text2 = st.text_area("ENTER ARTICLE ABSTRACT HERE")
|
|
@@ -102,7 +112,7 @@ model = build_model()
|
|
| 102 |
action = st.button('click here to infer topic')
|
| 103 |
if action:
|
| 104 |
if len(text) < 3:
|
| 105 |
-
st.
|
| 106 |
else:
|
| 107 |
infer_and_display_result(text)
|
| 108 |
|
|
|
|
| 35 |
@st.cache(suppress_st_warning=True)
|
| 36 |
def build_model():
|
| 37 |
model = BertClassifier(n_classes=len(labels))
|
| 38 |
+
# st.markdown("Model created")
|
| 39 |
model.load_state_dict(torch.load('model_weights_1.pt', map_location=torch.device('cpu')))
|
| 40 |
model.eval()
|
| 41 |
+
#st.markdown("Model weights loaded")
|
| 42 |
return model
|
| 43 |
|
| 44 |
def inference(txt):
|
|
|
|
| 87 |
|
| 88 |
|
| 89 |
st.title('Big-data cloud application for actionable scientific article topic analytics using in-memory computing and stuff.')
|
| 90 |
+
st.subtitle('test application for ML-2 class, YSDA-2022' )
|
| 91 |
image = Image.open('dilbert_big_data.jpg')
|
| 92 |
st.image(image)
|
| 93 |
st.write('test application for ML-2 class, YSDA-2022' )
|
| 94 |
+
|
| 95 |
+
comment = """
|
| 96 |
+
this application estimates probability that certain article belongs to one of the following classes based on Arxiv Category Taxonomy:
|
| 97 |
+
|
| 98 |
+
- 'cs.NE': 'Neural and Evolutionary Computing',
|
| 99 |
+
- 'cs.CL': 'Computation and Language',
|
| 100 |
+
- 'cs.AI': 'Artificial Intelligence',
|
| 101 |
+
- 'stat.ML': 'Machine Learning (stat)',
|
| 102 |
+
- 'cs.CV': 'Computer Vision',
|
| 103 |
+
- 'cs.LG': 'Machine Learning' """.replace("'", '')
|
| 104 |
+
st.markdown()
|
| 105 |
|
| 106 |
text1 = st.text_area("ENTER ARTICLE TITLE HERE")
|
| 107 |
text2 = st.text_area("ENTER ARTICLE ABSTRACT HERE")
|
|
|
|
| 112 |
action = st.button('click here to infer topic')
|
| 113 |
if action:
|
| 114 |
if len(text) < 3:
|
| 115 |
+
st.subtitle("this text is too short or empty. try again")
|
| 116 |
else:
|
| 117 |
infer_and_display_result(text)
|
| 118 |
|