Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,18 +6,21 @@ from PIL import Image
|
|
| 6 |
import zipfile
|
| 7 |
import gdown
|
| 8 |
|
| 9 |
-
# Path to your zipped model file
|
| 10 |
-
|
| 11 |
-
UNZIPPED_MODEL_PATH = '/app/
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
zip_ref.extractall('/app')
|
| 22 |
print(f"Model unzipped to {UNZIPPED_MODEL_PATH}")
|
| 23 |
|
|
|
|
| 6 |
import zipfile
|
| 7 |
import gdown
|
| 8 |
|
| 9 |
+
# Path to your zipped model file (this will be the local path after downloading)
|
| 10 |
+
ZIP_MODEL_PATH = '/app/your_trained_model_resnet50.keras.zip'
|
| 11 |
+
UNZIPPED_MODEL_PATH = '/app/your_trained_model_resnet50.keras' # Path where the model will be extracted
|
| 12 |
|
| 13 |
+
# Google Drive link to the model file
|
| 14 |
+
MODEL_URL = 'https://drive.google.com/uc?export=download&id=1-4p6AZBkooWL1rhN9WwIrfd9fJbhzY0e'
|
| 15 |
+
|
| 16 |
+
# Download the model if it doesn't exist
|
| 17 |
+
if not os.path.exists(ZIP_MODEL_PATH):
|
| 18 |
+
gdown.download(MODEL_URL, ZIP_MODEL_PATH, quiet=False)
|
| 19 |
+
print(f"Model downloaded to {ZIP_MODEL_PATH}")
|
| 20 |
|
| 21 |
+
# Unzip the model if it hasn't been unzipped already
|
| 22 |
+
if not os.path.exists(UNZIPPED_MODEL_PATH):
|
| 23 |
+
with zipfile.ZipFile(ZIP_MODEL_PATH, 'r') as zip_ref:
|
| 24 |
zip_ref.extractall('/app')
|
| 25 |
print(f"Model unzipped to {UNZIPPED_MODEL_PATH}")
|
| 26 |
|