Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
import streamlit as st
|
2 |
from importlib.machinery import PathFinder
|
|
|
3 |
import io
|
4 |
import netrc
|
5 |
import pickle
|
@@ -32,7 +32,7 @@ st.markdown(
|
|
32 |
)
|
33 |
|
34 |
# # let's load the saved model
|
35 |
-
|
36 |
|
37 |
|
38 |
# Containers
|
@@ -48,35 +48,32 @@ with header_container:
|
|
48 |
|
49 |
# model container
|
50 |
with mod_container:
|
51 |
-
|
52 |
# collecting input from user
|
53 |
prompt = st.text_input("Enter your description below ...")
|
54 |
|
55 |
# Loading e data
|
56 |
-
data = (pd.read_csv("SBERT_data.csv")
|
57 |
-
).drop(['Unnamed: 0'], axis=1)
|
58 |
|
59 |
-
data['prompt']
|
60 |
-
data.rename(columns={'target_text':
|
61 |
-
'prompt': 'sentence1'}, inplace=True)
|
62 |
data['sentence2'] = data['sentence2'].astype('str')
|
63 |
-
data['sentence1']
|
64 |
|
65 |
# let's pass the input to the loaded_model with torch compiled with cuda
|
66 |
if prompt:
|
67 |
# let's get the result
|
68 |
-
|
|
|
69 |
from sentence_transformers import CrossEncoder
|
70 |
loaded_model = CrossEncoder("cross-encoder/stsb-roberta-base")
|
71 |
sentence_pairs = []
|
72 |
-
for sentence1, sentence2 in zip(data['sentence1'],
|
73 |
sentence_pairs.append([sentence1, sentence2])
|
74 |
|
75 |
-
simscore = loaded_model.predict([prompt])
|
76 |
# sorting the df to get highest scoring xpath_container
|
77 |
data['SBERT CrossEncoder_Score'] = loaded_model.predict(sentence_pairs)
|
78 |
most_acc = data.head(5)
|
79 |
# predictions
|
80 |
st.write("Highest Similarity score: ", simscore)
|
81 |
st.text("Is this one of these the Xpath you're looking for?")
|
82 |
-
st.write(st.write(most_acc["input_text"]))
|
|
|
|
|
1 |
from importlib.machinery import PathFinder
|
2 |
+
|
3 |
import io
|
4 |
import netrc
|
5 |
import pickle
|
|
|
32 |
)
|
33 |
|
34 |
# # let's load the saved model
|
35 |
+
loaded_model = pickle.load(open('XpathFinder1.sav', 'rb'))
|
36 |
|
37 |
|
38 |
# Containers
|
|
|
48 |
|
49 |
# model container
|
50 |
with mod_container:
|
|
|
51 |
# collecting input from user
|
52 |
prompt = st.text_input("Enter your description below ...")
|
53 |
|
54 |
# Loading e data
|
55 |
+
data = (pd.read_csv("SBERT_data.csv")).drop(['Unnamed: 0'], axis = 1)
|
|
|
56 |
|
57 |
+
data['prompt']= prompt
|
58 |
+
data.rename(columns = {'target_text':'sentence2', 'prompt':'sentence1'}, inplace = True)
|
|
|
59 |
data['sentence2'] = data['sentence2'].astype('str')
|
60 |
+
data['sentence1'] = data['sentence1'].astype('str')
|
61 |
|
62 |
# let's pass the input to the loaded_model with torch compiled with cuda
|
63 |
if prompt:
|
64 |
# let's get the result
|
65 |
+
simscore = loaded_model.predict([prompt])
|
66 |
+
|
67 |
from sentence_transformers import CrossEncoder
|
68 |
loaded_model = CrossEncoder("cross-encoder/stsb-roberta-base")
|
69 |
sentence_pairs = []
|
70 |
+
for sentence1, sentence2 in zip(data['sentence1'],data['sentence2']):
|
71 |
sentence_pairs.append([sentence1, sentence2])
|
72 |
|
|
|
73 |
# sorting the df to get highest scoring xpath_container
|
74 |
data['SBERT CrossEncoder_Score'] = loaded_model.predict(sentence_pairs)
|
75 |
most_acc = data.head(5)
|
76 |
# predictions
|
77 |
st.write("Highest Similarity score: ", simscore)
|
78 |
st.text("Is this one of these the Xpath you're looking for?")
|
79 |
+
st.write(st.write(most_acc["input_text"]))
|