fix: python download script
Browse files- Dockerfile +30 -29
Dockerfile
CHANGED
|
@@ -17,35 +17,36 @@ RUN pip install huggingface_hub
|
|
| 17 |
# Create models directory
|
| 18 |
RUN mkdir -p /models
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
RUN
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
hf_hub_download(
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
| 49 |
|
| 50 |
# Stage 2: Build the application
|
| 51 |
FROM python:3.10-slim
|
|
|
|
| 17 |
# Create models directory
|
| 18 |
RUN mkdir -p /models
|
| 19 |
|
| 20 |
+
# Create download script
|
| 21 |
+
RUN echo 'from huggingface_hub import hf_hub_download\n\
|
| 22 |
+
import os\n\
|
| 23 |
+
\n\
|
| 24 |
+
# Download model files\n\
|
| 25 |
+
print("Downloading model files...")\n\
|
| 26 |
+
hf_hub_download("seamo-ai/marina-species-v1", "marina-benthic-33k.pt", local_dir="/models", local_dir_use_symlinks=False)\n\
|
| 27 |
+
hf_hub_download("seamo-ai/marina-species-v1", "marina-benthic-33k.names", local_dir="/models", local_dir_use_symlinks=False)\n\
|
| 28 |
+
\n\
|
| 29 |
+
# Download sample images\n\
|
| 30 |
+
print("Downloading sample images...")\n\
|
| 31 |
+
sample_images = [\n\
|
| 32 |
+
"crab.png", "fish.png", "fish_2.png", "fish_3.png", "fish_4.png", "fish_5.png",\n\
|
| 33 |
+
"flat_fish.png", "flat_red_fish.png", "jelly.png", "jelly_2.png", "jelly_3.png",\n\
|
| 34 |
+
"puff.png", "red_fish.png", "red_fish_2.png", "scene.png", "scene_2.png",\n\
|
| 35 |
+
"scene_3.png", "scene_4.png", "scene_5.png", "scene_6.png", "soft_coral.png",\n\
|
| 36 |
+
"starfish.png", "starfish_2.png"\n\
|
| 37 |
+
]\n\
|
| 38 |
+
\n\
|
| 39 |
+
for img in sample_images:\n\
|
| 40 |
+
try:\n\
|
| 41 |
+
hf_hub_download("seamo-ai/marina-species-v1", f"images/{img}", local_dir="/models", local_dir_use_symlinks=False)\n\
|
| 42 |
+
print(f"Downloaded {img}")\n\
|
| 43 |
+
except Exception as e:\n\
|
| 44 |
+
print(f"Failed to download {img}: {e}")\n\
|
| 45 |
+
\n\
|
| 46 |
+
print("Download complete!")' > /tmp/download_models.py
|
| 47 |
+
|
| 48 |
+
# Run the download script
|
| 49 |
+
RUN python3 /tmp/download_models.py
|
| 50 |
|
| 51 |
# Stage 2: Build the application
|
| 52 |
FROM python:3.10-slim
|