kamau1 commited on
Commit
adf4a4e
·
verified ·
1 Parent(s): 2dab624

Downloads sample images

Browse files
Dockerfile CHANGED
@@ -17,11 +17,13 @@ RUN pip install huggingface_hub
17
  # Create models directory
18
  RUN mkdir -p /models
19
 
20
- # Download models from seamo-ai/marina-species-v1
21
  RUN python -c "\
22
  from huggingface_hub import hf_hub_download; \
23
  hf_hub_download('seamo-ai/marina-species-v1', 'marina-benthic-33k.pt', local_dir='/models', local_dir_use_symlinks=False); \
24
- hf_hub_download('seamo-ai/marina-species-v1', 'marina-benthic-33k.names', local_dir='/models', local_dir_use_symlinks=False)"
 
 
25
 
26
  # Stage 2: Build the application
27
  FROM python:3.10-slim
@@ -71,6 +73,11 @@ COPY --chown=user ./app app
71
  COPY --chown=user ./templates templates
72
  COPY --chown=user ./static static
73
 
 
 
 
 
 
74
  # Create necessary directories
75
  RUN mkdir -p $HOME/.cache/huggingface $HOME/.cache/torch
76
 
 
17
  # Create models directory
18
  RUN mkdir -p /models
19
 
20
+ # Download models and sample images from seamo-ai/marina-species-v1
21
  RUN python -c "\
22
  from huggingface_hub import hf_hub_download; \
23
  hf_hub_download('seamo-ai/marina-species-v1', 'marina-benthic-33k.pt', local_dir='/models', local_dir_use_symlinks=False); \
24
+ hf_hub_download('seamo-ai/marina-species-v1', 'marina-benthic-33k.names', local_dir='/models', local_dir_use_symlinks=False); \
25
+ hf_hub_download('seamo-ai/marina-species-v1', 'images/red_fish.png', local_dir='/models', local_dir_use_symlinks=False); \
26
+ hf_hub_download('seamo-ai/marina-species-v1', 'images/red_fish_2.png', local_dir='/models', local_dir_use_symlinks=False)"
27
 
28
  # Stage 2: Build the application
29
  FROM python:3.10-slim
 
73
  COPY --chown=user ./templates templates
74
  COPY --chown=user ./static static
75
 
76
+ # Copy sample images from models to static directory for web access
77
+ RUN mkdir -p static/images/samples
78
+ RUN cp $HOME/app/models/images/red_fish.png static/images/samples/
79
+ RUN cp $HOME/app/models/images/red_fish_2.png static/images/samples/
80
+
81
  # Create necessary directories
82
  RUN mkdir -p $HOME/.cache/huggingface $HOME/.cache/torch
83
 
static/css/dashboard-simple.css CHANGED
@@ -6,23 +6,7 @@
6
  padding: 20px;
7
  }
8
 
9
- .page-header {
10
- text-align: center;
11
- margin-bottom: 40px;
12
- }
13
 
14
- .page-header h1 {
15
- font-size: 2rem;
16
- margin-bottom: 10px;
17
- color: #111827;
18
- }
19
-
20
- .page-description {
21
- font-size: 1.125rem;
22
- color: #6b7280;
23
- max-width: 600px;
24
- margin: 0 auto;
25
- }
26
 
27
  /* Status Banner */
28
  .status-banner {
 
6
  padding: 20px;
7
  }
8
 
 
 
 
 
9
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  /* Status Banner */
12
  .status-banner {
static/js/dashboard.js CHANGED
@@ -248,12 +248,12 @@ class MarineDashboard {
248
  const sampleImages = [
249
  {
250
  name: 'red_fish.png',
251
- url: 'https://huggingface.co/seamo-ai/marina-species-v1/resolve/main/red_fish.png',
252
  description: 'Marine Fish Sample'
253
  },
254
  {
255
  name: 'red_fish_2.png',
256
- url: 'https://huggingface.co/seamo-ai/marina-species-v1/resolve/main/red_fish_2.png',
257
  description: 'Deep Sea Sample'
258
  }
259
  ];
@@ -272,8 +272,24 @@ class MarineDashboard {
272
  // Show loading state
273
  window.MarineAPI.utils.showNotification('Loading sample image...', 'info');
274
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  // Fetch the image
276
- const response = await fetch(imageUrl);
 
 
 
 
277
  const blob = await response.blob();
278
 
279
  // Convert to File object
@@ -285,7 +301,7 @@ class MarineDashboard {
285
  window.MarineAPI.utils.showNotification('Sample image loaded successfully!', 'success');
286
  } catch (error) {
287
  console.error('Failed to load sample image:', error);
288
- window.MarineAPI.utils.showNotification('Failed to load sample image', 'error');
289
  }
290
  }
291
  }
 
248
  const sampleImages = [
249
  {
250
  name: 'red_fish.png',
251
+ url: 'https://huggingface.co/seamo-ai/marina-species-v1/resolve/main/images/red_fish.png',
252
  description: 'Marine Fish Sample'
253
  },
254
  {
255
  name: 'red_fish_2.png',
256
+ url: 'https://huggingface.co/seamo-ai/marina-species-v1/resolve/main/images/red_fish_2.png',
257
  description: 'Deep Sea Sample'
258
  }
259
  ];
 
272
  // Show loading state
273
  window.MarineAPI.utils.showNotification('Loading sample image...', 'info');
274
 
275
+ let finalUrl = imageUrl;
276
+
277
+ // Try local URL first, fallback to HuggingFace if needed
278
+ try {
279
+ const testResponse = await fetch(imageUrl, { method: 'HEAD' });
280
+ if (!testResponse.ok) {
281
+ finalUrl = `https://huggingface.co/seamo-ai/marina-species-v1/resolve/main/images/${imageName}`;
282
+ }
283
+ } catch (e) {
284
+ finalUrl = `https://huggingface.co/seamo-ai/marina-species-v1/resolve/main/images/${imageName}`;
285
+ }
286
+
287
  // Fetch the image
288
+ const response = await fetch(finalUrl);
289
+ if (!response.ok) {
290
+ throw new Error(`Failed to fetch image: ${response.status}`);
291
+ }
292
+
293
  const blob = await response.blob();
294
 
295
  // Convert to File object
 
301
  window.MarineAPI.utils.showNotification('Sample image loaded successfully!', 'success');
302
  } catch (error) {
303
  console.error('Failed to load sample image:', error);
304
+ window.MarineAPI.utils.showNotification('Failed to load sample image. Please try uploading your own image.', 'error');
305
  }
306
  }
307
  }
templates/dashboard.html CHANGED
@@ -9,10 +9,7 @@
9
 
10
  {% block content %}
11
  <div class="dashboard">
12
- <!-- Page Header -->
13
- <div class="page-header">
14
- <h1>Species Identification</h1>
15
- </div>
16
 
17
  <!-- API Status Banner -->
18
  <div class="status-banner" id="statusBanner">
 
9
 
10
  {% block content %}
11
  <div class="dashboard">
12
+
 
 
 
13
 
14
  <!-- API Status Banner -->
15
  <div class="status-banner" id="statusBanner">