Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,56 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache DeepFace weights
uses: actions/cache@v4
with:
path: ~/.deepface/weights
key: deepface-weights-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
deepface-weights-${{ runner.os }}-py${{ matrix.python-version }}-
deepface-weights-${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
# sending files in form data throwing error in flask 3 while running tests
pip install Werkzeug==2.0.2 flask==2.0.2
pip install .
- name: Remove corrupted DeepFace weights (if any)
run: |
python - <<'PY'
import os, glob

weights_dir = os.path.expanduser("~/.deepface/weights")
if not os.path.isdir(weights_dir):
raise SystemExit(0)

# Validate HDF5 integrity; delete invalid files so they will be re-downloaded.
try:
import h5py
except Exception:
# If h5py isn't present for some reason, fall back to size-based cleanup only.
h5py = None

for p in glob.glob(os.path.join(weights_dir, "*.h5")):
try:
# Keep your existing small-file guard
if os.path.getsize(p) < 1024 * 100:
print("Removing tiny weight file:", p)
os.remove(p)
continue

if h5py is not None:
try:
with h5py.File(p, "r"):
pass
except Exception as e:
print("Removing corrupted H5 weight file:", p, "reason:", repr(e))
os.remove(p)

except OSError:
pass
PY
- name: Test with pytest
run: |
cd tests/unit
Expand Down
Loading