remove: skin_tone_trace node type

- skin_tone is a person attribute (like height), not trace attribute
- Remove build_skin_tone_trace_nodes function
- Remove skin_tone_trace_nodes from TkgResult and API response
- Remove skin_tone_trace from documentation tables
This commit is contained in:
Accusys
2026-06-25 19:21:05 +08:00
parent fd2edd5736
commit 0c3f385b1f
4 changed files with 0 additions and 203 deletions
-1
View File
@@ -1002,7 +1002,6 @@ async fn rebuild_tkg(
"lip_track_nodes": r.lip_track_nodes,
"text_region_nodes": r.text_region_nodes,
"appearance_trace_nodes": r.appearance_trace_nodes,
"skin_tone_trace_nodes": r.skin_tone_trace_nodes,
"accessory_nodes": r.accessory_nodes,
"object_nodes": r.object_nodes,
"hand_nodes": r.hand_nodes,
-92
View File
@@ -465,7 +465,6 @@ pub struct TkgResult {
pub lip_track_nodes: usize,
pub text_region_nodes: usize,
pub appearance_trace_nodes: usize,
pub skin_tone_trace_nodes: usize,
pub accessory_nodes: usize,
pub object_nodes: usize,
pub hand_nodes: usize,
@@ -511,7 +510,6 @@ pub async fn build_tkg(db: &PostgresDb, file_uuid: &str, output_dir: &str) -> Re
let n_text = build_text_region_nodes(pool, file_uuid).await?;
let n_appearance =
build_appearance_trace_nodes(pool, file_uuid, output_dir, &pose_data).await?;
let n_skin_tone = build_skin_tone_trace_nodes(pool, file_uuid, output_dir).await?;
let n_accessories = build_accessory_nodes(pool, file_uuid, output_dir).await?;
let n_objects = build_yolo_object_nodes(pool, file_uuid, output_dir).await?;
let n_hands = build_hand_nodes(pool, file_uuid, output_dir).await?;
@@ -532,7 +530,6 @@ pub async fn build_tkg(db: &PostgresDb, file_uuid: &str, output_dir: &str) -> Re
lip_track_nodes: n_lip,
text_region_nodes: n_text,
appearance_trace_nodes: n_appearance,
skin_tone_trace_nodes: n_skin_tone,
accessory_nodes: n_accessories,
object_nodes: n_objects,
hand_nodes: n_hands,
@@ -2578,94 +2575,6 @@ fn classify_fitzpatrick(h_mean: f64) -> &'static str {
}
}
async fn build_skin_tone_trace_nodes(
pool: &PgPool,
file_uuid: &str,
output_dir: &str,
) -> Result<usize> {
let nodes_table = t("tkg_nodes");
let fd_table = t("face_detections");
let mut count = 0;
let rows: Vec<(i64, i64)> = sqlx::query_as(&format!(
"SELECT trace_id::bigint, COUNT(*)::bigint \
FROM {} \
WHERE file_uuid = $1 AND trace_id IS NOT NULL \
GROUP BY trace_id",
fd_table
))
.bind(file_uuid)
.fetch_all(pool)
.await?;
if rows.is_empty() {
tracing::info!("[TKG] No traced faces for skin_tone_trace nodes");
return Ok(0);
}
let path = Path::new(output_dir).join(format!("{}.face.json", file_uuid));
let face_json = if path.exists() {
let content = std::fs::read_to_string(&path)
.with_context(|| format!("Failed to read face.json: {}", path.display()))?;
serde_json::from_str::<serde_json::Value>(&content)?
} else {
tracing::warn!("[TKG] No face.json for skin_tone computation");
serde_json::Value::Null
};
for (trace_id, frame_count) in &rows {
let avg_skin_h = if !face_json.is_null() {
let mut skin_h_values = Vec::new();
if let Some(frames) = face_json.get("frames").and_then(|v| v.as_array()) {
for frame_entry in frames {
if let Some(faces) = frame_entry.get("faces").and_then(|v| v.as_array()) {
for face in faces {
let face_trace_id = face.get("trace_id").and_then(|v| v.as_i64());
if face_trace_id == Some(*trace_id) {
skin_h_values.push(compute_skin_h_from_face(face));
}
}
}
}
}
if skin_h_values.is_empty() {
20.0
} else {
skin_h_values.iter().sum::<f64>() / skin_h_values.len() as f64
}
} else {
20.0
};
let fitz_type = classify_fitzpatrick(avg_skin_h);
let external_id = format!("skin_tone_{}", trace_id);
let label = format!("Skin Tone Trace {}", trace_id);
sqlx::query(&format!(
"INSERT INTO {} (node_type, external_id, file_uuid, label, properties) \
VALUES ('skin_tone_trace', $1, $2, $3, $4::jsonb) \
ON CONFLICT (file_uuid, node_type, external_id) DO UPDATE SET properties = EXCLUDED.properties",
nodes_table
))
.bind(&external_id)
.bind(file_uuid)
.bind(&label)
.bind(serde_json::json!({
"trace_id": trace_id,
"avg_skin_h": avg_skin_h,
"fitzpatrick_type": fitz_type,
"frame_count": frame_count,
}))
.execute(pool)
.await?;
count += 1;
}
tracing::info!("[TKG] Built {} skin_tone_trace nodes", count);
Ok(count)
}
// ── Accessory Nodes ──────────────────────────────────────────────
async fn build_accessory_nodes(pool: &PgPool, file_uuid: &str, output_dir: &str) -> Result<usize> {
@@ -3219,7 +3128,6 @@ let r = TkgResult {
lip_track_nodes: 4,
text_region_nodes: 20,
appearance_trace_nodes: 3,
skin_tone_trace_nodes: 5,
accessory_nodes: 0,
object_nodes: 10,
hand_nodes: 0,