Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""gradio_deploy.ipynb
|
| 3 |
+
Automatically generated by Colaboratory.
|
| 4 |
+
"""
|
| 5 |
+
import os
|
| 6 |
+
import gradio
|
| 7 |
+
from PIL import Image
|
| 8 |
+
from timeit import default_timer as timer
|
| 9 |
+
from tensorflow import keras
|
| 10 |
+
import torch
|
| 11 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 12 |
+
import numpy as np
|
| 13 |
+
|
| 14 |
+
loaded_model = AutoModelForSequenceClassification.from_pretrained("runaksh/ResumeClassification_distilBERT")
|
| 15 |
+
loaded_tokenizer = AutoTokenizer.from_pretrained("runaksh/ResumeClassification_distilBERT")
|
| 16 |
+
|
| 17 |
+
# Function for class prediction
|
| 18 |
+
def predict(sample, validate=True):
|
| 19 |
+
classifier = pipeline("text-classification", model=loaded_model, tokenizer=loaded_tokenizer)
|
| 20 |
+
pred = classifier(sample)[0]['label']
|
| 21 |
+
return pred
|
| 22 |
+
|
| 23 |
+
title = "Categorizing the Resumes"
|
| 24 |
+
description = "Enter the Resume you want to categorize"
|
| 25 |
+
|
| 26 |
+
# Gradio elements
|
| 27 |
+
|
| 28 |
+
# Input from user
|
| 29 |
+
in_prompt = gradio.inputs.Textbox(lines=2, label='Enter the Resume')
|
| 30 |
+
|
| 31 |
+
# Output response
|
| 32 |
+
out_response = gradio.outputs.Textbox(label='Category')
|
| 33 |
+
|
| 34 |
+
# Gradio interface to generate UI link
|
| 35 |
+
iface = gradio.Interface(fn=predict,
|
| 36 |
+
inputs = in_prompt,
|
| 37 |
+
outputs = out_response,
|
| 38 |
+
title=title,
|
| 39 |
+
description=description
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
iface.launch(debug = True)
|