atifsial123 commited on
Commit
8212ea2
·
verified ·
1 Parent(s): 353ba65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -46,23 +46,25 @@ def get_name(pec_number, df):
46
  print("PEC Number not found.") # Debugging output
47
  return "PEC Number not found."
48
 
49
- # Function to process the PEC number using the Hugging Face model
50
- def process_with_model(pec_number):
51
- inputs = tokenizer(pec_number, return_tensors="pt")
52
- with torch.no_grad():
53
- outputs = model(**inputs)
54
- # Instead of returning the full model output, return just a simple confirmation
55
- return "Model processed successfully."
 
 
56
 
57
- # Combine both functions to create a prediction
58
  def predict(pec_number):
59
  try:
60
  # Load the dataset from the root directory
61
  df = load_dataset()
62
 
63
  name = get_name(pec_number, df)
64
- model_output = process_with_model(pec_number)
65
- return f"Name: {name}" # Only display the name
66
  except Exception as e:
67
  print(f"An error occurred: {e}")
68
  return f"Error: {e}"
@@ -70,10 +72,10 @@ def predict(pec_number):
70
  # Build the Gradio interface without the file upload option
71
  iface = gr.Interface(
72
  fn=predict,
73
- inputs=gr.Textbox(lines=1, placeholder="Enter PEC Number..."),
74
  outputs="text",
75
  title="PEC Number to Name Lookup",
76
- description="Enter a PEC number to retrieve the corresponding name."
77
  )
78
 
79
  # Run the Gradio interface
 
46
  print("PEC Number not found.") # Debugging output
47
  return "PEC Number not found."
48
 
49
+ # Function to check if the PEC number is attached
50
+ def check_pec_number(pec_number, df):
51
+ df['PEC No.'] = df['PEC No.'].str.strip().str.upper()
52
+ pec_number = pec_number.strip().upper()
53
+
54
+ if pec_number in df['PEC No.'].values:
55
+ return "Your PEC Number is Attached."
56
+ else:
57
+ return "Your PEC Number is Not Attached."
58
 
59
+ # Combine the functions to create a prediction
60
  def predict(pec_number):
61
  try:
62
  # Load the dataset from the root directory
63
  df = load_dataset()
64
 
65
  name = get_name(pec_number, df)
66
+ pec_status = check_pec_number(pec_number, df)
67
+ return f"Your Name is: {name}\n{pec_status}" # Return name and PEC status
68
  except Exception as e:
69
  print(f"An error occurred: {e}")
70
  return f"Error: {e}"
 
72
  # Build the Gradio interface without the file upload option
73
  iface = gr.Interface(
74
  fn=predict,
75
+ inputs=gr.Textbox(lines=1, placeholder="**Enter PEC Number...**"), # Bold placeholder text
76
  outputs="text",
77
  title="PEC Number to Name Lookup",
78
+ description="Enter a PEC number to retrieve the corresponding name and check if your PEC number is attached."
79
  )
80
 
81
  # Run the Gradio interface