yarppg icon indicating copy to clipboard operation
yarppg copied to clipboard

Importing the yarppg package is not working/taking too long

Open Niteesh-Kalangi opened this issue 1 year ago • 7 comments

I am trying to use yarppg as a package, and I did all the instructions to install the package locally.

I have attached my code below. Basically, it prints "hello" once and then stops for like 5 mins (didn't wait longer than that), meaning it is stuck when importing yarppg. Also, just a note: it was working before. But that was like a few weeks ago, but now when I am running the same program, this issue is happening. How can I fix or debug this?

print("hello")
import yarppg
print("hello")
import matplotlib.pyplot as plt
import numpy as np
import scipy.signal
import neurokit2 as nk
import joblib
import pandas as pd
print("hello")



filename = "/Users/niteesh/Desktop/rppg-tes1.mov"

fps = yarppg.get_video_fps(filename)
filter_cfg = yarppg.digital_filter.FilterConfig(fps, 0.5, 1.5, btype="bandpass")
livefilter = yarppg.digital_filter.make_digital_filter(filter_cfg)
processor = yarppg.FilteredProcessor(yarppg.Processor(), livefilter=livefilter)

rppg = yarppg.Rppg(
    processor=processor,
    hr_calc=yarppg.PeakBasedHrCalculator(fps, window_seconds=4),
)
results = rppg.process_video(filename)

distanceVal = 0.5
values = np.array(results)
hrs = yarppg.bpm_from_frames_per_beat(values[:, -1], fps)

signals = values[:, 0]

mean_hr = np.nanmean(hrs)
peaks, _ = scipy.signal.find_peaks(signals, distance=distanceVal * fps)
hrv_indices = nk.hrv(peaks, sampling_rate=fps, show=True)
print("Type", type(hrv_indices))
sdrr = hrv_indices['HRV_SDNN'].loc[0]  # Standard deviation of NN intervals
rmssd = hrv_indices['HRV_RMSSD'].loc[0]  # Root mean square of successive differences
sdsd = hrv_indices['HRV_SDSD'].loc[0]  # Standard deviation of successive differences
pnn50 = hrv_indices['HRV_pNN50'].loc[0]  # Proportion of pairs of successive NNs that differ by more than 50 ms
HRV_metrics = {"HR": mean_hr, "SDNN": sdrr, "RMSSD": rmssd, "SDSD": sdsd, "pNN50": pnn50}
print(HRV_metrics)
print("pNN50", pnn50)

Niteesh-Kalangi avatar Nov 15 '24 20:11 Niteesh-Kalangi

What version of Python are you using? Which OS?

Have you tried re-installing the package?

SamProell avatar Nov 16 '24 09:11 SamProell

Macos Python 3.10.1. Yes, I have tried reinstalling.

Niteesh-Kalangi avatar Nov 16 '24 18:11 Niteesh-Kalangi

Unfortunately, I am struggling to reproduce the problem.

Importing yarppg works for me on an M3 mac with Python3.10..

If you could find out, which import inside yarppg blocks for you we can maybe figure it out.

Also, have you tried it inside a fresh virtual environment?

SamProell avatar Nov 17 '24 08:11 SamProell

When I tried it in a fresh environment it worked. This is because I am using this within the context of other code as well, so there is probably a dependency issue happening. Could you tell me which of these dependencies could be problematic from the other code?

Repo 1: heartpy==1.2.7 joblib==1.3.2 matplotlib==3.8.3 numpy==1.26.4 pandas==2.2.1 scikit_learn==1.2.2 tensorflow==2.16.1 tensorflow_intel==2.16.1 xgboost==2.0.3 scipy==1.11.3 neurokit2==0.2.7

Repo 2: Flask==2.2.2 gunicorn Werkzeug==2.2.2 pandas numpy==1.26.3 pandas==2.2.0 scikit-learn==1.2.2 scipy==1.12.0 seaborn==0.13.2 xgboost==2.0.3 azure-storage-blob azure-identity joblib==1.3.2 heartpy serial datetime pyserial

Niteesh-Kalangi avatar Nov 22 '24 19:11 Niteesh-Kalangi

great to hear that the issue was just in the environment. It's difficult for me to tell. tensorflow might be an issue parallel to mediapipe but I am not sure.

SamProell avatar Nov 26 '24 08:11 SamProell

Any way you can give me a list of all the packages and/or versions required for yarppg?

Niteesh-Kalangi avatar Dec 01 '24 23:12 Niteesh-Kalangi

This works for me on Windows (Python 3.11)

hydra-core==1.3.2
mediapipe==0.10.14
numpy==2.0.1
opencv-contrib-python==4.10.0.84
pandas==2.2.2
scipy==1.14.0

Full environment:

absl-py==2.1.0
altgraph==0.17.4
antlr4-python3-runtime==4.9.3
asttokens==2.4.1
attrs==24.2.0
babel==2.16.0
beautifulsoup4==4.12.3
bleach==6.1.0
certifi==2024.8.30
cffi==1.17.0
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
comm==0.2.2
contourpy==1.2.1
cycler==0.12.1
debugpy==1.8.5
decorator==5.1.1
defusedxml==0.7.1
executing==2.0.1
fastjsonschema==2.20.0
flatbuffers==24.3.25
fonttools==4.53.1
ghp-import==2.1.0
griffe==1.3.1
hydra-core==1.3.2
idna==3.10
iniconfig==2.0.0
ipykernel==6.29.5
ipython==8.26.0
jax==0.4.31
jaxlib==0.4.31
jedi==0.19.1
Jinja2==3.1.4
joblib==1.4.2
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
jupyter_client==8.6.2
jupyter_core==5.7.2
jupyterlab_pygments==0.3.0
jupytext==1.16.4
kiwisolver==1.4.5
Markdown==3.7
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.9.2
matplotlib-inline==0.1.7
mdit-py-plugins==0.4.2
mdurl==0.1.2
mediapipe==0.10.14
mergedeep==1.3.4
mistune==3.0.2
mkdocs==1.6.1
mkdocs-autorefs==1.2.0
mkdocs-get-deps==0.2.0
mkdocs-jupyter==0.25.0
mkdocs-material==9.5.38
mkdocs-material-extensions==1.3.1
mkdocs-section-index==0.3.9
mkdocstrings==0.26.1
mkdocstrings-python==1.11.1
ml-dtypes==0.4.0
mypy==1.11.1
mypy-extensions==1.0.0
nbclient==0.10.0
nbconvert==7.16.4
nbformat==5.10.4
nest-asyncio==1.6.0
numpy==2.0.1
omegaconf==2.3.0
opencv-contrib-python==4.10.0.84
opencv-contrib-python-headless==4.10.0.84
opt-einsum==3.3.0
packaging==24.1
paginate==0.5.7
pandas==2.2.2
pandocfilters==1.5.1
parso==0.8.4
pathspec==0.12.1
pefile==2024.8.26
pillow==10.4.0
platformdirs==4.2.2
pluggy==1.5.0
prompt_toolkit==3.0.47
protobuf==4.25.4
psutil==6.0.0
pure_eval==0.2.3
pycparser==2.22
Pygments==2.18.0
pyinstaller==6.10.0
pyinstaller-hooks-contrib==2024.8
pymdown-extensions==10.11
pyparsing==3.1.2
PyQt6==6.7.1
PyQt6-Qt6==6.7.2
PyQt6_sip==13.8.0
pyqtgraph==0.13.7
PySide6==6.6.3.1
PySide6-stubs==6.4.2.0
PySide6_Addons==6.6.3.1
PySide6_Essentials==6.6.3.1
pytest==8.3.3
python-dateutil==2.9.0.post0
pytz==2024.1
pywin32==306
pywin32-ctypes==0.2.3
PyYAML==6.0.2
pyyaml_env_tag==0.1
pyzmq==26.1.0
referencing==0.35.1
regex==2024.9.11
requests==2.32.3
rpds-py==0.20.0
ruff==0.6.1
scipy==1.14.0
shiboken6==6.6.3.1
six==1.16.0
snakeviz==2.2.0
sounddevice==0.5.0
soupsieve==2.6
stack-data==0.6.3
tinycss2==1.3.0
tornado==6.4.1
traitlets==5.14.3
typer-slim==0.12.5
typing_extensions==4.12.2
tzdata==2024.1
urllib3==2.2.3
watchdog==5.0.3
wcwidth==0.2.13
webencodings==0.5.1

SamProell avatar Dec 02 '24 17:12 SamProell