HudaQamber commited on
Commit
380da11
Β·
verified Β·
1 Parent(s): 3c67378

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -12
app.py CHANGED
@@ -1,27 +1,39 @@
1
  import streamlit as st
2
- from transformers import pipeline
3
 
4
- # Load the summarization pipeline from Hugging Face
5
- rephrase_pipeline = pipeline("text2text-generation", model="Vamsi/T5_Paraphrase_Paws")
 
 
 
 
 
 
 
6
 
7
  def tailor_resume(job_description, resume):
8
- prompt = f"Job Description: {job_description}\nResume: {resume}\n\nRewrite the resume to match the job description:"
9
- output = rephrase_pipeline(prompt, max_length=512, do_sample=True, top_k=50)[0]["generated_text"]
 
10
  return output
11
 
 
12
  st.set_page_config(page_title="Resume Tailor", layout="centered")
13
 
14
  st.title("🎯 Resume Tailoring App")
15
- st.write("Enhance your resume based on the job description using AI.")
16
 
17
- job_desc = st.text_area("πŸ“‹ Paste the Job Description here:", height=200)
18
- resume_input = st.text_area("🧾 Paste Your Resume here:", height=300)
19
 
20
  if st.button("Tailor Resume"):
21
- if job_desc.strip() == "" or resume_input.strip() == "":
22
  st.warning("Please enter both the job description and your resume.")
23
  else:
24
  with st.spinner("Tailoring your resume..."):
25
- tailored_resume = tailor_resume(job_desc, resume_input)
26
- st.subheader("πŸŽ‰ Tailored Resume")
27
- st.text_area("You can now copy your optimized resume below:", value=tailored_resume, height=400)
 
 
 
 
1
  import streamlit as st
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
3
 
4
+ # Load model and tokenizer
5
+ @st.cache_resource
6
+ def load_pipeline():
7
+ model_name = "Vamsi/T5_Paraphrase_Paws"
8
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
9
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
10
+ return pipeline("text2text-generation", model=model, tokenizer=tokenizer)
11
+
12
+ rephrase_pipeline = load_pipeline()
13
 
14
  def tailor_resume(job_description, resume):
15
+ # Create a concise prompt
16
+ prompt = f"paraphrase: Adapt this resume for the job description.\nJob: {job_description}\nResume: {resume}"
17
+ output = rephrase_pipeline(prompt, max_length=512, num_return_sequences=1, clean_up_tokenization_spaces=True)[0]["generated_text"]
18
  return output
19
 
20
+ # Streamlit UI
21
  st.set_page_config(page_title="Resume Tailor", layout="centered")
22
 
23
  st.title("🎯 Resume Tailoring App")
24
+ st.write("Use AI to align your resume with a specific job description.")
25
 
26
+ job_desc = st.text_area("πŸ“‹ Paste the Job Description:", height=200)
27
+ resume_input = st.text_area("🧾 Paste Your Resume:", height=300)
28
 
29
  if st.button("Tailor Resume"):
30
+ if not job_desc.strip() or not resume_input.strip():
31
  st.warning("Please enter both the job description and your resume.")
32
  else:
33
  with st.spinner("Tailoring your resume..."):
34
+ try:
35
+ tailored_resume = tailor_resume(job_desc, resume_input)
36
+ st.subheader("πŸŽ‰ Tailored Resume")
37
+ st.text_area("You can now copy your optimized resume:", value=tailored_resume, height=400)
38
+ except Exception as e:
39
+ st.error(f"Something went wrong: {e}")