Skip to content

liesliy/tlabel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TouchLabel AI 🦞

Sensor-Agnostic Tactile Data Annotation Toolkit

load β†’ review β†’ export Β· Three steps to close the loop

PyPI Python License δΈ­ζ–‡ζ–‡ζ‘£

TouchLabel AI Panel Demo


πŸš€ Quick Start

pip install tlabel
import tlabel

# 1️⃣ Load β€” auto-detect sensor format
data = tlabel.load("gelsight_force.pkl")     # GelSight / DIGIT
data = tlabel.load("paxini_episode.h5")      # PaXini
data = tlabel.load("daimon_data/")           # Daimon (directory or .parquet)

# 2️⃣ Annotate β€” interactive Jupyter panel
data.review()          # Chinese UI
data.review(lang="en") # English UI

# 3️⃣ Export
data.export("output.json")   # TLabel Format v2 JSON
data.export("output.csv")    # CSV flat table
πŸ“₯ Try with demo data
pip install tlabel
python -c "
import json, urllib.request
from tlabel.core.types import TLabelFrame, TLabelData

url = 'https://raw.githubusercontent.com/liesliy/tlabel/main/examples/data/demo_gelsight.json'
raw = json.loads(urllib.request.urlopen(url).read())
frames = [TLabelFrame(f['frame_idx'], f['timestamp_s'], f['tlabel_v2'], f.get('manipulation_phase','idle'), f.get('confidence',1.0)) for f in raw['frames']]
data = TLabelData(frames, raw['sensor'], raw['episode'], raw['capabilities'])
data.review()
"

πŸ“‘ Supported Sensors

Sensor Format Dimensions Optical Flow Status
GelSight Mini .pkl 22 βœ… βœ… Stable
DIGIT .pkl 22 βœ… βœ… Stable
Daimon DM-TacClaw .parquet / dir 22 (video) / 20 (no video) βœ… / β€” βœ… Stable
PaXini PXCap .h5 / .hdf5 20 β€” βœ… Stable

Force-type sensors (PaXini) lack optical images and don't support optical flow features, yielding 20 dimensions. Image-type sensors output all 22 dimensions. Daimon gracefully degrades to 20 dims when no video file is present.


πŸ“¦ Installation

# Minimal (numpy only)
pip install tlabel

# Per-sensor optional dependencies
pip install tlabel[gelsight]   # GelSight / DIGIT β†’ opencv-python
pip install tlabel[paxini]     # PaXini β†’ h5py
pip install tlabel[daimon]     # Daimon β†’ pyarrow + opencv-python

# Everything
pip install tlabel[all]

🎨 Panel Features

  • 🎨 Color-coded timeline: green = contact Β· red = slip Β· gray = no contact
  • πŸ•Έ 22-dim radar chart: full TLabel Format v2 visualization with bilingual labels
  • ✏️ Frame & batch patching: select a range, modify in one click
  • πŸ”— Cascade rules: setting contact=0 auto-zeroes 7 related fields + resets manipulation_phaseβ†’idle
  • 🌐 Bilingual toggle: Chinese / English, one click in the top-right corner
  • πŸ“€ Export: JSON / CSV, auto-detected by file extension

TLabel Format v2 β€” 22 Dimensions

Static Features (18-dim)

# Key Description
1 contact Binary contact flag
2 deformation_magnitude Surface deformation intensity
3 force_magnitude Normal force magnitude
4 force_peak Peak force in episode window
5 force_direction Force vector angle (Β°)
6 slip_entropy Uncertainty of slip detection
7 slip_event Binary slip event flag
8 texture_energy Surface texture frequency energy
9 edge_density Contact edge pixel ratio
10 contact_area Contact region area ratio
11 centroid_x Contact centroid x-position
12 normal_field_magnitude Normal pressure field magnitude
13 normal_field_variance Normal field spatial variance
14 shear_field_magnitude Shear stress magnitude
15 shear_field_direction Shear direction angle (Β°)
16 delta_force_normal Frame-to-frame Ξ”F_normal
17 delta_force_shear Frame-to-frame Ξ”F_shear
18 friction_cone_ratio Tangential/normal force ratio

Temporal Features (4-dim, v0.2.0)

# Key Image-type Force-type Description
19 optical_flow_magnitude βœ… β€” Inter-frame motion magnitude (Farneback)
20 optical_flow_direction βœ… β€” Optical flow angle (Β°)
21 temporal_deformation_rate βœ… βœ… Rate of deformation change
22 contact_transition βœ… βœ… Contact state transition probability

πŸ“– API Quick Reference

import tlabel

# ── Loading ──
data = tlabel.load(path)                     # Auto-detect sensor format
data = tlabel.load(path, format="gelsight")  # Force specific adapter

# ── Properties ──
data.num_frames        # int β€” total frame count
data.duration_s        # float β€” episode duration
data.sensor_type       # str β€” sensor identifier
data.dimension_keys    # list β€” all dimension keys for this sensor
data.modified_count    # int β€” frames with manual patches

# ── Frame Access ──
frame = data[0]                          # Index access
frame = data.get_frame(42)               # By frame_idx
frame.contact                            # Contact value
frame.slip_event                         # Slip event value
frame.is_modified                        # Has patches?

# ── Patching ──
frame.patch("contact", 0)                         # Single frame (cascade=True)
frame.patch("contact", 0, cascade=False)           # No cascade
data.batch_patch(10, 50, "contact", 0)             # Range patch

# ── Review & Export ──
data.review()                    # Jupyter panel (Chinese)
data.review(lang="en")           # English
data.export("output.json")       # JSON (TLabel Format v2)
data.export("output.csv")        # CSV

Cascade Rules (contact β†’ 0)

When contact is set to 0, these fields are automatically zeroed:

Auto-zeroed Field Condition
force_magnitude always
force_peak always
slip_event always
delta_force_normal always
delta_force_shear always
contact_area always
contact_transition only if value > 0.5
manipulation_phase β†’ "idle" (if not already)

πŸ—‚ Project Structure

tlabel/
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ types.py          # TLabelFrame / TLabelData containers
β”‚   β”œβ”€β”€ loader.py         # Auto-detect & dispatch loading
β”‚   └── registry.py       # Adapter registry
β”œβ”€β”€ adapters/
β”‚   β”œβ”€β”€ base.py           # BaseAdapter interface
β”‚   β”œβ”€β”€ gelsight.py       # GelSight Mini / DIGIT
β”‚   β”œβ”€β”€ paxini.py         # PaXini PXCap
β”‚   └── daimon.py         # Daimon DM-TacClaw (+ video decoding)
β”œβ”€β”€ viewer/
β”‚   β”œβ”€β”€ panel.py          # Jupyter _repr_html_ renderer
β”‚   └── templates.py      # HTML + JS + CSS template engine
└── export/
    └── writer.py         # JSON / CSV export + NumpyEncoder

🀝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Good first issues:

  • πŸ”Œ Add a new sensor adapter (e.g., SynTouch, XELA)
  • πŸ“Š Improve radar chart UI (dark mode, interactive hover)
  • 🌐 Add more language support (ζ—₯本θͺž, ν•œκ΅­μ–΄)
  • πŸ§ͺ Add integration tests for edge cases

πŸ“„ License

MIT Β© Niuzu Tech


Star us ⭐ if it helps your research!

About

A Unified Annotation Framework for Cross-Sensor Tactile Manipulation Data

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors