Karthikeyan commited on
Commit
95bf4f0
0 Parent(s):

Duplicate from randstad/ResumeSummarizer

Browse files
Files changed (5) hide show
  1. .gitattributes +35 -0
  2. README.md +13 -0
  3. app.py +95 -0
  4. requirements.txt +4 -0
  5. style.css +26 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: ResumeSummarizer
3
+ emoji: 👁
4
+ colorFrom: green
5
+ colorTo: gray
6
+ sdk: gradio
7
+ sdk_version: 3.35.2
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: randstad/ResumeSummarizer
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import openai
3
+ import PyPDF2
4
+ import gradio as gr
5
+ import docx
6
+
7
+ class CourseGenarator:
8
+ def __init__(self):
9
+ openai.api_key = os.getenv("OPENAI_API_KEY")
10
+
11
+ def extract_text_from_file(self,file_path):
12
+ # Get the file extension
13
+ file_extension = os.path.splitext(file_path)[1]
14
+
15
+ if file_extension == '.pdf':
16
+ with open(file_path, 'rb') as file:
17
+ # Create a PDF file reader object
18
+ reader = PyPDF2.PdfFileReader(file)
19
+
20
+ # Create an empty string to hold the extracted text
21
+ extracted_text = ""
22
+
23
+ # Loop through each page in the PDF and extract the text
24
+ for page_number in range(reader.getNumPages()):
25
+ page = reader.getPage(page_number)
26
+ extracted_text += page.extractText()
27
+ return extracted_text
28
+
29
+ elif file_extension == '.txt':
30
+ with open(file_path, 'r') as file:
31
+ # Just read the entire contents of the text file
32
+ return file.read()
33
+
34
+ elif file_extension == '.docx':
35
+ doc = docx.Document(file_path)
36
+ text = []
37
+ for paragraph in doc.paragraphs:
38
+ text.append(paragraph.text)
39
+ return '\n'.join(text)
40
+
41
+ else:
42
+ return "Unsupported file type"
43
+
44
+ def response(self,resume_path):
45
+ resume_path = resume_path.name
46
+ resume = self.extract_text_from_file(resume_path)
47
+
48
+
49
+ # Define the prompt or input for the model
50
+ prompt = f"""Analyze the resume to write the summary for following resume delimitted by triple backticks.
51
+ ```{resume}```
52
+ """
53
+
54
+ # Generate a response from the GPT-3 model
55
+ response = openai.Completion.create(
56
+ engine='text-davinci-003',
57
+ prompt=prompt,
58
+ max_tokens=200,
59
+ temperature=0,
60
+ n=1,
61
+ stop=None,
62
+ )
63
+
64
+ # Extract the generated text from the API response
65
+ generated_text = response.choices[0].text.strip()
66
+
67
+ return generated_text
68
+
69
+ def gradio_interface(self):
70
+ with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as app:
71
+ gr.HTML("""<img class="leftimage" align="left" src="https://templates.images.credential.net/1612472097627370951721412474196.png" alt="Image" width="210" height="210">
72
+ <img class="rightimage" align="right" src="https://companieslogo.com/img/orig/RAND.AS_BIG-0f1935a4.png?t=1651813778" alt="Image" width="210" height="210">""")
73
+
74
+ with gr.Row(elem_id="col-container"):
75
+ with gr.Column():
76
+ gr.HTML("<br>")
77
+ gr.HTML(
78
+ """<h1 style="text-align:center; color:"white">Resume Summarizer</h1> """
79
+ )
80
+ with gr.Column():
81
+ resume = gr.File(label="Resume",elem_classes="heightfit")
82
+
83
+ with gr.Column():
84
+ analyse = gr.Button("Analyze")
85
+
86
+ with gr.Column():
87
+ result = gr.Textbox(label="Summarized",lines=8)
88
+
89
+ analyse.click(self.response, [resume], result)
90
+ print(result)
91
+
92
+ app.launch()
93
+
94
+ ques = CourseGenarator()
95
+ ques.gradio_interface()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ openai
2
+ gradio
3
+ PyPDF2==2.12.1
4
+ python-docx
style.css ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #col-container {
2
+ max-width: 600px;
3
+ margin-left: auto;
4
+ margin-right: auto;
5
+ }
6
+
7
+ #row-flex {
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ }
12
+ .leftimage .rightimage{
13
+ float:left;
14
+ filter: drop-shadow(20px 20px 10px white);
15
+ }
16
+ .leftimage{
17
+ padding-top:40px;
18
+ margin-left:310px;
19
+ }
20
+ .rightimage{
21
+ padding-top:35px;
22
+ margin-right:320px;
23
+ }
24
+ .heightfit{
25
+ height:85px;
26
+ }