Spaces:
Sleeping
Sleeping
File size: 1,721 Bytes
b9b4796 f13a3ca 65e80e3 bf33cf7 cb24176 f13a3ca cb24176 f13a3ca 9e57aa8 bf33cf7 e403126 bf33cf7 e403126 9e57aa8 80e0122 e403126 9e57aa8 f13a3ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import os
os.system('pip install transformers')
# Import the necessary libraries
import os
os.system('pip install torch')
# Import the necessary libraries
# Import the necessary libraries
from transformers import AutoModel, AutoTokenizer
import torch
from torch.utils.data import DataLoader, Dataset
from sklearn.model_selection import train_test_split # Corrected import statement
import pandas as pd
import gradio as gr
# Load the pre-trained model and tokenizer
model = AutoModel.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
# Function to load the dataset
def load_dataset():
df = pd.read_excel("your_dataset.xlsx") # Ensure the file name and path are correct
print("Columns in the dataset:", df.columns.tolist())
return df
# Example function to search by name and return the PEC number
def search_by_name(name, df):
name_matches = df[df['Name'].str.contains(name, case=False, na=False)]
if not name_matches.empty:
return f"Your PEC number: {name_matches['PEC No'].values[0]}"
else:
return "No matches found for your name."
# Gradio interface
def build_interface():
df = load_dataset() # Load your dataset
iface = gr.Interface(
fn=lambda name: search_by_name(name, df),
inputs=gr.Textbox(label="Please write your Name"),
outputs=gr.Textbox(label="Your PEC number"),
title="PEC Number Lookup",
description="Enter your name to find your PEC number."
)
return iface
# Main function to run the Gradio app
if __name__ == "__main__":
iface = build_interface()
iface.launch()
|