Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,53 +1,60 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
-
import numpy as np
|
3 |
import tensorflow as tf
|
4 |
import spacy
|
5 |
-
from
|
|
|
6 |
|
7 |
-
# Load
|
8 |
-
|
9 |
-
token='YOUR_HUGGING_FACE_API_KEY')
|
10 |
|
11 |
# Load your TensorFlow model
|
12 |
model = tf.keras.models.load_model("resume_generator_model.h5")
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
resume_text = uploaded_resume.read().decode("utf-8")
|
20 |
|
21 |
-
|
|
|
|
|
22 |
doc = nlp(resume_text)
|
|
|
23 |
|
24 |
-
#
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
#
|
29 |
-
#
|
30 |
-
|
31 |
-
#
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
44 |
iface = gr.Interface(
|
45 |
fn=enhance_resume,
|
46 |
-
inputs=[
|
47 |
-
|
48 |
-
outputs=gr.outputs.Textbox(label="Enhanced Resume"),
|
49 |
title="Resume Enhancer",
|
50 |
-
description="Upload
|
51 |
)
|
52 |
|
|
|
53 |
iface.launch()
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
|
|
3 |
import tensorflow as tf
|
4 |
import spacy
|
5 |
+
from transformers import InferenceClient
|
6 |
+
from jinja2 import Environment, FileSystemLoader
|
7 |
|
8 |
+
# Load spaCy model
|
9 |
+
nlp = spacy.load("en_core_web_sm")
|
|
|
10 |
|
11 |
# Load your TensorFlow model
|
12 |
model = tf.keras.models.load_model("resume_generator_model.h5")
|
13 |
|
14 |
+
# Initialize the InferenceClient for LLaMA
|
15 |
+
llama_client = InferenceClient(model="meta-llama/Meta-Llama-3.1-8B-Instruct")
|
16 |
|
17 |
+
# Configure Jinja2 for template rendering
|
18 |
+
env = Environment(loader=FileSystemLoader("templates"))
|
|
|
19 |
|
20 |
+
# Helper function to enhance the resume content using spaCy and LLaMA
|
21 |
+
def enhance_resume(resume_text, job_title):
|
22 |
+
# 1. Analyze the resume using spaCy
|
23 |
doc = nlp(resume_text)
|
24 |
+
entities = [(ent.text, ent.label_) for ent in doc.ents]
|
25 |
|
26 |
+
# 2. Use LLaMA model to generate new content based on the job title
|
27 |
+
prompt = f"Enhance the following resume text for a {job_title} position: {resume_text}"
|
28 |
+
llama_response = llama_client(prompt)
|
29 |
+
|
30 |
+
# 3. Use your custom model for additional predictions (e.g., key skills, professional summary)
|
31 |
+
# Here, we simulate predictions based on your model's capabilities
|
32 |
+
predictions = model.predict([[job_title]]) # Adjust this based on your model's input requirements
|
33 |
+
enhanced_skills = ["Skill A", "Skill B", "Skill C"] # Replace with model-predicted skills
|
34 |
+
|
35 |
+
# 4. Populate the HTML template with the enhanced content
|
36 |
+
template = env.get_template("resume_template.html")
|
37 |
+
rendered_resume = template.render(
|
38 |
+
name="John Doe",
|
39 |
+
email="john.doe@example.com",
|
40 |
+
phone="123-456-7890",
|
41 |
+
location="San Francisco, CA",
|
42 |
+
summary=llama_response["generated_text"],
|
43 |
+
skills=enhanced_skills,
|
44 |
+
experiences=["Experience 1", "Experience 2"],
|
45 |
+
educations=["Bachelor's in Computer Science", "Master's in Data Science"]
|
46 |
+
)
|
47 |
+
|
48 |
+
return rendered_resume
|
49 |
+
|
50 |
+
# Define the Gradio interface
|
51 |
iface = gr.Interface(
|
52 |
fn=enhance_resume,
|
53 |
+
inputs=["text", "text"], # Upload resume text and specify job title
|
54 |
+
outputs="html", # Rendered HTML output
|
|
|
55 |
title="Resume Enhancer",
|
56 |
+
description="Upload a resume and specify a job title to enhance it.",
|
57 |
)
|
58 |
|
59 |
+
# Launch the Gradio app
|
60 |
iface.launch()
|