rongo1
commited on
Commit
Β·
46dec01
1
Parent(s):
6ba44e8
fix
Browse files
app.py
CHANGED
@@ -51,8 +51,20 @@ else:
|
|
51 |
|
52 |
# Create output directories
|
53 |
logger.info("Setting up output directories")
|
54 |
-
#
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
output_dir = BASE_PATH / "business_card_exports"
|
57 |
images_dir = BASE_PATH / "business_cards"
|
58 |
output_dir.mkdir(parents=True, exist_ok=True)
|
@@ -700,20 +712,20 @@ with gr.Blocks(title="Business Card Data Extractor") as demo:
|
|
700 |
- π **Current Run**: Contains only the cards you just processed
|
701 |
- π **Total Database**: Contains ALL cards ever processed (cumulative)
|
702 |
|
703 |
-
|
704 |
-
-
|
705 |
-
-
|
706 |
-
-
|
707 |
-
-
|
708 |
|
709 |
**π File Access:**
|
710 |
-
- Download directly from interface
|
711 |
-
-
|
712 |
-
-
|
|
|
713 |
|
714 |
**βοΈ Optional Hub Integration:**
|
715 |
-
- Set `HF_TOKEN` in Space secrets to
|
716 |
-
- Files will be uploaded to `polygraf-ai/business_card_extractor`
|
717 |
"""
|
718 |
)
|
719 |
|
@@ -772,7 +784,7 @@ with gr.Blocks(title="Business Card Data Extractor") as demo:
|
|
772 |
- π **Data Extraction**: Names, emails, phone numbers, addresses, and more
|
773 |
- π **Smart Combination**: Multiple emails/phones combined with commas
|
774 |
- π **Address Merging**: All phone types and address fields combined
|
775 |
-
- πΎ **
|
776 |
- π **Hub Integration**: Auto-upload to repository (optional)
|
777 |
- π **Dual Output**: Current run + cumulative database files
|
778 |
- π **Full Tracking**: Processing date, filename, image path, and AI model used
|
|
|
51 |
|
52 |
# Create output directories
|
53 |
logger.info("Setting up output directories")
|
54 |
+
# Try /data for persistent storage, fallback to current directory
|
55 |
+
try:
|
56 |
+
# Check if /data is available (persistent storage enabled)
|
57 |
+
data_path = Path("/data")
|
58 |
+
if data_path.exists() and os.access(data_path, os.W_OK):
|
59 |
+
BASE_PATH = data_path
|
60 |
+
logger.info("Using /data directory for persistent storage")
|
61 |
+
else:
|
62 |
+
raise PermissionError("No access to /data")
|
63 |
+
except (PermissionError, OSError):
|
64 |
+
# Fallback to current directory for free tier
|
65 |
+
BASE_PATH = Path(".")
|
66 |
+
logger.info("Using current directory (files will be ephemeral without persistent storage)")
|
67 |
+
|
68 |
output_dir = BASE_PATH / "business_card_exports"
|
69 |
images_dir = BASE_PATH / "business_cards"
|
70 |
output_dir.mkdir(parents=True, exist_ok=True)
|
|
|
712 |
- π **Current Run**: Contains only the cards you just processed
|
713 |
- π **Total Database**: Contains ALL cards ever processed (cumulative)
|
714 |
|
715 |
+
**πΎ File Storage:**
|
716 |
+
- π Excel files: `business_card_exports/` folder
|
717 |
+
- πΌοΈ Images: `business_cards/` folder (if save option enabled)
|
718 |
+
- π **Persistent storage**: Enable in Space settings for files to survive restarts
|
719 |
+
- π **Hub uploads**: Files auto-uploaded to repository (if `HF_TOKEN` configured)
|
720 |
|
721 |
**π File Access:**
|
722 |
+
- β¬οΈ Download directly from interface buttons
|
723 |
+
- π Check Space's Files tab (if persistent storage enabled)
|
724 |
+
- π Hub repository: `exports/` and `images/` folders (if token set)
|
725 |
+
- π `FOLDER_CONTENTS.txt` shows complete file listing
|
726 |
|
727 |
**βοΈ Optional Hub Integration:**
|
728 |
+
- Set `HF_TOKEN` in Space secrets to upload files to `polygraf-ai/business_card_extractor`
|
|
|
729 |
"""
|
730 |
)
|
731 |
|
|
|
784 |
- π **Data Extraction**: Names, emails, phone numbers, addresses, and more
|
785 |
- π **Smart Combination**: Multiple emails/phones combined with commas
|
786 |
- π **Address Merging**: All phone types and address fields combined
|
787 |
+
- πΎ **Smart Storage**: Auto-detects persistent storage, falls back gracefully
|
788 |
- π **Hub Integration**: Auto-upload to repository (optional)
|
789 |
- π **Dual Output**: Current run + cumulative database files
|
790 |
- π **Full Tracking**: Processing date, filename, image path, and AI model used
|