Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,6 +33,21 @@ def classify_image(image):
|
|
| 33 |
st.error("Image classification failed. Please try again.")
|
| 34 |
return None
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def find_closest_match(df, brand, model):
|
| 37 |
match = df[(df['make'].str.contains(brand, case=False)) & (df['model'].str.contains(model, case=False))]
|
| 38 |
if not match.empty:
|
|
|
|
| 33 |
st.error("Image classification failed. Please try again.")
|
| 34 |
return None
|
| 35 |
|
| 36 |
+
@st.cache_data
|
| 37 |
+
def load_datasets():
|
| 38 |
+
try:
|
| 39 |
+
with st.spinner('Loading dataset...'):
|
| 40 |
+
# Use BytesIO to read the CSV content
|
| 41 |
+
original_data = pd.read_csv('CTP_Model1.csv', low_memory=False)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
# Ensure column names match the model's expectations
|
| 45 |
+
original_data.columns = original_data.columns.str.strip().str.capitalize()
|
| 46 |
+
return original_data
|
| 47 |
+
except Exception as e:
|
| 48 |
+
st.error(f"Error loading dataset: {str(e)}")
|
| 49 |
+
raise e
|
| 50 |
+
|
| 51 |
def find_closest_match(df, brand, model):
|
| 52 |
match = df[(df['make'].str.contains(brand, case=False)) & (df['model'].str.contains(model, case=False))]
|
| 53 |
if not match.empty:
|