monster07 commited on
Commit
48b8a9c
ยท
verified ยท
1 Parent(s): 4253246

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -6,15 +6,17 @@ from reportlab.pdfgen import canvas
6
  from reportlab.lib.utils import ImageReader
7
  from transformers import pipeline
8
 
9
- # Load FLAN-T5 model from Hugging Face
10
- summary_generator = pipeline("text2text-generation", model="google/flan-t5-base")
11
 
12
- def generate_resume(name, job_title, email, phone, skills, education, experience, photo):
13
- # Generate a passionate summary
14
- prompt = f"Write a passionate summary for a person named {name}, applying as a {job_title}, skilled in {skills}, with experience in {experience}."
15
- summary = summary_generator(prompt, max_length=200)[0]["generated_text"]
 
 
 
16
 
17
- # Create PDF buffer
18
  buffer = io.BytesIO()
19
  pdf = canvas.Canvas(buffer, pagesize=A4)
20
  width, height = A4
@@ -77,7 +79,7 @@ def generate_resume(name, job_title, email, phone, skills, education, experience
77
  buffer.seek(0)
78
  return buffer
79
 
80
- # Gradio UI
81
  iface = gr.Interface(
82
  fn=generate_resume,
83
  inputs=[
@@ -88,11 +90,13 @@ iface = gr.Interface(
88
  gr.Textbox(label="Skills (comma-separated)"),
89
  gr.Textbox(label="Education (use ; to separate items)"),
90
  gr.Textbox(label="Experience (use ; to separate items)"),
91
- gr.File(label="Profile Photo (optional)", type="binary")
 
92
  ],
93
  outputs=gr.File(label="๐Ÿ“„ Download Resume PDF"),
94
- title="๐Ÿง  AI Resume Builder (ReportLab + FLAN-T5)",
95
- description="Generates a beautiful resume with AI-generated summary using FLAN-T5 and exports a working PDF (100% compatible with Hugging Face Spaces)."
 
96
  )
97
 
98
  iface.launch()
 
6
  from reportlab.lib.utils import ImageReader
7
  from transformers import pipeline
8
 
9
+ # Load smaller faster model
10
+ summary_generator = pipeline("text2text-generation", model="google/flan-t5-small")
11
 
12
+ def generate_resume(name, job_title, email, phone, skills, education, experience, photo, use_ai):
13
+ # Fast AI summary or fallback
14
+ if use_ai:
15
+ prompt = f"Write a passionate professional summary for {name}, applying as a {job_title}, skilled in {skills}, with experience in {experience}."
16
+ summary = summary_generator(prompt, max_length=200)[0]["generated_text"]
17
+ else:
18
+ summary = f"{name} is a passionate {job_title} with skills in {skills}, and experience in {experience}."
19
 
 
20
  buffer = io.BytesIO()
21
  pdf = canvas.Canvas(buffer, pagesize=A4)
22
  width, height = A4
 
79
  buffer.seek(0)
80
  return buffer
81
 
82
+ # Launch Gradio App
83
  iface = gr.Interface(
84
  fn=generate_resume,
85
  inputs=[
 
90
  gr.Textbox(label="Skills (comma-separated)"),
91
  gr.Textbox(label="Education (use ; to separate items)"),
92
  gr.Textbox(label="Experience (use ; to separate items)"),
93
+ gr.File(label="Profile Photo (optional)", type="binary"),
94
+ gr.Checkbox(label="Use AI to auto-generate summary?", value=True)
95
  ],
96
  outputs=gr.File(label="๐Ÿ“„ Download Resume PDF"),
97
+ title="๐Ÿš€ AI Resume Builder (Fast Edition)",
98
+ description="Create a smart resume using FLAN-T5-Small for fast AI summary or manual fallback. Works great on Hugging Face Spaces!",
99
+ live=True
100
  )
101
 
102
  iface.launch()