EthanCui commited on
Commit
9e3f4b2
·
verified ·
1 Parent(s): 78715f8

Add face shape measurement sheet, dataset card and four-measurement CLI

Browse files
README.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc0-1.0
3
+ language:
4
+ - en
5
+ pretty_name: Face Shape Measurement Reference (8 Shapes)
6
+ task_categories:
7
+ - tabular-classification
8
+ tags:
9
+ - face-shape
10
+ - beauty
11
+ - measurements
12
+ - reference-table
13
+ size_categories:
14
+ - n<1K
15
+ ---
16
+
17
+ # Face Shape Measurement Reference (8 Shapes)
18
+
19
+ A compact, reusable reference for identifying face shape from four tape measurements:
20
+ **forehead width, cheekbone width, jawline width, and face length**.
21
+
22
+ ## Files
23
+
24
+ | File | What it is |
25
+ | --- | --- |
26
+ | `face_shape_measurement_sheet.csv` | One row per shape — oval, round, square, heart, diamond, oblong, triangle/pear, hourglass. The four columns state where each measurement sits *relative to the other three*; `fastest_check` gives the single quickest screening rule for that shape. |
27
+ | `classify_face_shape.py` | Zero-dependency Python CLI: give it your four numbers, it returns the shapes whose rules actually match, ranked, with every matched and failed condition listed. Usage: `python classify_face_shape.py --forehead 14.2 --cheekbones 15.0 --jawline 13.6 --length 19.1` |
28
+
29
+ ## How the rules are expressed — and why
30
+
31
+ The sheet is deliberately **relative, not absolute**. Published face-shape guides describe
32
+ shapes with language like "slightly narrower than the cheekbones" or "cheekbones clearly the
33
+ widest part". This sheet preserves that structure instead of inventing millimetre cutoffs that
34
+ no source supports. The tool's tie band for "roughly equal" is its own adjustable parameter
35
+ (`--tol`, default 3%) — not a figure taken from any study.
36
+
37
+ ## Limits, stated plainly
38
+
39
+ Two judgments cannot come from a tape measure: the **jaw angle** (which separates round from
40
+ square) and **chin shape** (which separates heart from diamond). When the four numbers cannot
41
+ separate two candidates, the tool reports both and flags the manual check rather than guessing.
42
+
43
+ ## Relationship to image datasets
44
+
45
+ This is a **rule/measurement reference, not an image dataset**. It is intended to complement
46
+ the image-based face-shape datasets on Kaggle and Hugging Face: those train classifiers to
47
+ output a shape label, while this sheet documents the relative-width rules that define the
48
+ labels themselves.
49
+
50
+ ## Source and full guide
51
+
52
+ The worked guide — how to set up an honest reading, how to resolve cases where published
53
+ guides disagree, and the dated research milestones behind the four-measurement method — is
54
+ maintained at **https://faceshapechart.com/**
55
+
56
+ Code is also mirrored at https://github.com/heroin546-afk/face-shape-measurements
57
+
58
+ ## License
59
+
60
+ Data sheet: **CC0-1.0** (public domain, no attribution required). Script: MIT.
classify_face_shape.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Classify face shape candidates from four tape measurements.
3
+
4
+ Only relative comparisons between your four numbers are used, because published
5
+ face-shape guides state their rules in relative terms. "Roughly equal" uses a
6
+ single tie band (--tol, default 3%) that is this tool's own parameter, not a
7
+ figure from any published study. Where measurements alone cannot separate two
8
+ shapes (e.g. round vs square depends on jaw angle), the tool says so instead
9
+ of inventing an answer.
10
+
11
+ Usage:
12
+ python classify_face_shape.py --forehead 14.2 --cheekbones 15.0 \
13
+ --jawline 13.6 --length 19.1 [--tol 0.03] [--json]
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import argparse
19
+ import json
20
+ import sys
21
+
22
+ WIDTHS = ("forehead", "cheekbones", "jawline")
23
+
24
+ MANUAL_CHECKS = (
25
+ "Manual check (a tape cannot see this): "
26
+ "round vs square needs the jaw angle (soft curve vs strong angle); "
27
+ "heart vs diamond partly needs chin shape (pointed vs tapered)."
28
+ )
29
+
30
+
31
+ def make_rules(tol: float):
32
+ """Rule table: shape -> list of (condition_fn, plain-English condition).
33
+
34
+ The comparisons mirror the rules published in the guide at
35
+ https://faceshapechart.com/ — stated there in relative terms only.
36
+ """
37
+
38
+ def width(m):
39
+ return max(m[k] for k in WIDTHS)
40
+
41
+ def roughly(a, b, factor=1.0):
42
+ return abs(a - b) <= tol * factor * max(a, b)
43
+
44
+ def widest_is(key, strict=False):
45
+ def check(m):
46
+ w = width(m)
47
+ if m[key] < w * (1 - tol): # clearly below the widest
48
+ return False
49
+ if strict: # must beat the others outright
50
+ return all(m[key] > m[o] * (1 - tol) for o in WIDTHS if o != key)
51
+ return True
52
+ return check
53
+
54
+ return {
55
+ "oval": [
56
+ (widest_is("cheekbones"), "cheekbones widest"),
57
+ (lambda m: m["length"] > width(m) * (1 + tol * 0.5), "face longer than wide"),
58
+ (lambda m: m["jawline"] < m["cheekbones"] * (1 - tol * 0.5), "jaw narrower than cheekbones"),
59
+ ],
60
+ "round": [
61
+ (lambda m: roughly(m["length"], width(m), 1.2), "length roughly equal to width"),
62
+ (lambda m: roughly(m["forehead"], m["jawline"], 1.5), "forehead roughly equal to jawline"),
63
+ ],
64
+ "square": [
65
+ (lambda m: roughly(m["forehead"], m["cheekbones"], 1.5) and roughly(m["cheekbones"], m["jawline"], 1.5), "forehead, cheekbones, jawline roughly equal"),
66
+ (lambda m: roughly(m["length"], width(m), 1.2), "length roughly equal to width"),
67
+ ],
68
+ "heart": [
69
+ (widest_is("forehead", strict=True), "forehead clearly widest"),
70
+ (lambda m: m["jawline"] < m["forehead"] * (1 - tol * 0.5), "jaw narrower than forehead"),
71
+ ],
72
+ "diamond": [
73
+ (widest_is("cheekbones", strict=True), "cheekbones clearly widest"),
74
+ (lambda m: m["forehead"] < m["cheekbones"] * (1 - tol * 0.5), "forehead narrower than cheekbones"),
75
+ (lambda m: m["jawline"] < m["cheekbones"] * (1 - tol * 0.5), "jaw narrower than cheekbones"),
76
+ ],
77
+ "oblong": [
78
+ (lambda m: m["length"] > width(m) * (1 + 4 * tol), "length clearly greater than width"),
79
+ (lambda m: roughly(m["forehead"], m["cheekbones"], 1.5) and roughly(m["cheekbones"], m["jawline"], 1.5), "forehead, cheekbones, jawline roughly equal"),
80
+ ],
81
+ "triangle (pear)": [
82
+ (widest_is("jawline", strict=True), "jawline clearly widest"),
83
+ (lambda m: m["jawline"] > m["cheekbones"] * (1 + tol * 0.5), "jaw wider than cheekbones"),
84
+ ],
85
+ "hourglass": [
86
+ (lambda m: m["cheekbones"] >= m["forehead"] * (1 - tol) and m["jawline"] > m["forehead"] * (1 - tol) and m["jawline"] >= width(m) * (1 - 2 * tol), "cheekbones AND jawline both prominent"),
87
+ (lambda m: roughly(m["length"], width(m) * 1.1, 2.0), "length balanced against width"),
88
+ ],
89
+ }
90
+
91
+
92
+ def classify(m: dict, tol: float):
93
+ rules = make_rules(tol)
94
+ results = {}
95
+ for shape, conds in rules.items():
96
+ matched = [text for fn, text in conds if fn(m)]
97
+ failed = [text for fn, text in conds if not fn(m)]
98
+ results[shape] = {"score": len(matched), "total": len(conds), "matched": matched, "failed": failed}
99
+ return results
100
+
101
+
102
+ def main() -> int:
103
+ p = argparse.ArgumentParser(description="Rank face-shape candidates from four measurements.")
104
+ p.add_argument("--forehead", type=float, required=True, help="widest width across the forehead")
105
+ p.add_argument("--cheekbones", type=float, required=True, help="widest width across the cheekbones")
106
+ p.add_argument("--jawline", type=float, required=True, help="width across the jawline")
107
+ p.add_argument("--length", type=float, required=True, help="hairline-to-chin length")
108
+ p.add_argument("--tol", type=float, default=0.03, help="tie band for 'roughly equal' as a fraction (default 0.03 = 3%%); this tool's own parameter, not a published figure")
109
+ p.add_argument("--json", action="store_true", help="print raw JSON")
110
+ a = p.parse_args()
111
+
112
+ if min(a.forehead, a.cheekbones, a.jawline, a.length) <= 0:
113
+ p.error("all four measurements must be positive numbers (any consistent unit)")
114
+
115
+ m = {"forehead": a.forehead, "cheekbones": a.cheekbones, "jawline": a.jawline, "length": a.length}
116
+ results = classify(m, a.tol)
117
+
118
+ if a.json:
119
+ print(json.dumps({"measurements": m, "tol": a.tol, "results": results}, indent=2))
120
+ return 0
121
+
122
+ ranked = sorted(results.items(), key=lambda kv: (-kv[1]["score"], kv[0]))
123
+ best = ranked[0][1]["score"]
124
+ top = [s for s, r in ranked if r["score"] == best]
125
+
126
+ print("Measurements: forehead=%.4g cheekbones=%.4g jawline=%.4g length=%.4g (tol=%.0f%%)"
127
+ % (a.forehead, a.cheekbones, a.jawline, a.length, a.tol * 100))
128
+ print()
129
+ print("Top candidate(s): %s" % ", ".join(top))
130
+ print()
131
+ for shape, r in ranked:
132
+ tag = "OK " if not r["failed"] else " "
133
+ print(" %s[%s] %d/%d matched" % (tag, shape.ljust(16), r["score"], r["total"]))
134
+ for t in r["matched"]:
135
+ print(" + %s" % t)
136
+ for t in r["failed"]:
137
+ print(" - %s" % t)
138
+ print()
139
+ print(MANUAL_CHECKS)
140
+ return 0
141
+
142
+
143
+ if __name__ == "__main__":
144
+ sys.exit(main())
face_shape_measurement_sheet.csv ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ "face_shape","forehead","cheekbones","jawline","face_length","fastest_check"
2
+ "oval","slightly narrower than cheekbones","widest, gently rounded","softly curved, narrower than cheekbones","longer than width","length greater than width; cheekbones widest; soft jaw"
3
+ "round","about equal to jawline","full cheeks; width roughly equals length","soft, no strong angle","roughly equal to width","length equals width; no angles"
4
+ "square","broad; roughly equal to cheekbones and jawline","roughly equal to forehead and jawline","strong and angular","roughly equal to width","forehead, cheekbones and jawline equal; angular jaw"
5
+ "heart","widest point (broad forehead)","taper toward the chin","narrow; chin narrow and pointed","longer than lower-face width","widest at forehead; narrow chin"
6
+ "diamond","narrower than cheekbones","clearly the widest point","narrow; chin pointed","longer than width","cheekbones dominant; narrow forehead and chin"
7
+ "oblong","roughly equal to cheekbones and jawline","straight cheek line","similar width to forehead","noticeably longer than width","length clearly greater than width; straight sides"
8
+ "triangle (pear)","narrowest feature","narrower than jawline","widest and broad","varies","jaw is the widest point"
9
+ "hourglass (rare)","narrower than cheekbones","prominent and wide","wide and angular","balanced","cheekbones AND jawline both prominent"