Spaces:
Sleeping
Sleeping
Commit ·
b906063
1
Parent(s): 2e35676
Update
Browse filesFiles changed (2)
400 unmodified lines401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437400 unmodified linesbatch = images[i:i + batch_size]processed_batch = self.preprocess_image_batch(batch)try:# Handle different model interface typesif hasattr(self.path_foundation, 'signatures') and "serving_default" in self.path_foundation.signatures:# TensorFlow SavedModel formatinfer = self.path_foundation.signatures["serving_default"]batch_embeddings = infer(tf.constant(processed_batch))elif hasattr(self.path_foundation, 'predict'):# Standard Keras modelbatch_embeddings = self.path_foundation.predict(processed_batch, verbose=0)else:# Direct callablebatch_embeddings = self.path_foundation(processed_batch)# Handle different output formatsif isinstance(batch_embeddings, dict):key = list(batch_embeddings.keys())[0]if hasattr(batch_embeddings[key], 'numpy'):batch_embeddings = batch_embeddings[key].numpy()else:batch_embeddings = batch_embeddings[key]elif hasattr(batch_embeddings, 'numpy'):batch_embeddings = batch_embeddings.numpy()embeddings.append(batch_embeddings)# Progress reportingbatch_num = i // batch_size + 1if batch_num % 10 == 0:print(f"Processed batch {batch_num}/{num_batches}")except Exception as e:print(f"Error processing batch {batch_num}: {e}")continue400 unmodified lines401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435400 unmodified linesbatch = images[i:i + batch_size]processed_batch = self.preprocess_image_batch(batch)# Calculate batch number before try block to ensure it's available in except blockbatch_num = i // batch_size + 1try:# Handle different model interface typesif hasattr(self.path_foundation, 'signatures') and "serving_default" in self.path_foundation.signatures:# TensorFlow SavedModel formatinfer = self.path_foundation.signatures["serving_default"]batch_embeddings = infer(tf.constant(processed_batch))elif hasattr(self.path_foundation, 'predict'):# Standard Keras modelbatch_embeddings = self.path_foundation.predict(processed_batch, verbose=0)else:# Direct callablebatch_embeddings = self.path_foundation(processed_batch)# Handle different output formatsif isinstance(batch_embeddings, dict):key = list(batch_embeddings.keys())[0]if hasattr(batch_embeddings[key], 'numpy'):batch_embeddings = batch_embeddings[key].numpy()else:batch_embeddings = batch_embeddings[key]elif hasattr(batch_embeddings, 'numpy'):batch_embeddings = batch_embeddings.numpy()embeddings.append(batch_embeddings)# Progress reportingprint(f"Error processing batch {batch_num}: {e}")continue
58 unmodified lines596061626364656658 unmodified lines"/histo/hist1.png","/histo/hist2.png","/histo/hist3.jpg","/histo/hist4.jpg","/histo/hist5.jpg",],};58 unmodified lines596061626364656658 unmodified lines"/histo/hist1.png","/histo/hist2.png","/histo/hist3.jpg","/histo/hist4.tif","/histo/hist5.tif",],};
backend/model_histo.py+28-30
frontend/src/components/UploadSection.tsx+2-2