Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,70 +1,62 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import tensorflow as tf
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
# Load your
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
technical_skills=enhanced_content["technical_skills"],
|
| 40 |
-
experience=enhanced_content["experience"],
|
| 41 |
-
education=enhanced_content["education"]
|
| 42 |
-
)
|
| 43 |
-
|
| 44 |
-
return filled_resume
|
| 45 |
-
|
| 46 |
-
# Gradio interface
|
| 47 |
-
def gradio_interface(resume_text, job_title):
|
| 48 |
-
# Generate the filled-in resume HTML
|
| 49 |
-
filled_resume = fill_resume_template(resume_text, job_title)
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
)
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
import tensorflow as tf
|
| 4 |
+
from huggingface_hub import InferenceClient
|
| 5 |
+
import fitz # PyMuPDF
|
| 6 |
+
|
| 7 |
+
# Load your TensorFlow model
|
| 8 |
+
model_path = 'resume_generator_model.h5'
|
| 9 |
+
resume_model = tf.keras.models.load_model(model_path)
|
| 10 |
+
|
| 11 |
+
# Initialize the LLaMA model
|
| 12 |
+
llama_client = InferenceClient("meta-llama/Meta-Llama-3.1-8B-Instruct")
|
| 13 |
+
|
| 14 |
+
# Function to extract text from PDF or text files
|
| 15 |
+
def extract_text(file):
|
| 16 |
+
text = ""
|
| 17 |
+
if file.name.endswith('.pdf'):
|
| 18 |
+
with fitz.open(file.name) as pdf:
|
| 19 |
+
for page in pdf:
|
| 20 |
+
text += page.get_text()
|
| 21 |
+
else:
|
| 22 |
+
text = file.read().decode('utf-8')
|
| 23 |
+
return text
|
| 24 |
+
|
| 25 |
+
# Function to enhance the resume using both models
|
| 26 |
+
def enhance_resume(file, job_title):
|
| 27 |
+
# Extract text from the uploaded resume
|
| 28 |
+
resume_text = extract_text(file)
|
| 29 |
+
|
| 30 |
+
# Generate enhancements using your model
|
| 31 |
+
# This is a placeholder for your actual model's prediction logic
|
| 32 |
+
enhanced_content = resume_model.predict([resume_text]) # Adjust as needed
|
| 33 |
+
|
| 34 |
+
# Use LLaMA to enhance the resume based on job title
|
| 35 |
+
llama_input = f"Enhance this resume for the job title: {job_title}. Original resume: {resume_text}"
|
| 36 |
+
llama_output = llama_client(llama_input)
|
| 37 |
+
|
| 38 |
+
# Combine outputs
|
| 39 |
+
final_output = f"{enhanced_content}\n\n{llama_output['generated_text']}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
# Load and fill in the HTML template
|
| 42 |
+
with open("templates/resume_template.html", "r") as f:
|
| 43 |
+
template = f.read()
|
| 44 |
+
|
| 45 |
+
# Replace placeholder with the user's name (extract name from resume)
|
| 46 |
+
user_name = "User" # Replace this with logic to extract the name from resume
|
| 47 |
+
filled_template = template.replace("{{ name }}", user_name)
|
| 48 |
+
filled_template = filled_template.replace("{{ content }}", final_output)
|
| 49 |
+
|
| 50 |
+
return filled_template
|
| 51 |
+
|
| 52 |
+
# Gradio Interface
|
| 53 |
+
gr.Interface(
|
| 54 |
+
fn=enhance_resume,
|
| 55 |
+
inputs=[
|
| 56 |
+
gr.File(label="Upload Resume (PDF/Text)"),
|
| 57 |
+
gr.Textbox(label="Job Title")
|
| 58 |
+
],
|
| 59 |
+
outputs=gr.HTML(label="Enhanced Resume"),
|
| 60 |
+
title="Resume Enhancer",
|
| 61 |
+
description="Upload your resume and provide a job title to enhance your resume."
|
| 62 |
+
).launch()
|