Fixed second image inference failing issue
All checks were successful
armco-org/visual-search-engine/pipeline/head This commit looks good

This commit is contained in:
2026-01-03 16:35:28 +05:30
parent 376ca54b2d
commit 11e3fea61d
3 changed files with 24 additions and 0 deletions

2
.gitattributes.bak Normal file
View File

@@ -0,0 +1,2 @@
*.pkl filter=lfs diff=lfs merge=lfs -text
*.faiss filter=lfs diff=lfs merge=lfs -text

View File

@@ -6,6 +6,18 @@ Override via environment variables or by modifying defaults.
"""
import os
import platform
# Disable MPS (Metal) on Apple Silicon to avoid intermittent inference failures
# This must be set BEFORE importing TensorFlow/Keras
os.environ.setdefault('TF_USE_LEGACY_KERAS', '1')
os.environ.setdefault('CUDA_VISIBLE_DEVICES', '')
os.environ.setdefault('TF_CPP_MIN_LOG_LEVEL', '2')
# Force CPU-only on macOS to avoid MPS graph caching bugs
if platform.system() == 'Darwin':
os.environ['TF_DISABLE_MPS_DEVICE_PLACEMENT'] = '1'
os.environ['METAL_DEVICE_WRAPPER_TYPE'] = '0'
class Config:

View File

@@ -1,6 +1,16 @@
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import numpy as np
import joblib
# Disable GPU/Metal to fix intermittent MPS graph cache crash on Apple Silicon
import tensorflow as tf
try:
tf.config.set_visible_devices([], 'GPU')
except Exception:
pass
from keras import Sequential
from keras.preprocessing import image
from keras.layers import GlobalMaxPooling2D