Spaces:
Running
Running
Download scripts/stat.py from Ethscriptions/mx: direct link, hf CLI and curl.
- Browser
- Download file 480 Bytes
-
https://huggingface.co/spaces/Ethscriptions/mx/resolve/main/scripts/stat.py
- Command line
-
hf download hf://spaces/Ethscriptions/mx/scripts/stat.py
-
curl -L -o stat.py https://huggingface.co/spaces/Ethscriptions/mx/resolve/main/scripts/stat.py
480 Bytes
| import sys | |
| from PIL import Image; import numpy as np | |
| for f in sys.argv[1:]: | |
| a=np.array(Image.open(f).convert('RGB')).astype(int) | |
| skin=(a[:,:,0]>150)&(a[:,:,0]>a[:,:,2]+40) | |
| bone=(a[:,:,0]>190)&(a[:,:,1]>180)&(a[:,:,2]>150) | |
| red=(a[:,:,0]>200)&(a[:,:,1]<90) | |
| def bb(m): | |
| ys,xs=np.where(m); return (int(m.sum()), (xs.min(),xs.max(),ys.min(),ys.max())) if len(xs) else (0,None) | |
| print(f, 'mean',a.mean(axis=(0,1)).round(1),'skin',bb(skin),'bright',bb(bone),'red',bb(red)) | |