PixelPoppie commited on
Commit ·
2a0f308
1
Parent(s): b43b19c
ui update
Browse files
app.py
CHANGED
|
@@ -413,8 +413,9 @@ def build_interface():
|
|
| 413 |
with gr.Tabs():
|
| 414 |
# Predictions Tab
|
| 415 |
with gr.Tab("Make Predictions"):
|
| 416 |
-
#
|
| 417 |
with gr.Row():
|
|
|
|
| 418 |
with gr.Column(scale=1):
|
| 419 |
input_file = gr.File(
|
| 420 |
label="Upload JSON File",
|
|
@@ -429,10 +430,8 @@ def build_interface():
|
|
| 429 |
info="Lower values will result in more predictions, higher values in more human review cases"
|
| 430 |
)
|
| 431 |
predict_btn = gr.Button("Make Predictions", variant="primary")
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
with gr.Row():
|
| 435 |
-
with gr.Column(scale=1):
|
| 436 |
validation_output = gr.Textbox(
|
| 437 |
label="Validation Steps",
|
| 438 |
lines=3,
|
|
@@ -443,18 +442,25 @@ def build_interface():
|
|
| 443 |
label="Download Predictions",
|
| 444 |
value=""
|
| 445 |
)
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
|
| 459 |
# Diagnostics Tab
|
| 460 |
with gr.Tab("Diagnostics"):
|
|
@@ -465,18 +471,10 @@ def build_interface():
|
|
| 465 |
)
|
| 466 |
analyze_btn = gr.Button("Run Diagnostic Analysis", variant="secondary")
|
| 467 |
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
max_lines=30,
|
| 473 |
-
elem_classes="diagnostic-output"
|
| 474 |
-
)
|
| 475 |
-
|
| 476 |
-
analyze_btn.click(
|
| 477 |
-
create_diagnostic_output,
|
| 478 |
-
inputs=[diagnostic_file],
|
| 479 |
-
outputs=[diagnostic_output]
|
| 480 |
)
|
| 481 |
|
| 482 |
# Help Tab
|
|
@@ -487,55 +485,99 @@ def build_interface():
|
|
| 487 |
2. Adjust the confidence threshold if needed
|
| 488 |
3. Click "Make Predictions" to get results
|
| 489 |
4. Download results using the provided link
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 490 |
""")
|
| 491 |
|
| 492 |
-
# Updated CSS for better
|
| 493 |
demo.css = """
|
| 494 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
overflow: visible !important;
|
| 496 |
max-height: none !important;
|
|
|
|
| 497 |
}
|
| 498 |
|
| 499 |
-
|
| 500 |
width: 100% !important;
|
| 501 |
border-collapse: collapse !important;
|
| 502 |
}
|
| 503 |
|
| 504 |
-
|
| 505 |
-
background:
|
| 506 |
-
|
| 507 |
-
padding: 8px !important;
|
| 508 |
-
border: 1px solid #ddd !important;
|
| 509 |
text-align: left !important;
|
|
|
|
|
|
|
|
|
|
| 510 |
}
|
| 511 |
|
| 512 |
-
|
| 513 |
-
padding: 8px !important;
|
| 514 |
-
border: 1px solid #
|
|
|
|
| 515 |
}
|
| 516 |
|
| 517 |
-
|
| 518 |
-
background-color: #
|
| 519 |
}
|
| 520 |
|
| 521 |
-
|
| 522 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 523 |
}
|
| 524 |
-
|
| 525 |
-
/*
|
| 526 |
.validation-box {
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
border:
|
| 530 |
-
|
| 531 |
-
|
| 532 |
}
|
| 533 |
-
|
| 534 |
/* Download link styling */
|
| 535 |
.download-link {
|
| 536 |
-
margin
|
| 537 |
-
padding:
|
| 538 |
text-align: center !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 539 |
}
|
| 540 |
"""
|
| 541 |
|
|
@@ -545,6 +587,12 @@ def build_interface():
|
|
| 545 |
inputs=[input_file, confidence],
|
| 546 |
outputs=[predictions_df, download_link, validation_output]
|
| 547 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
|
| 549 |
return demo
|
| 550 |
|
|
|
|
| 413 |
with gr.Tabs():
|
| 414 |
# Predictions Tab
|
| 415 |
with gr.Tab("Make Predictions"):
|
| 416 |
+
# Create a two-column layout
|
| 417 |
with gr.Row():
|
| 418 |
+
# Left column for inputs
|
| 419 |
with gr.Column(scale=1):
|
| 420 |
input_file = gr.File(
|
| 421 |
label="Upload JSON File",
|
|
|
|
| 430 |
info="Lower values will result in more predictions, higher values in more human review cases"
|
| 431 |
)
|
| 432 |
predict_btn = gr.Button("Make Predictions", variant="primary")
|
| 433 |
+
|
| 434 |
+
# Validation output in left column
|
|
|
|
|
|
|
| 435 |
validation_output = gr.Textbox(
|
| 436 |
label="Validation Steps",
|
| 437 |
lines=3,
|
|
|
|
| 442 |
label="Download Predictions",
|
| 443 |
value=""
|
| 444 |
)
|
| 445 |
+
|
| 446 |
+
# Right column for predictions, taking more space
|
| 447 |
+
with gr.Column(scale=2):
|
| 448 |
+
predictions_df = gr.DataFrame(
|
| 449 |
+
headers=[
|
| 450 |
+
'SKU',
|
| 451 |
+
'MfrID',
|
| 452 |
+
'Predicted_Class',
|
| 453 |
+
'Confidence CLass',
|
| 454 |
+
'Confidence Score',
|
| 455 |
+
'Second_Best_Class',
|
| 456 |
+
'Second_Best_Score'
|
| 457 |
+
],
|
| 458 |
+
label="Predictions",
|
| 459 |
+
value=None,
|
| 460 |
+
wrap=True,
|
| 461 |
+
height=600,
|
| 462 |
+
interactive=False
|
| 463 |
+
)
|
| 464 |
|
| 465 |
# Diagnostics Tab
|
| 466 |
with gr.Tab("Diagnostics"):
|
|
|
|
| 471 |
)
|
| 472 |
analyze_btn = gr.Button("Run Diagnostic Analysis", variant="secondary")
|
| 473 |
|
| 474 |
+
diagnostic_output = gr.Textbox(
|
| 475 |
+
label="Diagnostic Results",
|
| 476 |
+
lines=20,
|
| 477 |
+
max_lines=30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
)
|
| 479 |
|
| 480 |
# Help Tab
|
|
|
|
| 485 |
2. Adjust the confidence threshold if needed
|
| 486 |
3. Click "Make Predictions" to get results
|
| 487 |
4. Download results using the provided link
|
| 488 |
+
|
| 489 |
+
### Understanding the Results
|
| 490 |
+
- **SKU**: Unique identifier for the item
|
| 491 |
+
- **MfrID**: Manufacturer ID
|
| 492 |
+
- **Predicted_Class**: Primary classification prediction
|
| 493 |
+
- **Review**: Final classification or "Needs Human Review"
|
| 494 |
+
- **Confidence Score**: Confidence level of primary prediction
|
| 495 |
+
- **Second_Best_Class**: Alternative classification
|
| 496 |
+
- **Second_Best_Score**: Confidence level of alternative
|
| 497 |
""")
|
| 498 |
|
| 499 |
+
# Updated CSS for better layout and readability
|
| 500 |
demo.css = """
|
| 501 |
+
/* General layout improvements */
|
| 502 |
+
.container {
|
| 503 |
+
max-width: 100% !important;
|
| 504 |
+
padding: 0 !important;
|
| 505 |
+
margin: 0 !important;
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
/* DataFrame styling */
|
| 509 |
+
.table-wrap {
|
| 510 |
overflow: visible !important;
|
| 511 |
max-height: none !important;
|
| 512 |
+
border: none !important;
|
| 513 |
}
|
| 514 |
|
| 515 |
+
table {
|
| 516 |
width: 100% !important;
|
| 517 |
border-collapse: collapse !important;
|
| 518 |
}
|
| 519 |
|
| 520 |
+
th {
|
| 521 |
+
background: #f3f4f6 !important;
|
| 522 |
+
padding: 12px 8px !important;
|
|
|
|
|
|
|
| 523 |
text-align: left !important;
|
| 524 |
+
font-weight: 600 !important;
|
| 525 |
+
color: #374151 !important;
|
| 526 |
+
border-bottom: 2px solid #d1d5db !important;
|
| 527 |
}
|
| 528 |
|
| 529 |
+
td {
|
| 530 |
+
padding: 12px 8px !important;
|
| 531 |
+
border-bottom: 1px solid #e5e7eb !important;
|
| 532 |
+
color: #4b5563 !important;
|
| 533 |
}
|
| 534 |
|
| 535 |
+
tr:nth-child(even) {
|
| 536 |
+
background-color: #f9fafb !important;
|
| 537 |
}
|
| 538 |
|
| 539 |
+
/* Button styling */
|
| 540 |
+
button.primary {
|
| 541 |
+
background-color: #2563eb !important;
|
| 542 |
+
color: white !important;
|
| 543 |
+
padding: 10px 20px !important;
|
| 544 |
+
border-radius: 6px !important;
|
| 545 |
+
font-weight: 500 !important;
|
| 546 |
}
|
| 547 |
+
|
| 548 |
+
/* Validation output styling */
|
| 549 |
.validation-box {
|
| 550 |
+
background-color: #f3f4f6 !important;
|
| 551 |
+
border: 1px solid #e5e7eb !important;
|
| 552 |
+
border-radius: 6px !important;
|
| 553 |
+
padding: 12px !important;
|
| 554 |
+
margin: 12px 0 !important;
|
| 555 |
}
|
| 556 |
+
|
| 557 |
/* Download link styling */
|
| 558 |
.download-link {
|
| 559 |
+
margin: 12px 0 !important;
|
| 560 |
+
padding: 8px !important;
|
| 561 |
text-align: center !important;
|
| 562 |
+
background-color: #f3f4f6 !important;
|
| 563 |
+
border-radius: 6px !important;
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
/* Tab styling */
|
| 567 |
+
.tab-nav {
|
| 568 |
+
border-bottom: 2px solid #e5e7eb !important;
|
| 569 |
+
padding-bottom: 0 !important;
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
.tab-nav button {
|
| 573 |
+
padding: 12px 20px !important;
|
| 574 |
+
margin-right: 4px !important;
|
| 575 |
+
border-radius: 6px 6px 0 0 !important;
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
.tab-nav button.selected {
|
| 579 |
+
background-color: #f3f4f6 !important;
|
| 580 |
+
border-bottom: 2px solid #2563eb !important;
|
| 581 |
}
|
| 582 |
"""
|
| 583 |
|
|
|
|
| 587 |
inputs=[input_file, confidence],
|
| 588 |
outputs=[predictions_df, download_link, validation_output]
|
| 589 |
)
|
| 590 |
+
|
| 591 |
+
analyze_btn.click(
|
| 592 |
+
create_diagnostic_output,
|
| 593 |
+
inputs=[diagnostic_file],
|
| 594 |
+
outputs=[diagnostic_output]
|
| 595 |
+
)
|
| 596 |
|
| 597 |
return demo
|
| 598 |
|