Spaces:
Sleeping
Sleeping
atifsial123
commited on
Commit
•
d121c92
1
Parent(s):
69e8c1f
Update app.py
Browse files
app.py
CHANGED
@@ -13,8 +13,8 @@ install("openpyxl")
|
|
13 |
import pandas as pd
|
14 |
import gradio as gr
|
15 |
|
16 |
-
# Function to load the dataset from
|
17 |
-
def load_dataset(file_path):
|
18 |
try:
|
19 |
df = pd.read_excel(file_path)
|
20 |
print("File loaded successfully.")
|
@@ -41,10 +41,10 @@ def get_details(name, df):
|
|
41 |
return "Name not found."
|
42 |
|
43 |
# Combine the functions to create a prediction
|
44 |
-
def predict(name
|
45 |
try:
|
46 |
-
# Load the dataset from the
|
47 |
-
df = load_dataset(
|
48 |
|
49 |
# Get details for the provided name
|
50 |
if df is not None:
|
@@ -56,13 +56,13 @@ def predict(name, file):
|
|
56 |
print(f"An error occurred: {e}")
|
57 |
return f"Error: {e}"
|
58 |
|
59 |
-
# Build the Gradio interface
|
60 |
iface = gr.Interface(
|
61 |
fn=predict,
|
62 |
-
inputs=
|
63 |
outputs="json",
|
64 |
title="Name Details Lookup",
|
65 |
-
description="
|
66 |
)
|
67 |
|
68 |
# Run the Gradio interface
|
|
|
13 |
import pandas as pd
|
14 |
import gradio as gr
|
15 |
|
16 |
+
# Function to load the dataset from the provided file path
|
17 |
+
def load_dataset(file_path='cleaned_data.xlsx'):
|
18 |
try:
|
19 |
df = pd.read_excel(file_path)
|
20 |
print("File loaded successfully.")
|
|
|
41 |
return "Name not found."
|
42 |
|
43 |
# Combine the functions to create a prediction
|
44 |
+
def predict(name):
|
45 |
try:
|
46 |
+
# Load the dataset from the provided file path
|
47 |
+
df = load_dataset()
|
48 |
|
49 |
# Get details for the provided name
|
50 |
if df is not None:
|
|
|
56 |
print(f"An error occurred: {e}")
|
57 |
return f"Error: {e}"
|
58 |
|
59 |
+
# Build the Gradio interface without the file upload option
|
60 |
iface = gr.Interface(
|
61 |
fn=predict,
|
62 |
+
inputs=gr.Textbox(lines=1, label="**Enter Name**"), # Bold label for Name
|
63 |
outputs="json",
|
64 |
title="Name Details Lookup",
|
65 |
+
description="Enter a name to find all details associated with it from the 'cleaned_data.xlsx' file."
|
66 |
)
|
67 |
|
68 |
# Run the Gradio interface
|