atifsial123 commited on
Commit
80e0122
·
verified ·
1 Parent(s): 39c81f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -24
app.py CHANGED
@@ -3,15 +3,10 @@ os.system('pip install transformers')
3
  # Import the necessary libraries
4
  import os
5
  os.system('pip install torch')
6
-
7
- from transformers import AutoModel, AutoTokenizer
8
- import torch
9
-
10
  from transformers import AutoModel, AutoTokenizer
11
  import torch
12
  from torch.utils.data import DataLoader, Dataset
13
  from sklearn.model_selection import train_test_split
14
- from google.colab import files
15
  import pandas as pd
16
  import gradio as gr
17
 
@@ -19,25 +14,12 @@ import gradio as gr
19
  model = AutoModel.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
20
  tokenizer = AutoTokenizer.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
21
 
22
- # Upload your dataset
23
- uploaded = files.upload()
24
-
25
- # Load the dataset
26
- filename = next(iter(uploaded)) # Automatically get the first uploaded file's name
27
- df = pd.read_excel(filename) # Read the uploaded Excel file
28
-
29
- # Display the columns in the uploaded DataFrame to help identify correct names
30
- print("Columns in the dataset:", df.columns.tolist())
31
-
32
- # Function to search by name and return the PEC number
33
  def search_by_name(name):
34
- name_matches = df[df['Name'].str.contains(name, case=False, na=False)]
35
- if not name_matches.empty:
36
- return f"Your PEC number: {name_matches['PEC No'].values[0]}"
37
- else:
38
- return "No matches found for your name."
39
 
40
- # Gradio interface with the updated syntax
41
  iface = gr.Interface(
42
  fn=search_by_name,
43
  inputs=gr.Textbox(label="Please write your Name"),
@@ -46,7 +28,6 @@ iface = gr.Interface(
46
  description="Enter your name to find your PEC number."
47
  )
48
 
49
- # Launch the Gradio interface
50
  iface.launch()
51
 
52
-
 
3
  # Import the necessary libraries
4
  import os
5
  os.system('pip install torch')
 
 
 
 
6
  from transformers import AutoModel, AutoTokenizer
7
  import torch
8
  from torch.utils.data import DataLoader, Dataset
9
  from sklearn.model_selection import train_test_split
 
10
  import pandas as pd
11
  import gradio as gr
12
 
 
14
  model = AutoModel.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
15
  tokenizer = AutoTokenizer.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True)
16
 
17
+ # Example Gradio function
 
 
 
 
 
 
 
 
 
 
18
  def search_by_name(name):
19
+ # Your logic to search by name and return a response
20
+ pass
 
 
 
21
 
22
+ # Gradio interface
23
  iface = gr.Interface(
24
  fn=search_by_name,
25
  inputs=gr.Textbox(label="Please write your Name"),
 
28
  description="Enter your name to find your PEC number."
29
  )
30
 
31
+ # Launch the interface
32
  iface.launch()
33