Spaces:
Runtime error
Runtime error
Update app.py
Browse files67 unmodified lines6869707172737437 unmodified lines11211311411411511611711811911912012112212358 unmodified lines18218318418418518618718867 unmodified lines # Remove the Base64 prefix (if exists) and decode the image image_data = re.sub('^data:image/.+;base64,', '', base64_image) image = Image.open(BytesIO(base64.b64decode(image_data))) print("Decoded image successfully.") # Debug log return image except Exception as e: print(f"Error decoding image: {e}")37 unmodified lines # Decode Base64 image image = decode_base64_image(base64_image) if image is None: return "Error decoding the image. Ensure the image is captured correctly." return {"Extracted Text": "Error decoding the image.", "Matched Product Name": "N/A", "Extracted Attributes": {}}
# Extract text using OCR extracted_text = extract_text(image) if extracted_text == "Error processing the image.": return extracted_text return {"Extracted Text": extracted_text, "Matched Product Name": "N/A", "Extracted Attributes": {}}
# Match product name product_name = match_product_name(extracted_text)58 unmodified lines gr.JSON(label="Extracted Attributes"), ], title="Camera Image Processing with OCR", description="Use the camera to capture an image, process it with OCR, and extract product attributes." description="Capture an image with the camera and extract text, attributes, and product names using OCR." ) demo.launch(share=True)
app.py+4-3