Spaces:
Sleeping
Sleeping
Sean Carnahan commited on
Commit ·
2d71013
1
Parent(s): e2839df
Fix model loading: Add detailed logging and proper file handling
Browse files- Dockerfile +5 -4
- app.py +10 -0
Dockerfile
CHANGED
|
@@ -23,12 +23,13 @@ RUN mkdir -p /code/static/uploads \
|
|
| 23 |
&& chmod -R 777 /code/external \
|
| 24 |
&& chmod -R 777 /code/templates
|
| 25 |
|
| 26 |
-
# Copy the
|
| 27 |
-
COPY external/BodybuildingPoseClassifier/bodybuilding_pose_classifier.h5 /code/external/BodybuildingPoseClassifier/
|
| 28 |
-
|
| 29 |
-
# Copy the rest of the application
|
| 30 |
COPY . .
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
# Set environment variables
|
| 33 |
ENV PYTHONUNBUFFERED=1
|
| 34 |
ENV FLASK_APP=app.py
|
|
|
|
| 23 |
&& chmod -R 777 /code/external \
|
| 24 |
&& chmod -R 777 /code/templates
|
| 25 |
|
| 26 |
+
# Copy the entire application first
|
|
|
|
|
|
|
|
|
|
| 27 |
COPY . .
|
| 28 |
|
| 29 |
+
# Verify model file exists and has correct permissions
|
| 30 |
+
RUN ls -la /code/external/BodybuildingPoseClassifier/ && \
|
| 31 |
+
chmod 644 /code/external/BodybuildingPoseClassifier/bodybuilding_pose_classifier.h5
|
| 32 |
+
|
| 33 |
# Set environment variables
|
| 34 |
ENV PYTHONUNBUFFERED=1
|
| 35 |
ENV FLASK_APP=app.py
|
app.py
CHANGED
|
@@ -89,10 +89,20 @@ try:
|
|
| 89 |
cnn_model_path = os.path.join(MODEL_DIR, 'bodybuilding_pose_classifier.h5')
|
| 90 |
logger.info(f"Looking for model at: {cnn_model_path}")
|
| 91 |
|
|
|
|
|
|
|
|
|
|
| 92 |
if not os.path.exists(cnn_model_path):
|
|
|
|
|
|
|
|
|
|
| 93 |
raise FileNotFoundError(f"CNN model not found at {cnn_model_path}")
|
| 94 |
|
|
|
|
|
|
|
|
|
|
| 95 |
# Load model with custom_objects to handle any custom layers
|
|
|
|
| 96 |
cnn_model = load_model(cnn_model_path, compile=False)
|
| 97 |
logger.info("CNN model loaded successfully")
|
| 98 |
except Exception as e:
|
|
|
|
| 89 |
cnn_model_path = os.path.join(MODEL_DIR, 'bodybuilding_pose_classifier.h5')
|
| 90 |
logger.info(f"Looking for model at: {cnn_model_path}")
|
| 91 |
|
| 92 |
+
# List directory contents to debug
|
| 93 |
+
logger.info(f"Contents of MODEL_DIR: {os.listdir(MODEL_DIR)}")
|
| 94 |
+
|
| 95 |
if not os.path.exists(cnn_model_path):
|
| 96 |
+
logger.error(f"Model file not found at {cnn_model_path}")
|
| 97 |
+
logger.error(f"Current working directory: {os.getcwd()}")
|
| 98 |
+
logger.error(f"Directory contents: {os.listdir('.')}")
|
| 99 |
raise FileNotFoundError(f"CNN model not found at {cnn_model_path}")
|
| 100 |
|
| 101 |
+
# Check file permissions
|
| 102 |
+
logger.info(f"Model file permissions: {oct(os.stat(cnn_model_path).st_mode)[-3:]}")
|
| 103 |
+
|
| 104 |
# Load model with custom_objects to handle any custom layers
|
| 105 |
+
logger.info("Attempting to load model...")
|
| 106 |
cnn_model = load_model(cnn_model_path, compile=False)
|
| 107 |
logger.info("CNN model loaded successfully")
|
| 108 |
except Exception as e:
|