Update app.py
Browse files
app.py
CHANGED
|
@@ -196,6 +196,83 @@ input, textarea, select {
|
|
| 196 |
}
|
| 197 |
|
| 198 |
/* Upload/Webcam tab buttons - make them visible and styled */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
[data-testid="image"] [role="tablist"],
|
| 200 |
.image-container [role="tablist"],
|
| 201 |
button[role="tab"] {
|
|
@@ -691,16 +768,21 @@ def extract_text_from_receipt(file_path):
|
|
| 691 |
return None, []
|
| 692 |
|
| 693 |
try:
|
|
|
|
|
|
|
|
|
|
| 694 |
text = ""
|
| 695 |
|
| 696 |
if file_path.name.lower().endswith('.pdf'):
|
| 697 |
-
#
|
| 698 |
-
# Try with explicit poppler path first, fall back to default
|
| 699 |
try:
|
| 700 |
images = convert_from_path(file_path.name, poppler_path='/usr/bin')
|
| 701 |
-
except:
|
| 702 |
-
#
|
| 703 |
-
|
|
|
|
|
|
|
|
|
|
| 704 |
|
| 705 |
for img in images:
|
| 706 |
text += pytesseract.image_to_string(img) + "\n"
|
|
|
|
| 196 |
}
|
| 197 |
|
| 198 |
/* Upload/Webcam tab buttons - make them visible and styled */
|
| 199 |
+
/* Use more aggressive selectors for Gradio 5.50 */
|
| 200 |
+
.tabs button,
|
| 201 |
+
.tab-nav button,
|
| 202 |
+
button[id*="component"],
|
| 203 |
+
button[id*="upload"],
|
| 204 |
+
button[id*="webcam"] {
|
| 205 |
+
background: white !important;
|
| 206 |
+
border: 2px solid #cbd5e0 !important;
|
| 207 |
+
border-radius: 10px !important;
|
| 208 |
+
padding: 14px 28px !important;
|
| 209 |
+
font-size: 1em !important;
|
| 210 |
+
font-weight: 600 !important;
|
| 211 |
+
color: #2d3748 !important;
|
| 212 |
+
transition: all 0.3s ease !important;
|
| 213 |
+
min-width: 130px !important;
|
| 214 |
+
margin: 4px !important;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
.tabs button:hover,
|
| 218 |
+
.tab-nav button:hover {
|
| 219 |
+
background: #667eea !important;
|
| 220 |
+
border-color: #667eea !important;
|
| 221 |
+
color: white !important;
|
| 222 |
+
transform: translateY(-2px) !important;
|
| 223 |
+
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
.tabs button.selected,
|
| 227 |
+
.tab-nav button.selected,
|
| 228 |
+
button[aria-selected="true"] {
|
| 229 |
+
background: #667eea !important;
|
| 230 |
+
border-color: #667eea !important;
|
| 231 |
+
color: white !important;
|
| 232 |
+
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4) !important;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
/* Force ALL SVG icons to be visible with color */
|
| 236 |
+
.tabs button svg,
|
| 237 |
+
.tab-nav button svg,
|
| 238 |
+
button[id*="component"] svg,
|
| 239 |
+
button svg {
|
| 240 |
+
width: 20px !important;
|
| 241 |
+
height: 20px !important;
|
| 242 |
+
fill: currentColor !important;
|
| 243 |
+
stroke: currentColor !important;
|
| 244 |
+
opacity: 1 !important;
|
| 245 |
+
visibility: visible !important;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
.tabs button svg *,
|
| 249 |
+
.tab-nav button svg *,
|
| 250 |
+
button svg * {
|
| 251 |
+
fill: currentColor !important;
|
| 252 |
+
stroke: currentColor !important;
|
| 253 |
+
opacity: 1 !important;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
/* Specific for image component tabs */
|
| 257 |
+
div[id*="image"] button,
|
| 258 |
+
.image-container button {
|
| 259 |
+
background: white !important;
|
| 260 |
+
color: #2d3748 !important;
|
| 261 |
+
border: 2px solid #cbd5e0 !important;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
div[id*="image"] button:hover,
|
| 265 |
+
.image-container button:hover {
|
| 266 |
+
background: #667eea !important;
|
| 267 |
+
color: white !important;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
div[id*="image"] button svg,
|
| 271 |
+
.image-container button svg {
|
| 272 |
+
fill: currentColor !important;
|
| 273 |
+
stroke: currentColor !important;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
[data-testid="image"] [role="tablist"],
|
| 277 |
.image-container [role="tablist"],
|
| 278 |
button[role="tab"] {
|
|
|
|
| 768 |
return None, []
|
| 769 |
|
| 770 |
try:
|
| 771 |
+
# Set tesseract path for Hugging Face Spaces
|
| 772 |
+
pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract'
|
| 773 |
+
|
| 774 |
text = ""
|
| 775 |
|
| 776 |
if file_path.name.lower().endswith('.pdf'):
|
| 777 |
+
# Set poppler path for Hugging Face Spaces
|
|
|
|
| 778 |
try:
|
| 779 |
images = convert_from_path(file_path.name, poppler_path='/usr/bin')
|
| 780 |
+
except Exception as e:
|
| 781 |
+
# If poppler fails, try without path specification
|
| 782 |
+
try:
|
| 783 |
+
images = convert_from_path(file_path.name)
|
| 784 |
+
except Exception as e2:
|
| 785 |
+
return [[True, f"PDF Error: {str(e2)}", "", ""]], []
|
| 786 |
|
| 787 |
for img in images:
|
| 788 |
text += pytesseract.image_to_string(img) + "\n"
|