Update app.py
Browse files
app.py
CHANGED
@@ -66,7 +66,7 @@ with st.sidebar:
|
|
66 |
st.title("Check Your Paper Now!")
|
67 |
|
68 |
# Main content
|
69 |
-
option = st.radio("Select input type:",
|
70 |
|
71 |
if option == "Text":
|
72 |
title_input = st.text_area("Enter Title:")
|
@@ -99,37 +99,4 @@ if option == "Text":
|
|
99 |
unsafe_allow_html=True
|
100 |
)
|
101 |
else:
|
102 |
-
st.text(label)
|
103 |
-
|
104 |
-
elif option == "PDF":
|
105 |
-
uploaded_file = st.file_uploader("Upload a PDF file", type=["pdf"])
|
106 |
-
|
107 |
-
if uploaded_file is not None:
|
108 |
-
with st.spinner("Processing PDF..."):
|
109 |
-
file_path = os.path.join(uploaded_files_dir, uploaded_file.name)
|
110 |
-
with open(file_path, "wb") as f:
|
111 |
-
f.write(uploaded_file.getbuffer())
|
112 |
-
st.success("File uploaded successfully.")
|
113 |
-
st.text(f"File Path: {file_path}")
|
114 |
-
|
115 |
-
file_text = extract_text_from_pdf(file_path)
|
116 |
-
st.text("Extracted Text:")
|
117 |
-
st.text(file_text)
|
118 |
-
|
119 |
-
if st.button("Predict from PDF Text"):
|
120 |
-
if not file_text.strip():
|
121 |
-
st.warning("Please upload a PDF with text content.")
|
122 |
-
else:
|
123 |
-
with st.spinner("Predicting..."):
|
124 |
-
predicted_class = predict_class(file_text)
|
125 |
-
if predicted_class is not None:
|
126 |
-
class_labels = ["Level 1", "Level 2", "Level 3", "Level 4"]
|
127 |
-
st.text("**Predicted Class:**")
|
128 |
-
for i, label in enumerate(class_labels):
|
129 |
-
if i == predicted_class:
|
130 |
-
st.markdown(
|
131 |
-
f'<div style="background-color: {class_colors[predicted_class]}; padding: 10px; border-radius: 5px; color: white; font-weight: bold;">{label}</div>',
|
132 |
-
unsafe_allow_html=True
|
133 |
-
)
|
134 |
-
else:
|
135 |
-
st.text(label)
|
|
|
66 |
st.title("Check Your Paper Now!")
|
67 |
|
68 |
# Main content
|
69 |
+
#option = st.radio("Select input type:", "Text")
|
70 |
|
71 |
if option == "Text":
|
72 |
title_input = st.text_area("Enter Title:")
|
|
|
99 |
unsafe_allow_html=True
|
100 |
)
|
101 |
else:
|
102 |
+
st.text(label)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|