Update app.py
Browse files
app.py
CHANGED
|
@@ -25,16 +25,17 @@ import pickle
|
|
| 25 |
# Set up logging
|
| 26 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
os.
|
|
|
|
| 32 |
|
| 33 |
# Verify the current directory
|
| 34 |
logging.info(f"Current working directory: {os.getcwd()}")
|
| 35 |
|
| 36 |
# Cache file to store extracted text
|
| 37 |
-
CACHE_FILE = "
|
| 38 |
|
| 39 |
# Load cache if it exists
|
| 40 |
if os.path.exists(CACHE_FILE):
|
|
@@ -178,7 +179,7 @@ new_images = process_new_images(new_images)
|
|
| 178 |
combined_df.update(new_images)
|
| 179 |
|
| 180 |
# Save the updated dataset
|
| 181 |
-
combined_df.to_csv(
|
| 182 |
|
| 183 |
# Save the cache
|
| 184 |
with open(CACHE_FILE, "wb") as f:
|
|
|
|
| 25 |
# Set up logging
|
| 26 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 27 |
|
| 28 |
+
# Set the working directory to a writable location
|
| 29 |
+
WORKING_DIR = "/app" # Use /app or /tmp
|
| 30 |
+
if not os.path.exists(WORKING_DIR):
|
| 31 |
+
os.makedirs(WORKING_DIR)
|
| 32 |
+
os.chdir(WORKING_DIR)
|
| 33 |
|
| 34 |
# Verify the current directory
|
| 35 |
logging.info(f"Current working directory: {os.getcwd()}")
|
| 36 |
|
| 37 |
# Cache file to store extracted text
|
| 38 |
+
CACHE_FILE = os.path.join(WORKING_DIR, "image_text_cache.pkl")
|
| 39 |
|
| 40 |
# Load cache if it exists
|
| 41 |
if os.path.exists(CACHE_FILE):
|
|
|
|
| 179 |
combined_df.update(new_images)
|
| 180 |
|
| 181 |
# Save the updated dataset
|
| 182 |
+
combined_df.to_csv(os.path.join(WORKING_DIR, "data_with_extracted_text.csv"), index=False)
|
| 183 |
|
| 184 |
# Save the cache
|
| 185 |
with open(CACHE_FILE, "wb") as f:
|