TechTush commited on
Commit
3235984
·
verified ·
1 Parent(s): 5bf86f6

Rangrez dashboard

Browse files
README.md CHANGED
@@ -12,6 +12,8 @@ short_description: A self-driving dye lab on Meta models
12
 
13
  # Rangrez: a self-driving dye lab
14
 
 
 
15
  Pick a colour and press **Start campaign**. Rangrez mixes a recipe, dyes a cotton strip in its
16
  simulated lab (a hidden dye lot that differs from the supplier's model), photographs it like a
17
  phone would, measures it, and corrects itself until the cloth matches. Every dip photo is a
@@ -32,3 +34,4 @@ and see the customer's garment in the approved shade (**Muse Image**, measured a
32
  One lab, shared by everyone viewing: if a campaign is running, you are watching it.
33
 
34
  Code, hardware, firmware and evaluation: https://github.com/TusharTechs/rangrez
 
 
12
 
13
  # Rangrez: a self-driving dye lab
14
 
15
+ ▶ **[Watch the 3-minute demo](https://youtu.be/g4Z30UhPtjA)** · [A recorded live run](?replay=1) · [The 2-minute tour](?tour=1)
16
+
17
  Pick a colour and press **Start campaign**. Rangrez mixes a recipe, dyes a cotton strip in its
18
  simulated lab (a hidden dye lot that differs from the supplier's model), photographs it like a
19
  phone would, measures it, and corrects itself until the cloth matches. Every dip photo is a
 
34
  One lab, shared by everyone viewing: if a campaign is running, you are watching it.
35
 
36
  Code, hardware, firmware and evaluation: https://github.com/TusharTechs/rangrez
37
+ Open weights: https://huggingface.co/TechTush/rangrez-glimmer-lora · Dataset: https://huggingface.co/datasets/TechTush/rangrez-lab-dips
pyproject.toml CHANGED
@@ -3,6 +3,7 @@ name = "rangrez"
3
  version = "0.1.0"
4
  description = "A self-driving dye lab: Meta models match any colour on real cotton"
5
  readme = "README.md"
 
6
  authors = [
7
  { name = "Tushar Agarwal", email = "tusharaggarwal274@gmail.com" }
8
  ]
 
3
  version = "0.1.0"
4
  description = "A self-driving dye lab: Meta models match any colour on real cotton"
5
  readme = "README.md"
6
+ license = "Apache-2.0"
7
  authors = [
8
  { name = "Tushar Agarwal", email = "tusharaggarwal274@gmail.com" }
9
  ]
src/rangrez/esp32_emulator.py CHANGED
@@ -33,7 +33,7 @@ FIRMWARE = Path(__file__).parents[2] / "firmware" / "rangrez_rig" / "rangrez_rig
33
 
34
  def firmware_limits(path: Path = FIRMWARE) -> dict[str, float]:
35
  """The `const float MAX_*` limits and pump calibration, as compiled into the board."""
36
- src = path.read_text()
37
  limits = {k: float(v) for k, v in re.findall(r"const float (MAX_\w+) = ([\d.]+);", src)}
38
  limits["msPerMl"] = [float(v) for v in re.search(r"msPerMl\[5\] = \{([^}]*)\}", src).group(1).split(",")]
39
  return limits
 
33
 
34
  def firmware_limits(path: Path = FIRMWARE) -> dict[str, float]:
35
  """The `const float MAX_*` limits and pump calibration, as compiled into the board."""
36
+ src = path.read_text(encoding="utf-8")
37
  limits = {k: float(v) for k, v in re.findall(r"const float (MAX_\w+) = ([\d.]+);", src)}
38
  limits["msPerMl"] = [float(v) for v in re.search(r"msPerMl\[5\] = \{([^}]*)\}", src).group(1).split(",")]
39
  return limits
src/rangrez/memory.py CHANGED
@@ -32,7 +32,7 @@ class LabMemory:
32
  self.path = path
33
  self.data = {"dye_set": PROFILE.key, "dips": [], "campaigns": []}
34
  if path is not None and path.exists():
35
- self.data = json.loads(path.read_text())
36
 
37
  @property
38
  def dips(self) -> list[dict]:
@@ -56,7 +56,7 @@ class LabMemory:
56
  return
57
  self.path.parent.mkdir(parents=True, exist_ok=True)
58
  tmp = self.path.with_suffix(".tmp")
59
- tmp.write_text(json.dumps(self.data))
60
  tmp.replace(self.path)
61
 
62
  def recent(self, n: int = RECENT_DIPS) -> list[tuple[np.ndarray, np.ndarray]]:
 
32
  self.path = path
33
  self.data = {"dye_set": PROFILE.key, "dips": [], "campaigns": []}
34
  if path is not None and path.exists():
35
+ self.data = json.loads(path.read_text(encoding="utf-8"))
36
 
37
  @property
38
  def dips(self) -> list[dict]:
 
56
  return
57
  self.path.parent.mkdir(parents=True, exist_ok=True)
58
  tmp = self.path.with_suffix(".tmp")
59
+ tmp.write_text(json.dumps(self.data), encoding="utf-8")
60
  tmp.replace(self.path)
61
 
62
  def recent(self, n: int = RECENT_DIPS) -> list[tuple[np.ndarray, np.ndarray]]:
src/rangrez/recorder.py CHANGED
@@ -40,7 +40,7 @@ class Recorder:
40
  with self.lock:
41
  self.dir = self.root / f"{time.strftime('%Y-%m-%d_%H%M%S')}_{label}"
42
  self.dir.mkdir(parents=True, exist_ok=True)
43
- (self.dir / "meta.json").write_text(json.dumps(meta, indent=2, default=str))
44
  for name, data in self.pending:
45
  (self.dir / name).write_bytes(data)
46
  self.pending = []
@@ -49,7 +49,7 @@ class Recorder:
49
  def event(self, event: dict) -> None:
50
  if self.dir is None:
51
  return
52
- with self.lock, open(self.dir / "events.jsonl", "a") as f:
53
  f.write(json.dumps(event, default=str) + "\n")
54
 
55
  def save(self, name: str, data: bytes | str | dict) -> None:
 
40
  with self.lock:
41
  self.dir = self.root / f"{time.strftime('%Y-%m-%d_%H%M%S')}_{label}"
42
  self.dir.mkdir(parents=True, exist_ok=True)
43
+ (self.dir / "meta.json").write_text(json.dumps(meta, indent=2, default=str), encoding="utf-8")
44
  for name, data in self.pending:
45
  (self.dir / name).write_bytes(data)
46
  self.pending = []
 
49
  def event(self, event: dict) -> None:
50
  if self.dir is None:
51
  return
52
+ with self.lock, open(self.dir / "events.jsonl", "a", encoding="utf-8") as f:
53
  f.write(json.dumps(event, default=str) + "\n")
54
 
55
  def save(self, name: str, data: bytes | str | dict) -> None:
src/rangrez/replay.py CHANGED
@@ -19,7 +19,7 @@ SAMPLES = Path(__file__).parent / "samples"
19
  def runs() -> list[dict]:
20
  out = []
21
  for d in sorted((SAMPLES / "runs").glob("*")):
22
- meta = json.loads((d / "meta.json").read_text()) if (d / "meta.json").exists() else {}
23
  out.append({"name": d.name, "title": meta.get("title", d.name), "started": meta.get("started", ""),
24
  "agent": meta.get("agent", ""), "rig": meta.get("rig", "")})
25
  return out
@@ -30,8 +30,8 @@ class Replay:
30
  self.dir = SAMPLES / "runs" / Path(name).name # no path tricks: a run name only
31
  if not (self.dir / "events.jsonl").exists():
32
  raise FileNotFoundError(name)
33
- self.meta = json.loads((self.dir / "meta.json").read_text()) if (self.dir / "meta.json").exists() else {}
34
- self.events = [json.loads(line) for line in (self.dir / "events.jsonl").read_text().splitlines() if line.strip()]
35
  self.publish, self.speed, self.max_gap = publish, speed, max_gap
36
  self.stopped = False
37
  self.thread = threading.Thread(target=self._run, daemon=True)
 
19
  def runs() -> list[dict]:
20
  out = []
21
  for d in sorted((SAMPLES / "runs").glob("*")):
22
+ meta = json.loads((d / "meta.json").read_text(encoding="utf-8")) if (d / "meta.json").exists() else {}
23
  out.append({"name": d.name, "title": meta.get("title", d.name), "started": meta.get("started", ""),
24
  "agent": meta.get("agent", ""), "rig": meta.get("rig", "")})
25
  return out
 
30
  self.dir = SAMPLES / "runs" / Path(name).name # no path tricks: a run name only
31
  if not (self.dir / "events.jsonl").exists():
32
  raise FileNotFoundError(name)
33
+ self.meta = json.loads((self.dir / "meta.json").read_text(encoding="utf-8")) if (self.dir / "meta.json").exists() else {}
34
+ self.events = [json.loads(line) for line in (self.dir / "events.jsonl").read_text(encoding="utf-8").splitlines() if line.strip()]
35
  self.publish, self.speed, self.max_gap = publish, speed, max_gap
36
  self.stopped = False
37
  self.thread = threading.Thread(target=self._run, daemon=True)
src/rangrez/server.py CHANGED
@@ -482,8 +482,8 @@ def samples() -> dict:
482
  order = SAMPLES / "order.txt"
483
  read = SAMPLES / "kurta.json" # how live SAM 3.1 read the sample photo, for visitors without the passcode
484
  return {"photo": "/api/samples/kurta.jpg", "concept": "kurta",
485
- "read": json.loads(read.read_text()) if read.exists() else None,
486
- "order": order.read_text().strip() if order.exists() else "", "runs": runs()}
487
 
488
 
489
  @app.get("/api/samples/kurta.jpg")
 
482
  order = SAMPLES / "order.txt"
483
  read = SAMPLES / "kurta.json" # how live SAM 3.1 read the sample photo, for visitors without the passcode
484
  return {"photo": "/api/samples/kurta.jpg", "concept": "kurta",
485
+ "read": json.loads(read.read_text(encoding="utf-8")) if read.exists() else None,
486
+ "order": order.read_text(encoding="utf-8").strip() if order.exists() else "", "runs": runs()}
487
 
488
 
489
  @app.get("/api/samples/kurta.jpg")
src/rangrez/static/index.html CHANGED
@@ -190,6 +190,9 @@
190
  .case-hero img { width: 100%; height: 100%; object-fit: cover; animation: pan 26s ease-in-out infinite alternate; transform-origin: 40% 60%; }
191
  @keyframes pan { from { transform: scale(1.04) translateX(0); } to { transform: scale(1.14) translateX(-3%); } }
192
  .case-hero figcaption { position: absolute; left: 14px; bottom: 12px; font-size: 12px; color: #fff; background: rgba(20, 14, 8, .55); padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(4px); }
 
 
 
193
  .case { max-width: 1060px; margin: 0 auto; padding: 4px 24px 60px; }
194
  .case h2.big { font: 700 34px/1.15 var(--serif); text-transform: none; letter-spacing: 0; color: var(--ink); margin: 18px 0 10px; }
195
  .case h3 { margin-top: 34px; font-size: 24px; }
@@ -380,6 +383,10 @@
380
  <div id="caseView" class="case" hidden>
381
  <figure class="case-hero"><img src="/static/dyehouse.jpg" alt="" loading="lazy">
382
  <figcaption>The world Rangrez is for: a small cotton dye house. An illustration made with Muse Image, not a photo.</figcaption></figure>
 
 
 
 
383
  <h2 class="big">A dye house's lab dip, in minutes instead of days, from a phone.</h2>
384
  <p>Before a garment order is dyed, the dye house dyes a small swatch, a <b>lab dip</b>, and sends it to the buyer for approval. A rejected dip means correct, re-dye, re-send: usually 2 to 4 rounds of several days each. Large mills shorten this with spectrophotometers and colour-matching software. The thousands of small dye houses and job workers in India's textile towns mostly rely on a colourist's eye and repeated trials.</p>
385
  <p>Rangrez runs the colourist's loop itself: pick a recipe, dye a strip, photograph it, measure it, correct it, until the cloth matches. Six Meta models each do one job in that loop.</p>
 
190
  .case-hero img { width: 100%; height: 100%; object-fit: cover; animation: pan 26s ease-in-out infinite alternate; transform-origin: 40% 60%; }
191
  @keyframes pan { from { transform: scale(1.04) translateX(0); } to { transform: scale(1.14) translateX(-3%); } }
192
  .case-hero figcaption { position: absolute; left: 14px; bottom: 12px; font-size: 12px; color: #fff; background: rgba(20, 14, 8, .55); padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(4px); }
193
+ .case .links { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
194
+ .case .links a { font: 600 14px var(--sans); padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel, #fff); color: var(--ink); text-decoration: none; }
195
+ .case .links a.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
196
  .case { max-width: 1060px; margin: 0 auto; padding: 4px 24px 60px; }
197
  .case h2.big { font: 700 34px/1.15 var(--serif); text-transform: none; letter-spacing: 0; color: var(--ink); margin: 18px 0 10px; }
198
  .case h3 { margin-top: 34px; font-size: 24px; }
 
383
  <div id="caseView" class="case" hidden>
384
  <figure class="case-hero"><img src="/static/dyehouse.jpg" alt="" loading="lazy">
385
  <figcaption>The world Rangrez is for: a small cotton dye house. An illustration made with Muse Image, not a photo.</figcaption></figure>
386
+ <p class="links"><a class="primary" href="https://youtu.be/g4Z30UhPtjA" target="_blank" rel="noopener">▶ Watch the 3-minute demo</a>
387
+ <a href="https://github.com/TusharTechs/rangrez" target="_blank" rel="noopener">Code on GitHub</a>
388
+ <a href="https://huggingface.co/TechTush/rangrez-glimmer-lora" target="_blank" rel="noopener">Glimmer weights</a>
389
+ <a href="https://huggingface.co/datasets/TechTush/rangrez-lab-dips" target="_blank" rel="noopener">Dataset</a></p>
390
  <h2 class="big">A dye house's lab dip, in minutes instead of days, from a phone.</h2>
391
  <p>Before a garment order is dyed, the dye house dyes a small swatch, a <b>lab dip</b>, and sends it to the buyer for approval. A rejected dip means correct, re-dye, re-send: usually 2 to 4 rounds of several days each. Large mills shorten this with spectrophotometers and colour-matching software. The thousands of small dye houses and job workers in India's textile towns mostly rely on a colourist's eye and repeated trials.</p>
392
  <p>Rangrez runs the colourist's loop itself: pick a recipe, dye a strip, photograph it, measure it, correct it, until the cloth matches. Six Meta models each do one job in that loop.</p>