Spaces:
Runtime error
Runtime error
import os | |
import gradio as gr | |
import tensorflow as tf | |
import spacy | |
from transformers import InferenceClient | |
from jinja2 import Environment, FileSystemLoader | |
# Load spaCy model | |
nlp = spacy.load("en_core_web_sm") | |
# Load your TensorFlow model | |
model = tf.keras.models.load_model("resume_generator_model.h5") | |
# Initialize the InferenceClient for LLaMA | |
llama_client = InferenceClient(model="meta-llama/Meta-Llama-3.1-8B-Instruct") | |
# Configure Jinja2 for template rendering | |
env = Environment(loader=FileSystemLoader("templates")) | |
# Helper function to enhance the resume content using spaCy and LLaMA | |
def enhance_resume(resume_text, job_title): | |
# 1. Analyze the resume using spaCy | |
doc = nlp(resume_text) | |
entities = [(ent.text, ent.label_) for ent in doc.ents] | |
# 2. Use LLaMA model to generate new content based on the job title | |
prompt = f"Enhance the following resume text for a {job_title} position: {resume_text}" | |
llama_response = llama_client(prompt) | |
# 3. Use your custom model for additional predictions (e.g., key skills, professional summary) | |
# Here, we simulate predictions based on your model's capabilities | |
predictions = model.predict([[job_title]]) # Adjust this based on your model's input requirements | |
enhanced_skills = ["Skill A", "Skill B", "Skill C"] # Replace with model-predicted skills | |
# 4. Populate the HTML template with the enhanced content | |
template = env.get_template("resume_template.html") | |
rendered_resume = template.render( | |
name="John Doe", | |
email="john.doe@example.com", | |
phone="123-456-7890", | |
location="San Francisco, CA", | |
summary=llama_response["generated_text"], | |
skills=enhanced_skills, | |
experiences=["Experience 1", "Experience 2"], | |
educations=["Bachelor's in Computer Science", "Master's in Data Science"] | |
) | |
return rendered_resume | |
# Define the Gradio interface | |
iface = gr.Interface( | |
fn=enhance_resume, | |
inputs=["text", "text"], # Upload resume text and specify job title | |
outputs="html", # Rendered HTML output | |
title="Resume Enhancer", | |
description="Upload a resume and specify a job title to enhance it.", | |
) | |
# Launch the Gradio app | |
iface.launch() | |