import svetoviz_webgpu as sv
tokenizer = GPT2Tokenizer.from_pretrained('gpt2', device_map="cpu")
model = GPT2LMHeadModel.from_pretrained('gpt2', device_map="cpu")
def terminal_callback(buffer, message, images, files):
text = message # "Replace me by any text you'd like."
buffer.send_user_message(text)
inputs = tokenizer(text, return_tensors="pt")
# Generate continuation
outputs = model.generate(**inputs, max_new_tokens=50)
# Decode to string
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(decoded)
buffer.send_system_message(decoded)
sv.model(
model=model,
tokenizer=tokenizer,
terminal_callback=terminal_callback
)
Models
Load models directly from huggingface.
import svetoviz_webgpu as sv
image_processor = DetrImageProcessor.from_pretrained(
"facebook/detr-resnet-50",
revision="no_timm",
device_map="cpu")
model = DetrForObjectDetection.from_pretrained(
"facebook/detr-resnet-50",
revision="no_timm",
device_map="cpu")
def terminal_callback(buffer, message, images, files):
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = image_processor(images=image, return_tensors="pt")
outputs = model(**inputs)
buffer.send_system_message("processed")
sv.model(
model=model,
image_processor=image_processor,
terminal_callback=terminal_callback
)
import svetoviz_webgpu as sv
model = YolosForObjectDetection.from_pretrained('hustvl/yolos-tiny', device_map="cpu")
image_processor = YolosImageProcessor.from_pretrained("hustvl/yolos-tiny", device_map="cpu")
def terminal_callback(buffer, message, images, files):
image = Image.open("sample_image.jpg").convert("RGB")
inputs = image_processor(images=image, return_tensors="pt")
outputs = model(**inputs)
buffer.send_system_message("processed")
sv.model(
model=model,
image_processor=image_processor,
terminal_callback=terminal_callback
)
Interact with the model to collect the activations. Recognized modules provide mappings just like pytorch modules.
Use the settings window to modify various rendering aspects of your scene. You can adjust matrix settings to control the visual representation of data values when viewed at close range.
You can adjust layouts, spacing, padding, and spread dynamically, mirroring the configuration capabilities available in the Views API.
You can customize the appearance of specific modules by selecting colors and toggling the rendering mode to display groups as either lines or cubes.