import torch
import torchio as tio
image4d = tio.Resample()(tio.datasets.FPG().dmri)
collater = torch.utils.data.DataLoader([image4d])
batch = next(iter(collater))
tensor = batch[tio.DATA].float()
dropped = torch.nn.Dropout3d()(tensor)
for i, channel in enumerate(dropped[0]):
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /// script | |
# requires-python = ">=3.12" | |
# dependencies = [ | |
# "einops", | |
# "loguru", | |
# "numpy", | |
# "pillow", | |
# "procex", | |
# "torch", | |
# "transformers", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PYTHON_VERSION="3.13" | |
tmp_dir=$(mktemp -d) | |
uv init \ | |
--bare \ | |
--quiet \ | |
--python $PYTHON_VERSION \ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Convert the input of day 12 of Advent of Code 2022 to an STL file. | |
To install requirements, run: | |
pip install scikit-image numpy-stl | |
Usage: | |
python input_to_mesh.py input.txt output.stl | |
Example content of input.txt: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torchio as tio | |
from einops import rearrange | |
rows = 16 | |
cols = 28 | |
dataset = tio.datasets.OrganMNIST3D('train') | |
batch_size = rows * cols | |
loader = torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=True) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import torch | |
import torchvision | |
import numpy as np | |
from PIL import Image | |
import torchio as tio | |
from tqdm import trange | |
output_dir = Path('/tmp/transformed') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder