Spaces:
Sleeping
Sleeping
modified code
Browse files
app.py
CHANGED
@@ -13,6 +13,17 @@ from transformers import DistilBertForSequenceClassification, DistilBertTokenize
|
|
13 |
from torch.nn.functional import softmax
|
14 |
from doctr.models import ocr_predictor
|
15 |
from doctr.io import DocumentFile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
load_dotenv()
|
18 |
|
@@ -265,15 +276,15 @@ def main():
|
|
265 |
col1, col2, col3 = st.columns(3)
|
266 |
|
267 |
with col1:
|
268 |
-
knowledge = st.slider("Knowledge: Remembering information", 0, 100, 20, key='knowledge_slider')
|
269 |
-
application = st.slider("Application:
|
270 |
|
271 |
with col2:
|
272 |
-
comprehension = st.slider("Comprehension:
|
273 |
analysis = st.slider("Analysis: Breaking down a whole into component parts", 0, 100, 20, key='analysis_slider')
|
274 |
|
275 |
with col3:
|
276 |
-
synthesis = st.slider("Synthesis: Putting parts together to form a new and integrated whole", 0, 100, 10, key='synthesis_slider')
|
277 |
evaluation = st.slider("Evaluation: Making and defending judgments based on internal evidence or external criteria", 0, 100, 10, key='evaluation_slider')
|
278 |
|
279 |
# Collect the Bloom's Taxonomy weights
|
@@ -428,9 +439,9 @@ def main():
|
|
428 |
|
429 |
if submit_button:
|
430 |
# Calculate total score
|
431 |
-
|
432 |
-
dummydata = sendtogemini(
|
433 |
-
print(dummydata)
|
434 |
total_score = {'Remembering': 0, 'Understanding': 0, 'Applying': 0, 'Analyzing': 0, 'Evaluating': 0, 'Creating': 0}
|
435 |
for item in dummydata:
|
436 |
for category in total_score:
|
@@ -452,7 +463,7 @@ def main():
|
|
452 |
st.markdown(f"""
|
453 |
<div class="score-breakdown">
|
454 |
<div class="score-header" style="color: {color}">{category}</div>
|
455 |
-
<div style="font-size: 24px; color: {color};">{score}/
|
456 |
</div>
|
457 |
""", unsafe_allow_html=True)
|
458 |
|
|
|
13 |
from torch.nn.functional import softmax
|
14 |
from doctr.models import ocr_predictor
|
15 |
from doctr.io import DocumentFile
|
16 |
+
import tempfile
|
17 |
+
|
18 |
+
|
19 |
+
def save_uploaded_file(uploaded_file):
|
20 |
+
if uploaded_file is not None:
|
21 |
+
file_extension = uploaded_file.name.split('.')[-1].lower()
|
22 |
+
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix = f'.{file_extension}')
|
23 |
+
temp_file.write(uploaded_file.getvalue())
|
24 |
+
temp_file.close()
|
25 |
+
return temp_file.name
|
26 |
+
return None
|
27 |
|
28 |
load_dotenv()
|
29 |
|
|
|
276 |
col1, col2, col3 = st.columns(3)
|
277 |
|
278 |
with col1:
|
279 |
+
knowledge = st.slider("Knowledge or Remembering: Remembering information", 0, 100, 20, key='knowledge_slider')
|
280 |
+
application = st.slider("Application: Use knowledge in new situations or solve problems.", 0, 100, 20, key='application_slider')
|
281 |
|
282 |
with col2:
|
283 |
+
comprehension = st.slider("Comprehension or Understanding: Comprehend and explain ideas or concepts.", 0, 100, 20, key='comprehension_slider')
|
284 |
analysis = st.slider("Analysis: Breaking down a whole into component parts", 0, 100, 20, key='analysis_slider')
|
285 |
|
286 |
with col3:
|
287 |
+
synthesis = st.slider("Synthesis or Creating: Putting parts together to form a new and integrated whole", 0, 100, 10, key='synthesis_slider')
|
288 |
evaluation = st.slider("Evaluation: Making and defending judgments based on internal evidence or external criteria", 0, 100, 10, key='evaluation_slider')
|
289 |
|
290 |
# Collect the Bloom's Taxonomy weights
|
|
|
439 |
|
440 |
if submit_button:
|
441 |
# Calculate total score
|
442 |
+
pdf_path = save_uploaded_file(uploaded_file)
|
443 |
+
dummydata = sendtogemini(pdf_path)
|
444 |
+
#print(dummydata)
|
445 |
total_score = {'Remembering': 0, 'Understanding': 0, 'Applying': 0, 'Analyzing': 0, 'Evaluating': 0, 'Creating': 0}
|
446 |
for item in dummydata:
|
447 |
for category in total_score:
|
|
|
463 |
st.markdown(f"""
|
464 |
<div class="score-breakdown">
|
465 |
<div class="score-header" style="color: {color}">{category}</div>
|
466 |
+
<div style="font-size: 24px; color: {color};">{score}/{len(dummydata)}</div>
|
467 |
</div>
|
468 |
""", unsafe_allow_html=True)
|
469 |
|