File size: 1,557 Bytes
b9b4796
 
f13a3ca
 
 
 
 
 
 
 
 
9e57aa8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f13a3ca
b9b4796
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
import os
os.system('pip install transformers')
# 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
from google.colab import files
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)

# Upload your dataset
uploaded = files.upload()

# Load the dataset
filename = next(iter(uploaded))  # Automatically get the first uploaded file's name
df = pd.read_excel(filename)  # Read the uploaded Excel file

# Display the columns in the uploaded DataFrame to help identify correct names
print("Columns in the dataset:", df.columns.tolist())

# Function to search by name and return the PEC number
def search_by_name(name):
    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 with the updated syntax
iface = gr.Interface(
    fn=search_by_name,
    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."
)

# Launch the Gradio interface
iface.launch()