Skip to content

Commit 54b87f9

Browse files
Merge pull request #23 from jonathanrocher/ENH/add_metadata_to_script
Enh: add metadata collection to stage 0 script
2 parents 89444ab + 10fa20f commit 54b87f9

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ scalable applications, and package them into an installer.
2020
### Requirements
2121

2222
- Python 3.6+
23+
- scikits.image
24+
- Pillow
2325
- Pandas
2426
- matplotlib
2527
- traits
2628
- traitsui
27-
- scikits.image
2829

2930
### EDM users (recommended)
3031
First, download and install EDM from https://www.enthought.com/edm/. Then, run
@@ -33,7 +34,7 @@ Python environment and install all dependencies in it:
3334
```commandline
3435
edm env create ets_tutorial
3536
edm shell -e ets_tutorial
36-
edm install pandas matplotlib traits traitsui scikits.image
37+
edm install pandas matplotlib traits traitsui scikits.image pillow pyqt5 ipython
3738
```
3839

3940
### Conda users
@@ -43,14 +44,15 @@ edm install pandas matplotlib traits traitsui scikits.image
4344
Assuming a Python environment is created and activated on your machine, for
4445
example from https://www.python.org/,
4546
```commandline
46-
pip install pandas matplotlib traits traitsui scikits-image
47+
pip install pandas matplotlib traits traitsui scikits-image pillow pyqt5 ipython
4748
```
4849

4950
## Getting help
5051
### During the tutorial
5152
During the tutorial, don't hesitate to ask for help:
5253
- ask questions if something isn't clear,
53-
- there will be a number of developers in the room who can help unblock you.
54+
- or just call out for individual support: there will be a number of developers
55+
in the room who can help unblock you.
5456

5557
### After the tutorial
5658
- This tutorial was recorded and can be watched [here]() [TODO]
80.3 KB
Loading

sample_images/owls.jpg

3.07 MB
Loading

stage0_starting_script/face_detect_skimage.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1+
""" Script analyzing an image, detecting human faces inside it, and printing
2+
EXIF data about it.
3+
"""
4+
import PIL.Image
5+
from PIL.ExifTags import TAGS
16
from skimage import data
27
from skimage.feature import Cascade
3-
48
import matplotlib.pyplot as plt
59
from matplotlib import patches
10+
import sys
11+
from os.path import join
612

713
# Load the trained file from the module root.
814
trained_file = data.lbp_frontal_face_cascade_filename()
915

1016
# Initialize the detector cascade.
1117
detector = Cascade(trained_file)
1218

13-
img = data.astronaut()
19+
if len(sys.argv) > 1:
20+
image_path = sys.argv[1]
21+
else:
22+
image_path = join("..", "sample_images", "IMG-0311_xmas_2020.JPG")
23+
# image_path = join("..", "sample_images", "owls.jpg")
24+
25+
img = plt.imread(image_path)
1426

1527
detected = detector.detect_multi_scale(img=img,
1628
scale_factor=1.2,
1729
step_ratio=1,
1830
min_size=(60, 60),
19-
max_size=(123, 123))
31+
max_size=(600, 600))
2032

2133
plt.imshow(img)
2234
img_desc = plt.gca()
@@ -35,4 +47,11 @@
3547
)
3648
)
3749

50+
img = PIL.Image.open(image_path)
51+
52+
data = {TAGS[k]: v for k, v in img._getexif().items() if k in TAGS}
53+
data["Number of faces detected"] = len(detected)
54+
55+
print(data)
56+
3857
plt.show()

0 commit comments

Comments
 (0)