Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,14 @@ import mimetypes
|
|
| 10 |
# Configure logging
|
| 11 |
logging.basicConfig(level=logging.INFO)
|
| 12 |
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# OCR Extraction Function
|
| 14 |
def extract_ocr(file):
|
| 15 |
try:
|
|
@@ -61,8 +69,9 @@ def score_vendor(vendor_id, timeliness, issue_count, feedback_rating):
|
|
| 61 |
|
| 62 |
# Gradio Main Interface
|
| 63 |
def gradio_interface(vendor_id, timeliness, issue_count, feedback_rating, evaluation_date, file):
|
| 64 |
-
|
| 65 |
-
|
|
|
|
| 66 |
if not file:
|
| 67 |
return "Error: Please upload a QA certificate image."
|
| 68 |
|
|
|
|
| 10 |
# Configure logging
|
| 11 |
logging.basicConfig(level=logging.INFO)
|
| 12 |
logger = logging.getLogger(__name__)
|
| 13 |
+
|
| 14 |
+
# Load environment variables
|
| 15 |
+
load_dotenv()
|
| 16 |
+
ocr_api_url = os.getenv("OCR_API_URL", "https://huggingface.co/spaces/your_username/your_space_name")
|
| 17 |
+
|
| 18 |
+
# Debug: Log whether environment variables are loaded
|
| 19 |
+
logger.info(f"OCR_API_URL: {ocr_api_url}")
|
| 20 |
+
|
| 21 |
# OCR Extraction Function
|
| 22 |
def extract_ocr(file):
|
| 23 |
try:
|
|
|
|
| 69 |
|
| 70 |
# Gradio Main Interface
|
| 71 |
def gradio_interface(vendor_id, timeliness, issue_count, feedback_rating, evaluation_date, file):
|
| 72 |
+
# Update to handle both "Vendor1006" and just "1006"
|
| 73 |
+
if not vendor_id.isdigit():
|
| 74 |
+
return "Error: Invalid Vendor ID. Please enter only numeric values."
|
| 75 |
if not file:
|
| 76 |
return "Error: Please upload a QA certificate image."
|
| 77 |
|