Rangrez dashboard
Browse filesFiles changed (8)
11 unmodified lines12131415161714 unmodified lines32333411 unmodified lines# Rangrez: a self-driving dye labPick a colour and press **Start campaign**. Rangrez mixes a recipe, dyes a cotton strip in itssimulated lab (a hidden dye lot that differs from the supplier's model), photographs it like aphone would, measures it, and corrects itself until the cloth matches. Every dip photo is a14 unmodified linesOne lab, shared by everyone viewing: if a campaign is running, you are watching it.Code, hardware, firmware and evaluation: https://github.com/TusharTechs/rangrez11 unmodified lines121314151617181914 unmodified lines3435363711 unmodified lines# Rangrez: a self-driving dye lab▶ **[Watch the 3-minute demo](https://youtu.be/g4Z30UhPtjA)** · [A recorded live run](?replay=1) · [The 2-minute tour](?tour=1)Pick a colour and press **Start campaign**. Rangrez mixes a recipe, dyes a cotton strip in itssimulated lab (a hidden dye lot that differs from the supplier's model), photographs it like aphone would, measures it, and corrects itself until the cloth matches. Every dip photo is a14 unmodified linesOne lab, shared by everyone viewing: if a campaign is running, you are watching it.Code, hardware, firmware and evaluation: https://github.com/TusharTechs/rangrezOpen weights: https://huggingface.co/TechTush/rangrez-glimmer-lora · Dataset: https://huggingface.co/datasets/TechTush/rangrez-lab-dips
2 unmodified lines3456782 unmodified linesversion = "0.1.0"description = "A self-driving dye lab: Meta models match any colour on real cotton"readme = "README.md"authors = [{ name = "Tushar Agarwal", email = "tusharaggarwal274@gmail.com" }]2 unmodified lines34567892 unmodified linesversion = "0.1.0"description = "A self-driving dye lab: Meta models match any colour on real cotton"readme = "README.md"license = "Apache-2.0"authors = [{ name = "Tushar Agarwal", email = "tusharaggarwal274@gmail.com" }]
32 unmodified lines3334353637383932 unmodified linesdef firmware_limits(path: Path = FIRMWARE) -> dict[str, float]:"""The `const float MAX_*` limits and pump calibration, as compiled into the board."""src = path.read_text()limits = {k: float(v) for k, v in re.findall(r"const float (MAX_\w+) = ([\d.]+);", src)}limits["msPerMl"] = [float(v) for v in re.search(r"msPerMl\[5\] = \{([^}]*)\}", src).group(1).split(",")]return limits32 unmodified lines3334353637383932 unmodified linesdef firmware_limits(path: Path = FIRMWARE) -> dict[str, float]:"""The `const float MAX_*` limits and pump calibration, as compiled into the board."""src = path.read_text(encoding="utf-8")limits = {k: float(v) for k, v in re.findall(r"const float (MAX_\w+) = ([\d.]+);", src)}limits["msPerMl"] = [float(v) for v in re.search(r"msPerMl\[5\] = \{([^}]*)\}", src).group(1).split(",")]return limits
31 unmodified lines3233343536373817 unmodified lines5657585960616231 unmodified linesself.path = pathself.data = {"dye_set": PROFILE.key, "dips": [], "campaigns": []}if path is not None and path.exists():self.data = json.loads(path.read_text())@propertydef dips(self) -> list[dict]:17 unmodified linesreturnself.path.parent.mkdir(parents=True, exist_ok=True)tmp = self.path.with_suffix(".tmp")tmp.write_text(json.dumps(self.data))tmp.replace(self.path)def recent(self, n: int = RECENT_DIPS) -> list[tuple[np.ndarray, np.ndarray]]:31 unmodified lines3233343536373817 unmodified lines5657585960616231 unmodified linesself.path = pathself.data = {"dye_set": PROFILE.key, "dips": [], "campaigns": []}if path is not None and path.exists():self.data = json.loads(path.read_text(encoding="utf-8"))@propertydef dips(self) -> list[dict]:17 unmodified linesreturnself.path.parent.mkdir(parents=True, exist_ok=True)tmp = self.path.with_suffix(".tmp")tmp.write_text(json.dumps(self.data), encoding="utf-8")tmp.replace(self.path)def recent(self, n: int = RECENT_DIPS) -> list[tuple[np.ndarray, np.ndarray]]:
39 unmodified lines404142434445462 unmodified lines4950515253545539 unmodified lineswith self.lock:self.dir = self.root / f"{time.strftime('%Y-%m-%d_%H%M%S')}_{label}"self.dir.mkdir(parents=True, exist_ok=True)(self.dir / "meta.json").write_text(json.dumps(meta, indent=2, default=str))for name, data in self.pending:(self.dir / name).write_bytes(data)self.pending = []2 unmodified linesdef event(self, event: dict) -> None:if self.dir is None:returnwith self.lock, open(self.dir / "events.jsonl", "a") as f:f.write(json.dumps(event, default=str) + "\n")def save(self, name: str, data: bytes | str | dict) -> None:39 unmodified lines404142434445462 unmodified lines4950515253545539 unmodified lineswith self.lock:self.dir = self.root / f"{time.strftime('%Y-%m-%d_%H%M%S')}_{label}"self.dir.mkdir(parents=True, exist_ok=True)(self.dir / "meta.json").write_text(json.dumps(meta, indent=2, default=str), encoding="utf-8")for name, data in self.pending:(self.dir / name).write_bytes(data)self.pending = []2 unmodified linesdef event(self, event: dict) -> None:if self.dir is None:returnwith self.lock, open(self.dir / "events.jsonl", "a", encoding="utf-8") as f:f.write(json.dumps(event, default=str) + "\n")def save(self, name: str, data: bytes | str | dict) -> None:
18 unmodified lines192021222324254 unmodified lines303132333435363718 unmodified linesdef runs() -> list[dict]:out = []for d in sorted((SAMPLES / "runs").glob("*")):meta = json.loads((d / "meta.json").read_text()) if (d / "meta.json").exists() else {}out.append({"name": d.name, "title": meta.get("title", d.name), "started": meta.get("started", ""),"agent": meta.get("agent", ""), "rig": meta.get("rig", "")})return out4 unmodified linesself.dir = SAMPLES / "runs" / Path(name).name # no path tricks: a run name onlyif not (self.dir / "events.jsonl").exists():raise FileNotFoundError(name)self.meta = json.loads((self.dir / "meta.json").read_text()) if (self.dir / "meta.json").exists() else {}self.events = [json.loads(line) for line in (self.dir / "events.jsonl").read_text().splitlines() if line.strip()]self.publish, self.speed, self.max_gap = publish, speed, max_gapself.stopped = Falseself.thread = threading.Thread(target=self._run, daemon=True)18 unmodified lines192021222324254 unmodified lines303132333435363718 unmodified linesdef runs() -> list[dict]:out = []for d in sorted((SAMPLES / "runs").glob("*")):meta = json.loads((d / "meta.json").read_text(encoding="utf-8")) if (d / "meta.json").exists() else {}out.append({"name": d.name, "title": meta.get("title", d.name), "started": meta.get("started", ""),"agent": meta.get("agent", ""), "rig": meta.get("rig", "")})return out4 unmodified linesself.dir = SAMPLES / "runs" / Path(name).name # no path tricks: a run name onlyif not (self.dir / "events.jsonl").exists():raise FileNotFoundError(name)self.meta = json.loads((self.dir / "meta.json").read_text(encoding="utf-8")) if (self.dir / "meta.json").exists() else {}self.events = [json.loads(line) for line in (self.dir / "events.jsonl").read_text(encoding="utf-8").splitlines() if line.strip()]self.publish, self.speed, self.max_gap = publish, speed, max_gapself.stopped = Falseself.thread = threading.Thread(target=self._run, daemon=True)
481 unmodified lines482483484485486487488489481 unmodified linesorder = SAMPLES / "order.txt"read = SAMPLES / "kurta.json" # how live SAM 3.1 read the sample photo, for visitors without the passcodereturn {"photo": "/api/samples/kurta.jpg", "concept": "kurta","read": json.loads(read.read_text()) if read.exists() else None,"order": order.read_text().strip() if order.exists() else "", "runs": runs()}@app.get("/api/samples/kurta.jpg")481 unmodified lines482483484485486487488489481 unmodified linesorder = SAMPLES / "order.txt"read = SAMPLES / "kurta.json" # how live SAM 3.1 read the sample photo, for visitors without the passcodereturn {"photo": "/api/samples/kurta.jpg", "concept": "kurta","read": json.loads(read.read_text(encoding="utf-8")) if read.exists() else None,"order": order.read_text(encoding="utf-8").strip() if order.exists() else "", "runs": runs()}@app.get("/api/samples/kurta.jpg")
189 unmodified lines190191192193194195184 unmodified lines380381382383384385189 unmodified lines.case-hero img { width: 100%; height: 100%; object-fit: cover; animation: pan 26s ease-in-out infinite alternate; transform-origin: 40% 60%; }@keyframes pan { from { transform: scale(1.04) translateX(0); } to { transform: scale(1.14) translateX(-3%); } }.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); }.case { max-width: 1060px; margin: 0 auto; padding: 4px 24px 60px; }.case h2.big { font: 700 34px/1.15 var(--serif); text-transform: none; letter-spacing: 0; color: var(--ink); margin: 18px 0 10px; }.case h3 { margin-top: 34px; font-size: 24px; }184 unmodified lines<div id="caseView" class="case" hidden><figure class="case-hero"><img src="/static/dyehouse.jpg" alt="" loading="lazy"><figcaption>The world Rangrez is for: a small cotton dye house. An illustration made with Muse Image, not a photo.</figcaption></figure><h2 class="big">A dye house's lab dip, in minutes instead of days, from a phone.</h2><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><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>189 unmodified lines190191192193194195196197198184 unmodified lines383384385386387388389390391392189 unmodified lines.case-hero img { width: 100%; height: 100%; object-fit: cover; animation: pan 26s ease-in-out infinite alternate; transform-origin: 40% 60%; }@keyframes pan { from { transform: scale(1.04) translateX(0); } to { transform: scale(1.14) translateX(-3%); } }.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); }.case .links { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }.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; }.case .links a.primary { background: var(--ink); color: #fff; border-color: var(--ink); }.case { max-width: 1060px; margin: 0 auto; padding: 4px 24px 60px; }.case h2.big { font: 700 34px/1.15 var(--serif); text-transform: none; letter-spacing: 0; color: var(--ink); margin: 18px 0 10px; }.case h3 { margin-top: 34px; font-size: 24px; }184 unmodified lines<div id="caseView" class="case" hidden><figure class="case-hero"><img src="/static/dyehouse.jpg" alt="" loading="lazy"><figcaption>The world Rangrez is for: a small cotton dye house. An illustration made with Muse Image, not a photo.</figcaption></figure><p class="links"><a class="primary" href="https://youtu.be/g4Z30UhPtjA" target="_blank" rel="noopener">▶ Watch the 3-minute demo</a><a href="https://github.com/TusharTechs/rangrez" target="_blank" rel="noopener">Code on GitHub</a><a href="https://huggingface.co/TechTush/rangrez-glimmer-lora" target="_blank" rel="noopener">Glimmer weights</a><a href="https://huggingface.co/datasets/TechTush/rangrez-lab-dips" target="_blank" rel="noopener">Dataset</a></p><h2 class="big">A dye house's lab dip, in minutes instead of days, from a phone.</h2><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><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>
README.md+3
pyproject.toml+1
src/rangrez/esp32_emulator.py+1-1
src/rangrez/memory.py+2-2
src/rangrez/recorder.py+2-2
src/rangrez/replay.py+3-3
src/rangrez/server.py+2-2
src/rangrez/static/index.html+7