Engineer / app.py
atifsial123's picture
Create app.py
9e57aa8 verified
raw
history blame
1.24 kB
# 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()