*This is a submission for [DEV's Summer Bug Smash: Smash Stories](https://dev.to/bugsmash) powered by [Sentry](https://sentry.io/).*

작성자

카테고리:

← 피드로
DEV Community · Sachitt A V · 2026-07-22 개발(SW)

The Texture That Vanished

I’m 17 and I built a 3D reconstruction pipeline called CODA Forge — it takes a phone rotation video and outputs a photorealistic 3D human model. 18 stages, CPU-only, no cloud. I was proud of it.

Then I exported a GLB file with texture and… it was grey. No texture. Just a flat grey mesh.

I spent 3 hours debugging before I found it. One line.

baseColorTexture=None

Enter fullscreen mode Exit fullscreen mode

That’s it. The _export_textured_glb method accepted a texture_path parameter, the caller checked if the file existed, everything looked correct. But inside the method, the texture was hardcoded to None. The parameter was accepted, validated, and then completely ignored.

The fix was two lines:

img = PILImage.open(texture_path)
baseColorTexture=img

Enter fullscreen mode Exit fullscreen mode

But the real lesson was: the code looked correct. The function signature said it took a texture. The caller passed a texture. The validation passed. The export succeeded. It just silently dropped the texture and returned a grey mesh. No error, no warning, no indication anything was wrong.

The Tokenizer That Never Cached

Same week, I was profiling my transformer’s generation speed. Something felt slow.

I added timing to the tokenizer calls and found this: the BPE tokenizer was being loaded from disk on every single token generation. For a 256-token output, that’s 256 file reads. Each one opens the JSON file, parses it, builds the vocabulary, and initializes the encoder.

The code looked like this:

def _tokenize(text, vocab_size):
    tok_path = Path("data/bpe_tokenizer.json")
    if tok_path.exists():
        tok = load_tokenizer(str(tok_path))  # Loaded EVERY call
        return tok.encode(text)

Enter fullscreen mode Exit fullscreen mode

Two functions (_tokenize and _detokenize) both independently loaded the same tokenizer on every call. No caching. No shared state.

Fixed with functools.lru_cache:

@lru_cache(maxsize=1)
def _get_tokenizer(tokenizer_path="data/bpe_tokenizer.json"):
    tok_path = Path(tokenizer_path)
    if tok_path.exists():
        return load_tokenizer(str(tok_path))
    return None

Enter fullscreen mode Exit fullscreen mode

One load. Cached forever. 256x fewer file reads.

The Call That Did Nothing

Third one was in my rotation-scan pipeline. There was this:

if weight_kg is not None and weight_kg > 0:
    estimate_body_volume(ellipse_params, lengths_cm)           # Result thrown away
    estimate_body_volume(ellipse_params, lengths_cm, weight_kg=weight_kg)

Enter fullscreen mode Exit fullscreen mode

The first call computed volume without weight calibration. The result was never stored, never used, never returned. Then the second call recomputed everything with weight calibration. The first call was pure waste.

I stared at this for 10 minutes trying to understand if there was some side effect I was missing. There wasn’t. It was just a leftover from an earlier refactor where the first call used to do something.

What I Learned

  1. Silent bugs are the worst bugs. The texture export “worked” — it produced a file. It just produced the wrong file. No exception, no traceback, no error message.

  2. Profile before you optimize. The tokenizer thing looked fine in code review. Only profiling revealed the 256x redundancy.

  3. Dead code lies. The redundant estimate_body_volume call looked intentional. It wasn’t. It was just… there.

All three fixes are live, CI-passing across Python 3.10, 3.11, and 3.12.

GitHub: https://github.com/Sachitt-AV-08/coda-forge-3d
GitHub: https://github.com/Sachitt-AV-08/bhaasm-transformer
GitHub: https://github.com/Sachitt-AV-08/rotation-scan-3d

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다