Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Load the pre-trained model and tokenizer
|
| 3 |
+
model = AutoModel.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
|
| 5 |
+
|
| 6 |
+
# Upload your dataset
|
| 7 |
+
uploaded = files.upload()
|
| 8 |
+
|
| 9 |
+
# Load the dataset
|
| 10 |
+
filename = next(iter(uploaded)) # Automatically get the first uploaded file's name
|
| 11 |
+
df = pd.read_excel(filename) # Read the uploaded Excel file
|
| 12 |
+
|
| 13 |
+
# Display the columns in the uploaded DataFrame to help identify correct names
|
| 14 |
+
print("Columns in the dataset:", df.columns.tolist())
|
| 15 |
+
|
| 16 |
+
# Function to search by name and return the PEC number
|
| 17 |
+
def search_by_name(name):
|
| 18 |
+
name_matches = df[df['Name'].str.contains(name, case=False, na=False)]
|
| 19 |
+
if not name_matches.empty:
|
| 20 |
+
return f"Your PEC number: {name_matches['PEC No'].values[0]}"
|
| 21 |
+
else:
|
| 22 |
+
return "No matches found for your name."
|
| 23 |
+
|
| 24 |
+
# Gradio interface with the updated syntax
|
| 25 |
+
iface = gr.Interface(
|
| 26 |
+
fn=search_by_name,
|
| 27 |
+
inputs=gr.Textbox(label="Please write your Name"),
|
| 28 |
+
outputs=gr.Textbox(label="Your PEC number"),
|
| 29 |
+
title="PEC Number Lookup",
|
| 30 |
+
description="Enter your name to find your PEC number."
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
# Launch the Gradio interface
|
| 34 |
+
iface.launch()
|