Spaces:
Sleeping
Sleeping
Commit
·
b906063
1
Parent(s):
2e35676
Update
Browse files
backend/model_histo.py
CHANGED
|
@@ -401,37 +401,35 @@ class BreastCancerClassifier:
|
|
| 401 |
batch = images[i:i + batch_size]
|
| 402 |
processed_batch = self.preprocess_image_batch(batch)
|
| 403 |
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
else:
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
batch_embeddings = batch_embeddings[key].numpy()
|
| 422 |
-
else:
|
| 423 |
-
batch_embeddings = batch_embeddings[key]
|
| 424 |
-
elif hasattr(batch_embeddings, 'numpy'):
|
| 425 |
-
batch_embeddings = batch_embeddings.numpy()
|
| 426 |
-
|
| 427 |
-
embeddings.append(batch_embeddings)
|
| 428 |
-
|
| 429 |
-
# Progress reporting
|
| 430 |
-
batch_num = i // batch_size + 1
|
| 431 |
-
if batch_num % 10 == 0:
|
| 432 |
-
print(f"Processed batch {batch_num}/{num_batches}")
|
| 433 |
-
|
| 434 |
-
except Exception as e:
|
| 435 |
print(f"Error processing batch {batch_num}: {e}")
|
| 436 |
continue
|
| 437 |
|
|
|
|
| 401 |
batch = images[i:i + batch_size]
|
| 402 |
processed_batch = self.preprocess_image_batch(batch)
|
| 403 |
|
| 404 |
+
# Calculate batch number before try block to ensure it's available in except block
|
| 405 |
+
batch_num = i // batch_size + 1
|
| 406 |
+
|
| 407 |
+
try:
|
| 408 |
+
# Handle different model interface types
|
| 409 |
+
if hasattr(self.path_foundation, 'signatures') and "serving_default" in self.path_foundation.signatures:
|
| 410 |
+
# TensorFlow SavedModel format
|
| 411 |
+
infer = self.path_foundation.signatures["serving_default"]
|
| 412 |
+
batch_embeddings = infer(tf.constant(processed_batch))
|
| 413 |
+
elif hasattr(self.path_foundation, 'predict'):
|
| 414 |
+
# Standard Keras model
|
| 415 |
+
batch_embeddings = self.path_foundation.predict(processed_batch, verbose=0)
|
| 416 |
+
else:
|
| 417 |
+
# Direct callable
|
| 418 |
+
batch_embeddings = self.path_foundation(processed_batch)
|
| 419 |
+
|
| 420 |
+
# Handle different output formats
|
| 421 |
+
if isinstance(batch_embeddings, dict):
|
| 422 |
+
key = list(batch_embeddings.keys())[0]
|
| 423 |
+
if hasattr(batch_embeddings[key], 'numpy'):
|
| 424 |
+
batch_embeddings = batch_embeddings[key].numpy()
|
| 425 |
else:
|
| 426 |
+
batch_embeddings = batch_embeddings[key]
|
| 427 |
+
elif hasattr(batch_embeddings, 'numpy'):
|
| 428 |
+
batch_embeddings = batch_embeddings.numpy()
|
| 429 |
+
|
| 430 |
+
embeddings.append(batch_embeddings)
|
| 431 |
+
|
| 432 |
+
# Progress reporting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 433 |
print(f"Error processing batch {batch_num}: {e}")
|
| 434 |
continue
|
| 435 |
|
frontend/src/components/UploadSection.tsx
CHANGED
|
@@ -59,8 +59,8 @@ export function UploadSection({
|
|
| 59 |
"/histo/hist1.png",
|
| 60 |
"/histo/hist2.png",
|
| 61 |
"/histo/hist3.jpg",
|
| 62 |
-
"/histo/hist4.
|
| 63 |
-
"/histo/hist5.
|
| 64 |
],
|
| 65 |
};
|
| 66 |
|
|
|
|
| 59 |
"/histo/hist1.png",
|
| 60 |
"/histo/hist2.png",
|
| 61 |
"/histo/hist3.jpg",
|
| 62 |
+
"/histo/hist4.tif",
|
| 63 |
+
"/histo/hist5.tif",
|
| 64 |
],
|
| 65 |
};
|
| 66 |
|