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