Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,8 @@ model = AutoModel.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_rem
|
|
24 |
def load_dataset(file_path='PEC_Numbers_and_Names.xlsx'):
|
25 |
if os.path.exists(file_path):
|
26 |
df = pd.read_excel(file_path)
|
|
|
|
|
27 |
else:
|
28 |
raise FileNotFoundError(f"File not found: {file_path}")
|
29 |
return df
|
@@ -31,13 +33,16 @@ def load_dataset(file_path='PEC_Numbers_and_Names.xlsx'):
|
|
31 |
# Function to get the name based on the PEC number
|
32 |
def get_name(pec_number, df):
|
33 |
df['PEC No.'] = df['PEC No.'].str.strip().str.upper()
|
34 |
-
pec_number = pec_number.strip().
|
35 |
|
|
|
36 |
result = df[df['PEC No.'] == pec_number]
|
37 |
|
38 |
if not result.empty:
|
|
|
39 |
return result.iloc[0]['Name']
|
40 |
else:
|
|
|
41 |
return "PEC Number not found."
|
42 |
|
43 |
# Function to process the PEC number using the Hugging Face model
|
@@ -56,8 +61,9 @@ def predict(pec_number):
|
|
56 |
name = get_name(pec_number, df)
|
57 |
model_output = process_with_model(pec_number)
|
58 |
return f"Name: {name}\nModel Output: {model_output}"
|
59 |
-
except
|
60 |
-
|
|
|
61 |
|
62 |
# Build the Gradio interface without the file upload option
|
63 |
iface = gr.Interface(
|
@@ -71,3 +77,4 @@ iface = gr.Interface(
|
|
71 |
# Run the Gradio interface
|
72 |
if __name__ == "__main__":
|
73 |
iface.launch()
|
|
|
|
24 |
def load_dataset(file_path='PEC_Numbers_and_Names.xlsx'):
|
25 |
if os.path.exists(file_path):
|
26 |
df = pd.read_excel(file_path)
|
27 |
+
print("File loaded successfully.")
|
28 |
+
print(df.head()) # Print first few rows for debugging
|
29 |
else:
|
30 |
raise FileNotFoundError(f"File not found: {file_path}")
|
31 |
return df
|
|
|
33 |
# Function to get the name based on the PEC number
|
34 |
def get_name(pec_number, df):
|
35 |
df['PEC No.'] = df['PEC No.'].str.strip().str.upper()
|
36 |
+
pec_number = pec_number.strip().upper()
|
37 |
|
38 |
+
print(f"Searching for PEC Number: {pec_number}") # Debugging output
|
39 |
result = df[df['PEC No.'] == pec_number]
|
40 |
|
41 |
if not result.empty:
|
42 |
+
print(f"Found Name: {result.iloc[0]['Name']}") # Debugging output
|
43 |
return result.iloc[0]['Name']
|
44 |
else:
|
45 |
+
print("PEC Number not found.") # Debugging output
|
46 |
return "PEC Number not found."
|
47 |
|
48 |
# Function to process the PEC number using the Hugging Face model
|
|
|
61 |
name = get_name(pec_number, df)
|
62 |
model_output = process_with_model(pec_number)
|
63 |
return f"Name: {name}\nModel Output: {model_output}"
|
64 |
+
except Exception as e:
|
65 |
+
print(f"An error occurred: {e}")
|
66 |
+
return f"Error: {e}"
|
67 |
|
68 |
# Build the Gradio interface without the file upload option
|
69 |
iface = gr.Interface(
|
|
|
77 |
# Run the Gradio interface
|
78 |
if __name__ == "__main__":
|
79 |
iface.launch()
|
80 |
+
|