Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 10 |
-
summary_generator = pipeline("text2text-generation", model="google/flan-t5-
|
| 11 |
|
| 12 |
-
def generate_resume(name, job_title, email, phone, skills, education, experience, photo):
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 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
|
| 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="
|
| 95 |
-
description="
|
|
|
|
| 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()
|