atifsial123 commited on
Commit
03a4c5e
·
verified ·
1 Parent(s): d2521ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  os.system('pip install transformers')
3
  # Import the necessary libraries
@@ -5,9 +15,11 @@ import os
5
  os.system('pip install torch')
6
  # Import the necessary libraries
7
  # Import the necessary libraries
 
8
  from transformers import AutoModel, AutoTokenizer
9
  import torch
10
  from torch.utils.data import DataLoader, Dataset
 
11
  import pandas as pd
12
  import gradio as gr
13
 
@@ -17,11 +29,11 @@ tokenizer = AutoTokenizer.from_pretrained("Alibaba-NLP/gte-multilingual-base", t
17
 
18
  # Function to load the dataset
19
  def load_dataset():
20
- df = pd.read_excel("your_dataset.xlsx") # Ensure the file name and path are correct
21
  print("Columns in the dataset:", df.columns.tolist())
22
  return df
23
 
24
- # Example function to search by name and return the PEC number
25
  def search_by_name(name, df):
26
  name_matches = df[df['Name'].str.contains(name, case=False, na=False)]
27
  if not name_matches.empty:
 
1
+ # Upload your dataset
2
+ uploaded = files.upload()
3
+
4
+ # Load the dataset
5
+ filename = next(iter(uploaded)) # Automatically get the first uploaded file's name
6
+ df = pd.read_excel(filename) # Read the uploaded Excel file
7
+
8
+ # Display the columns in the uploaded DataFrame to help identify correct names
9
+ print("Columns in the dataset:", df.columns.tolist())
10
+
11
  import os
12
  os.system('pip install transformers')
13
  # Import the necessary libraries
 
15
  os.system('pip install torch')
16
  # Import the necessary libraries
17
  # Import the necessary libraries
18
+ # Import the necessary libraries
19
  from transformers import AutoModel, AutoTokenizer
20
  import torch
21
  from torch.utils.data import DataLoader, Dataset
22
+ from sklearn.model_selection import train_test_split
23
  import pandas as pd
24
  import gradio as gr
25
 
 
29
 
30
  # Function to load the dataset
31
  def load_dataset():
32
+ df = pd.read_excel("data.xlsx") # Ensure the file name and path are correct
33
  print("Columns in the dataset:", df.columns.tolist())
34
  return df
35
 
36
+ # Function to search by name and return the PEC number
37
  def search_by_name(name, df):
38
  name_matches = df[df['Name'].str.contains(name, case=False, na=False)]
39
  if not name_matches.empty: