Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
from sentence_transformers import SentenceTransformer
|
|
|
|
| 4 |
|
| 5 |
-
# Load models
|
| 6 |
print("Loading BERT NER model...")
|
| 7 |
ner_pipeline = pipeline("ner", model="yashpwr/resume-ner-bert-v2", aggregation_strategy="simple")
|
| 8 |
|
| 9 |
print("Loading SBERT model...")
|
| 10 |
similarity_model = SentenceTransformer("all-MiniLM-L6-v2")
|
| 11 |
|
|
|
|
|
|
|
| 12 |
def parse_resume(text):
|
| 13 |
if not text:
|
| 14 |
return {"error": "Empty input"}
|
|
@@ -25,6 +28,7 @@ def parse_resume(text):
|
|
| 25 |
except Exception as e:
|
| 26 |
return {"error": str(e)}
|
| 27 |
|
|
|
|
| 28 |
def get_embeddings(text):
|
| 29 |
if not text:
|
| 30 |
return {"error": "Empty input"}
|
|
@@ -34,7 +38,7 @@ def get_embeddings(text):
|
|
| 34 |
except Exception as e:
|
| 35 |
return {"error": str(e)}
|
| 36 |
|
| 37 |
-
# Create Gradio UI
|
| 38 |
with gr.Blocks() as demo:
|
| 39 |
gr.Markdown("# AI Resume Matcher Serverless API")
|
| 40 |
|
|
@@ -50,5 +54,4 @@ with gr.Blocks() as demo:
|
|
| 50 |
vector_output = gr.JSON(label="Embedding Vector")
|
| 51 |
embed_btn.click(fn=get_embeddings, inputs=text_input_emb, outputs=vector_output, api_name="embed")
|
| 52 |
|
| 53 |
-
# Launch the Gradio application
|
| 54 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
from sentence_transformers import SentenceTransformer
|
| 4 |
+
import spaces # Import Hugging Face ZeroGPU module
|
| 5 |
|
| 6 |
+
# Load models
|
| 7 |
print("Loading BERT NER model...")
|
| 8 |
ner_pipeline = pipeline("ner", model="yashpwr/resume-ner-bert-v2", aggregation_strategy="simple")
|
| 9 |
|
| 10 |
print("Loading SBERT model...")
|
| 11 |
similarity_model = SentenceTransformer("all-MiniLM-L6-v2")
|
| 12 |
|
| 13 |
+
# Decorate GPU functions
|
| 14 |
+
@spaces.GPU
|
| 15 |
def parse_resume(text):
|
| 16 |
if not text:
|
| 17 |
return {"error": "Empty input"}
|
|
|
|
| 28 |
except Exception as e:
|
| 29 |
return {"error": str(e)}
|
| 30 |
|
| 31 |
+
@spaces.GPU
|
| 32 |
def get_embeddings(text):
|
| 33 |
if not text:
|
| 34 |
return {"error": "Empty input"}
|
|
|
|
| 38 |
except Exception as e:
|
| 39 |
return {"error": str(e)}
|
| 40 |
|
| 41 |
+
# Create Gradio UI
|
| 42 |
with gr.Blocks() as demo:
|
| 43 |
gr.Markdown("# AI Resume Matcher Serverless API")
|
| 44 |
|
|
|
|
| 54 |
vector_output = gr.JSON(label="Embedding Vector")
|
| 55 |
embed_btn.click(fn=get_embeddings, inputs=text_input_emb, outputs=vector_output, api_name="embed")
|
| 56 |
|
|
|
|
| 57 |
demo.launch()
|