Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import openai
|
| 3 |
+
import fitz # PyMuPDF
|
| 4 |
+
import torch
|
| 5 |
+
from transformers import pipeline, BloomForCausalLM, BloomTokenizerFast
|
| 6 |
+
from huggingface_hub import login
|
| 7 |
+
import requests
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
from models import evaluate_with_gpt,evaluate_with_gemma,evaluate_with_bloom,evaluate_with_jabir,evaluate_with_llama
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def extract_text_from_pdf(pdf_file):
|
| 15 |
+
document = fitz.open(pdf_file)
|
| 16 |
+
text = ""
|
| 17 |
+
for page_num in range(len(document)):
|
| 18 |
+
page = document.load_page(page_num)
|
| 19 |
+
text += page.get_text()
|
| 20 |
+
return text
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def evaluate_all_models(pdf_file, job_description):
|
| 25 |
+
gpt_result = evaluate_with_gpt(pdf_file, job_description)
|
| 26 |
+
gemma_result = evaluate_with_gemma(pdf_file, job_description)
|
| 27 |
+
bloom_result = evaluate_with_bloom(pdf_file, job_description)
|
| 28 |
+
jabir_result = evaluate_with_jabir(pdf_file, job_description)
|
| 29 |
+
llama_result=evaluate_with_llama(pdf_file, job_description)
|
| 30 |
+
return f"GPT-4o Result:\n{gpt_result}\n\nGemma Result:\n{gemma_result}\n\nBloom Result:\n{bloom_result}\n\njabir Result:\n{jabir_result}\n\nllama Result:\n{llam_result}"
|
| 31 |
+
|
| 32 |
+
iface = gr.Interface(
|
| 33 |
+
fn=lambda pdf, jd, model: evaluate_with_gpt(pdf, jd) if model == "GPT-4o" else evaluate_with_gemma(pdf, jd) if model == "Gemma" else evaluate_with_bloom(pdf, jd) if model == "Bloom" else evaluate_with_jabir(pdf, jd) if model == "jabir" else evaluate_all_models(pdf, jd) if model == "llama" else evaluate_all_models(pdf, jd),
|
| 34 |
+
inputs=[
|
| 35 |
+
gr.File(label="Upload Resume PDF"),
|
| 36 |
+
gr.Textbox(lines=10, label="Job Description"),
|
| 37 |
+
gr.Radio(choices=["GPT-4o", "Gemma", "Bloom", "jabir"," llama", "All"], label="Choose Model")
|
| 38 |
+
],
|
| 39 |
+
outputs="text",
|
| 40 |
+
title="Resume Evaluator"
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
iface.launch()
|