Spaces:
Sleeping
Sleeping
Commit ·
2a26f8e
1
Parent(s): 7be7a2c
Fix Hugging Face deployment and improve radio UI
Browse files- app.py +93 -5
- utils/deployer.py +5 -1
app.py
CHANGED
|
@@ -640,9 +640,51 @@ def create_app():
|
|
| 640 |
|
| 641 |
/* Radio Group */
|
| 642 |
.radio-group {
|
| 643 |
-
display: flex;
|
| 644 |
-
|
| 645 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
}
|
| 647 |
|
| 648 |
.radio-item {
|
|
@@ -699,11 +741,57 @@ def create_app():
|
|
| 699 |
}
|
| 700 |
|
| 701 |
.radio-group {
|
| 702 |
-
flex-direction: column;
|
| 703 |
-
gap: 1rem;
|
| 704 |
}
|
| 705 |
}
|
| 706 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 707 |
/* Animation for active step */
|
| 708 |
@keyframes pulse {
|
| 709 |
0% { transform: scale(1); }
|
|
|
|
| 640 |
|
| 641 |
/* Radio Group */
|
| 642 |
.radio-group {
|
| 643 |
+
display: flex !important;
|
| 644 |
+
flex-direction: column !important;
|
| 645 |
+
gap: 1rem !important;
|
| 646 |
+
margin: 1.5rem 0 !important;
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
.radio-group label {
|
| 650 |
+
display: flex !important;
|
| 651 |
+
align-items: center !important;
|
| 652 |
+
gap: 0.75rem !important;
|
| 653 |
+
padding: 1rem 1.25rem !important;
|
| 654 |
+
background: white !important;
|
| 655 |
+
border: 2px solid #e5e7eb !important;
|
| 656 |
+
border-radius: 8px !important;
|
| 657 |
+
cursor: pointer !important;
|
| 658 |
+
transition: all 0.3s ease !important;
|
| 659 |
+
font-weight: 500 !important;
|
| 660 |
+
color: #374151 !important;
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
.radio-group label:hover {
|
| 664 |
+
border-color: #fbbf24 !important;
|
| 665 |
+
background: #fffbeb !important;
|
| 666 |
+
transform: translateX(4px) !important;
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
.radio-group input[type="radio"] {
|
| 670 |
+
width: 18px !important;
|
| 671 |
+
height: 18px !important;
|
| 672 |
+
cursor: pointer !important;
|
| 673 |
+
accent-color: #fbbf24 !important;
|
| 674 |
+
flex-shrink: 0 !important;
|
| 675 |
+
}
|
| 676 |
+
|
| 677 |
+
.radio-group input[type="radio"]:checked + * {
|
| 678 |
+
color: #1f2937 !important;
|
| 679 |
+
font-weight: 600 !important;
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
+
.radio-group label.selected {
|
| 683 |
+
background: linear-gradient(135deg, #fef3c7 0%, #fffbeb 100%) !important;
|
| 684 |
+
border-color: #fbbf24 !important;
|
| 685 |
+
box-shadow: 0 2px 8px rgba(251, 191, 36, 0.2) !important;
|
| 686 |
+
color: #1f2937 !important;
|
| 687 |
+
font-weight: 600 !important;
|
| 688 |
}
|
| 689 |
|
| 690 |
.radio-item {
|
|
|
|
| 741 |
}
|
| 742 |
|
| 743 |
.radio-group {
|
| 744 |
+
flex-direction: column !important;
|
| 745 |
+
gap: 1rem !important;
|
| 746 |
}
|
| 747 |
}
|
| 748 |
|
| 749 |
+
/* Gradio Radio Component Styling */
|
| 750 |
+
.gradio-radio {
|
| 751 |
+
gap: 0 !important;
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
.gradio-radio > label {
|
| 755 |
+
display: flex !important;
|
| 756 |
+
align-items: center !important;
|
| 757 |
+
padding: 1rem 1.25rem !important;
|
| 758 |
+
background: white !important;
|
| 759 |
+
border: 2px solid #e5e7eb !important;
|
| 760 |
+
border-radius: 8px !important;
|
| 761 |
+
margin-bottom: 0.75rem !important;
|
| 762 |
+
cursor: pointer !important;
|
| 763 |
+
transition: all 0.3s ease !important;
|
| 764 |
+
font-weight: 500 !important;
|
| 765 |
+
color: #374151 !important;
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
.gradio-radio > label:hover {
|
| 769 |
+
border-color: #fbbf24 !important;
|
| 770 |
+
background: #fffbeb !important;
|
| 771 |
+
transform: translateX(4px) !important;
|
| 772 |
+
}
|
| 773 |
+
|
| 774 |
+
.gradio-radio > label input[type="radio"] {
|
| 775 |
+
width: 18px !important;
|
| 776 |
+
height: 18px !important;
|
| 777 |
+
margin-right: 0.75rem !important;
|
| 778 |
+
cursor: pointer !important;
|
| 779 |
+
accent-color: #fbbf24 !important;
|
| 780 |
+
}
|
| 781 |
+
|
| 782 |
+
.gradio-radio > label input[type="radio"]:checked {
|
| 783 |
+
accent-color: #fbbf24 !important;
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
.gradio-radio > label:has(input[type="radio"]:checked) {
|
| 787 |
+
background: linear-gradient(135deg, #fef3c7 0%, #fffbeb 100%) !important;
|
| 788 |
+
border-color: #fbbf24 !important;
|
| 789 |
+
box-shadow: 0 2px 8px rgba(251, 191, 36, 0.2) !important;
|
| 790 |
+
color: #1f2937 !important;
|
| 791 |
+
font-weight: 600 !important;
|
| 792 |
+
}
|
| 793 |
+
|
| 794 |
+
|
| 795 |
/* Animation for active step */
|
| 796 |
@keyframes pulse {
|
| 797 |
0% { transform: scale(1); }
|
utils/deployer.py
CHANGED
|
@@ -3,6 +3,7 @@ Deployment logic for Hugging Face Spaces
|
|
| 3 |
"""
|
| 4 |
|
| 5 |
import re
|
|
|
|
| 6 |
from typing import Dict, Optional
|
| 7 |
from huggingface_hub import HfApi
|
| 8 |
|
|
@@ -68,8 +69,11 @@ def deploy_to_space(
|
|
| 68 |
if '```' in content:
|
| 69 |
content = content.replace('```', '')
|
| 70 |
|
|
|
|
|
|
|
|
|
|
| 71 |
api.upload_file(
|
| 72 |
-
path_or_fileobj=
|
| 73 |
path_in_repo=filename,
|
| 74 |
repo_id=repo_id,
|
| 75 |
repo_type="space",
|
|
|
|
| 3 |
"""
|
| 4 |
|
| 5 |
import re
|
| 6 |
+
from io import BytesIO
|
| 7 |
from typing import Dict, Optional
|
| 8 |
from huggingface_hub import HfApi
|
| 9 |
|
|
|
|
| 69 |
if '```' in content:
|
| 70 |
content = content.replace('```', '')
|
| 71 |
|
| 72 |
+
# Convert string content to BytesIO object
|
| 73 |
+
file_bytes = BytesIO(content.encode('utf-8'))
|
| 74 |
+
|
| 75 |
api.upload_file(
|
| 76 |
+
path_or_fileobj=file_bytes,
|
| 77 |
path_in_repo=filename,
|
| 78 |
repo_id=repo_id,
|
| 79 |
repo_type="space",
|