I build WebGPU PyTorch debugger, dataset browser and NumPy viewer

piogryko1 pts0 comments

Svetoviz

array_inspector.py

NumPy Inspector

Visualize any NumPy array with instant dimension awareness. Support for high-dimensional, large arrays.

import svetoviz_webgpu as sv

data = np.random.rand(4, 4, 32, 32).astype(np.float32)

sv.array(data, gap_size=10)<br>Learn More

pytorch_debugger.py

PyTorch Debugger

Directly load your PyTorch module, interact, and debug activations in real-time.

import svetoviz_webgpu as sv

img = Image.open("sample_image.jpg").convert("RGB")<br>img_np = np.array(img).astype(np.float32) / 255.0

# Rearrange from (H, W, C) to (C, H, W) and add batch dim<br>input_tensor = torch.from_numpy(img_np).permute(2, 0, 1).unsqueeze(0)

# 2. Define the 2D Convolutional module<br>conv2d = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, stride=1, padding=1)

def terminal_callback(buffer, message, images, files):<br># 3. Process the image through the module<br>output = conv2d(input_tensor)

# Log the feature map shape to the Svetoviz terminal<br>buffer.send_system_message(f"Processed image. Shape: {list(output.shape)}")

# 4. Start the interactive session<br>sv.pytorch(module=conv2d, terminal_callback=terminal_callback)<br>Learn More

model_viewer.py

Model Analysis

Deep-dive into model architecture. Explore layers down to a single parameter.

import svetoviz_webgpu as sv

image_processor = DetrImageProcessor.from_pretrained(<br>"facebook/detr-resnet-50",<br>revision="no_timm",<br>device_map="cpu")<br>model = DetrForObjectDetection.from_pretrained(<br>"facebook/detr-resnet-50",<br>revision="no_timm",<br>device_map="cpu")

sv.model(<br>model=model,<br>image_processor=image_processor<br>Learn More

model_debug.py

Model Debugger

Interact with your model and investigate activations in real-time.

import svetoviz_webgpu as sv

tokenizer = GPT2Tokenizer.from_pretrained('gpt2', device_map="cpu")<br>model = GPT2LMHeadModel.from_pretrained('gpt2', device_map="cpu")

def terminal_callback(buffer, message, images, files):<br>text = message # "Replace me by any text you'd like."<br>buffer.send_user_message(text)<br>inputs = tokenizer(text, return_tensors="pt")

# Generate continuation<br>outputs = model.generate(**inputs, max_new_tokens=50)

# Decode to string<br>decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)<br>buffer.send_system_message(decoded)

sv.model(<br>model=model,<br>tokenizer=tokenizer,<br>terminal_callback=terminal_callback<br>Learn More

dataset_handler.py

Dataset Explorer

Efficiently stream and visualize large-scale HuggingFace datasets from local storage or remote server.

import svetoviz_webgpu as sv

hf_name = "eltorio/ROCOv2-radiology"<br>dataset = load_dataset(hf_name, split="train")<br>view = DatasetView(<br>name=hf_name,<br>dataset=dataset,<br>image_columns=["image"],<br>cell_width=400,<br>cell_height=400<br>sv.save_to_disc(view=view,<br>compression="png_0",<br>directory=f"/Volumes/Untitled/{hf_name}")

sv.load_from_disc(directory=f"/Volumes/Untitled/{hf_name}")<br>Learn More

image_browser.py

Image Browser

Browse through massive collections of images regardless of resolution.

import svetoviz_webgpu as sv

view = DirectorySpiralView(directory="/Desktop/nasaimages")

sv.save_to_disc(view=view,<br>compression="jpeg_0",<br>directory="/Volumes/Untitled/universe")

sv.load_from_disc(directory="/Volumes/Untitled/universe")<br>Learn More

Installation

Guide

Explore installation guides and user manuals for Svetoviz

Next

model import svetoviz_webgpu learn terminal_callback view

Related Articles