sarahai commited on
Commit
58146ac
1 Parent(s): cff11e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -46
app.py CHANGED
@@ -1,46 +1,28 @@
1
- import streamlit as st
2
- import PyPDF2
3
- import docx
4
- import spacy
5
-
6
- # Load NLP model
7
- @st.cache_resource
8
- def load_model():
9
- return spacy.load("en_core_web_sm")
10
-
11
- nlp = load_model()
12
-
13
- # Function to extract text
14
- def extract_text(file):
15
- if file.type == "application/pdf":
16
- reader = PyPDF2.PdfFileReader(file)
17
- return "".join([reader.getPage(i).extract_text() for i in range(reader.numPages)])
18
- elif file.type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
19
- return "\n".join([para.text for para in docx.Document(file).paragraphs])
20
-
21
- # Function to extract and display information
22
- def analyze_resume(text, job_desc):
23
- doc = nlp(text)
24
- extracted_info = {"skills": [], "education": [], "experience": []}
25
-
26
- for ent in doc.ents:
27
- if ent.label_ in ["ORG", "GPE"]:
28
- extracted_info["education"].append(ent.text)
29
- elif ent.label_ == "DATE":
30
- extracted_info["experience"].append(ent.text)
31
-
32
- match_score = sum(1 for token in nlp(job_desc) if token.text in text) / len(job_desc.split()) * 100
33
- return extracted_info, match_score
34
-
35
- # Streamlit interface
36
- st.title("Resume Scanner with NLP")
37
- uploaded_file = st.file_uploader("Upload a resume (PDF or DOCX)", type=["pdf", "docx"])
38
- job_description = st.text_area("Paste the job description here")
39
-
40
- if uploaded_file and job_description:
41
- resume_text = extract_text(uploaded_file)
42
- extracted_info, match_score = analyze_resume(resume_text, job_description)
43
-
44
- st.subheader("Extracted Information:")
45
- st.write(extracted_info)
46
- st.subheader(f"Match Score: {match_score:.2f}%")
 
1
+ import streamlit as st
2
+ import easyocr
3
+ from PIL import Image
4
+
5
+ # Initialize the EasyOCR Reader
6
+ reader = easyocr.Reader(['en'])
7
+
8
+ # Streamlit interface
9
+ st.title("OCR with EasyOCR")
10
+
11
+ # Upload image
12
+ uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
13
+
14
+ if uploaded_file:
15
+ # Open image file
16
+ image = Image.open(uploaded_file)
17
+ st.image(image, caption='Uploaded Image', use_column_width=True)
18
+
19
+ # Run OCR
20
+ result = reader.readtext(image)
21
+
22
+ # Display OCR results
23
+ st.subheader("OCR Results:")
24
+ for detection in result:
25
+ text = detection[1]
26
+ bbox = detection[0]
27
+ st.write(f"Text: {text}")
28
+ st.write(f"Bounding Box: {bbox}")