Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
|
@@ -327,93 +327,94 @@ col1, col2 = st.columns([1, 1])
|
|
| 327 |
with col1:
|
| 328 |
st.header(" Upload & Configure")
|
| 329 |
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
|
| 342 |
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
|
| 356 |
-
|
| 357 |
|
| 358 |
-
|
| 359 |
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
},
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
},
|
| 396 |
-
"Other": {
|
| 397 |
-
"Phone": ["Other Model"],
|
| 398 |
-
"Laptop": ["Other Model"]
|
| 399 |
-
}
|
| 400 |
}
|
|
|
|
| 401 |
|
| 402 |
-
|
| 403 |
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
|
| 411 |
-
|
| 412 |
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
# Form submit button
|
|
|
|
| 417 |
submitted = st.form_submit_button(" Diagnose Device", type="primary")
|
| 418 |
|
| 419 |
with col2:
|
|
|
|
| 327 |
with col1:
|
| 328 |
st.header(" Upload & Configure")
|
| 329 |
|
| 330 |
+
#
|
| 331 |
+
uploaded_file = st.file_uploader(
|
| 332 |
+
"Choose a device image",
|
| 333 |
+
type=['jpg', 'jpeg', 'png'],
|
| 334 |
+
help="Upload a clear image of your device",
|
| 335 |
+
key="uploader"
|
| 336 |
+
)
|
| 337 |
|
| 338 |
+
if uploaded_file:
|
| 339 |
+
st.session_state.image_bytes = uploaded_file.getvalue()
|
| 340 |
+
st.session_state.image_name = uploaded_file.name
|
| 341 |
|
| 342 |
|
| 343 |
+
# Load image from session state (persists across reruns)
|
| 344 |
+
image = None
|
| 345 |
+
if "image_bytes" in st.session_state:
|
| 346 |
+
image = Image.open(io.BytesIO(st.session_state.image_bytes))
|
| 347 |
+
st.image(image, caption="Uploaded Image", use_column_width=False)
|
| 348 |
|
| 349 |
+
description = st.text_area(
|
| 350 |
+
"Describe the issue (optional)",
|
| 351 |
+
placeholder="e.g., My phone screen cracked after I dropped it. Touch is not working properly.",
|
| 352 |
+
height=100,
|
| 353 |
+
help="Providing a description improves accuracy"
|
| 354 |
+
)
|
| 355 |
|
| 356 |
+
st.subheader(" Device Information (for price prediction)")
|
| 357 |
|
| 358 |
+
col_a, col_b = st.columns(2)
|
| 359 |
|
| 360 |
+
with col_a:
|
| 361 |
+
brand = st.selectbox(
|
| 362 |
+
"Brand",
|
| 363 |
+
["Apple", "Samsung", "OnePlus", "Dell", "HP", "Lenovo", "Other"]
|
| 364 |
+
)
|
| 365 |
|
| 366 |
+
device_type = st.selectbox(
|
| 367 |
+
"Device Type",
|
| 368 |
+
["Phone", "Laptop"]
|
| 369 |
+
)
|
| 370 |
|
| 371 |
+
model_options = {
|
| 372 |
+
"Apple": {
|
| 373 |
+
"Phone": ["iPhone 15 Pro Max", "iPhone 15 Pro", "iPhone 15", "iPhone 14 Pro Max", "iPhone 14 Pro", "iPhone 14", "iPhone 13 Pro Max", "iPhone 13 Pro", "iPhone 13", "iPhone 12 Pro Max", "iPhone 12 Pro", "iPhone 12", "iPhone 11 Pro Max", "iPhone 11 Pro", "iPhone 11", "iPhone XS Max", "iPhone XS", "iPhone XR", "iPhone X", "iPhone 8 Plus", "iPhone 8"],
|
| 374 |
+
"Laptop": ["MacBook Pro 16\" M3 Max", "MacBook Pro 14\" M3 Pro", "MacBook Pro 16\" M2 Max", "MacBook Pro 14\" M2 Pro", "MacBook Air M3", "MacBook Air M2", "MacBook Air M1", "MacBook Pro 13\" M1"]
|
| 375 |
+
},
|
| 376 |
+
"Samsung": {
|
| 377 |
+
"Phone": ["Galaxy S24 Ultra", "Galaxy S24+", "Galaxy S24", "Galaxy S23 Ultra", "Galaxy S23+", "Galaxy S23", "Galaxy S22 Ultra", "Galaxy S22+", "Galaxy S22", "Galaxy Z Fold 5", "Galaxy Z Flip 5", "Galaxy Z Fold 4", "Galaxy Z Flip 4", "Galaxy A54", "Galaxy A34"],
|
| 378 |
+
"Laptop": ["Galaxy Book4 Pro", "Galaxy Book3 Ultra", "Galaxy Book3 Pro 360", "Galaxy Book2 Pro", "Galaxy Book2"]
|
| 379 |
+
},
|
| 380 |
+
"OnePlus": {
|
| 381 |
+
"Phone": ["OnePlus 12", "OnePlus 11", "OnePlus 10 Pro", "OnePlus 9 Pro", "OnePlus 9", "OnePlus 8T", "OnePlus Nord 3", "OnePlus Nord 2"],
|
| 382 |
+
"Laptop": []
|
| 383 |
},
|
| 384 |
+
"Dell": {
|
| 385 |
+
"Phone": [],
|
| 386 |
+
"Laptop": ["XPS 15", "XPS 13", "XPS 17", "Inspiron 15", "Inspiron 14", "Latitude 5430", "Latitude 7430", "Alienware m15", "Alienware x15", "Vostro 15"]
|
| 387 |
+
},
|
| 388 |
+
"HP": {
|
| 389 |
+
"Phone": [],
|
| 390 |
+
"Laptop": ["Pavilion 15", "Pavilion 14", "Envy 15", "Envy 13", "Spectre x360 14", "Spectre x360 16", "EliteBook 840", "EliteBook 850", "ProBook 450", "Omen 15"]
|
| 391 |
+
},
|
| 392 |
+
"Lenovo": {
|
| 393 |
+
"Phone": [],
|
| 394 |
+
"Laptop": ["ThinkPad X1 Carbon", "ThinkPad X1 Yoga", "ThinkPad T14", "ThinkPad T16", "IdeaPad Slim 5", "IdeaPad Gaming 3", "Yoga 9i", "Yoga 7i", "Legion 5 Pro"]
|
| 395 |
+
},
|
| 396 |
+
"Other": {
|
| 397 |
+
"Phone": ["Other Model"],
|
| 398 |
+
"Laptop": ["Other Model"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 399 |
}
|
| 400 |
+
}
|
| 401 |
|
| 402 |
+
available_models = model_options.get(brand, {}).get(device_type, ["Other Model"])
|
| 403 |
|
| 404 |
+
with col_b:
|
| 405 |
+
if available_models:
|
| 406 |
+
model = st.selectbox("Model", available_models)
|
| 407 |
+
else:
|
| 408 |
+
st.warning(f"No {device_type} models available for {brand}")
|
| 409 |
+
model = st.text_input("Model (enter manually)", "")
|
| 410 |
|
| 411 |
+
original_price = st.number_input("Original Price (₹)", min_value=0, value=79900, step=1000)
|
| 412 |
|
| 413 |
+
age_months = st.slider("Age (months)", 0, 60, 18, help="How old is the device?")
|
| 414 |
+
if st.session_state.processing:
|
| 415 |
+
st.warning("⏳ Processing… please wait")
|
| 416 |
# Form submit button
|
| 417 |
+
with st.form("diagnosis_form"):
|
| 418 |
submitted = st.form_submit_button(" Diagnose Device", type="primary")
|
| 419 |
|
| 420 |
with col2:
|