-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: initialize Sphinx Gallery (#2508)
* rename existing `_samples/` * conf * ignore * skimage * thumbnail * notes * dummy file * makedirs * header --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
85962a0
commit c62a58c
Showing
15 changed files
with
117 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
TorchMetrics' gallery | ||
===================== | ||
|
||
Welcome to a comprehensive guide on leveraging TorchMetrics, that facilitates the precise and consistent evaluation of machine learning models. As an integral tool for developers and researchers, TorchMetrics offers an array of metrics critical for assessing model performance across a variety of applications. Whether you are fine-tuning a neural network, comparing model iterations, or tracking performance improvements, this page provides a gallery of real-world applications where Torch Metrics can be effectively implemented. | ||
|
||
By touring through this application gallery, users can gain insights into how TorchMetrics is utilized across different sectors and scale settings, empowering them with the knowledge to implement metrics effectively in their own projects. Whether your interest lies in academic research or commercial product development, the examples provided here will help demonstrate the versatility and utility of Torch Metrics in enhancing machine learning model assessment. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Image domain | ||
============ | ||
|
||
Image-domain metrics are pivotal for gauging the performance of models in tasks like object detection, and segmentation. TorchMetrics provides a suite of specialized metrics designed for these purposes. Using these image-specific metrics from Torch Metrics helps in developing more precise and robust image-based models, ensuring that performance evaluations are both meaningful and directly applicable to practical vision tasks. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
Spatial Correlation Coefficient | ||
=============================== | ||
The Spatial Correlation Coefficient can be applied to compare the spatial structure of two images, which can be valuable in various domains such as medical imaging, remote sensing, and quality assessment in manufacturing or design processes. | ||
Let's consider a use case in medical imaging where Spatial Correlation Coefficient is used to compare the spatial correlation between a reference image and a reconstructed medical scan. | ||
This can be particularly relevant in evaluating the accuracy of image reconstruction techniques or assessing the quality of medical imaging data. | ||
""" | ||
|
||
# %% | ||
# Here's a hypothetical Python example demonstrating the usage of the Spatial Correlation Coefficient to compare two medical images: | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import torch | ||
from skimage.data import shepp_logan_phantom | ||
from skimage.transform import iradon, radon, rescale | ||
from torchmetrics.image import SpatialCorrelationCoefficient | ||
|
||
# %% | ||
# Create a Shepp-Logan phantom image | ||
phantom = shepp_logan_phantom() | ||
phantom = rescale(phantom, scale=512 / 400) # Rescaling to 512x512 | ||
|
||
# %% | ||
# Simulate projection data (sinogram) using Radon transform | ||
theta = np.linspace(0.0, 180.0, max(phantom.shape), endpoint=False) | ||
sinogram = radon(phantom, theta=theta) | ||
|
||
# %% | ||
# Perform reconstruction using the inverse Radon transform | ||
reconstruction = iradon(sinogram, theta=theta, circle=True) | ||
|
||
# %% | ||
# Display the results | ||
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(10, 4)) | ||
ax1.set_title("Original") | ||
ax1.imshow(phantom, cmap=plt.cm.Greys_r) | ||
ax2.set_title("Radon transform (Sinogram)") | ||
ax2.imshow(sinogram, cmap=plt.cm.Greys_r, extent=(0, 180, 0, sinogram.shape[0]), aspect="equal") | ||
ax3.set_title("Reconstruction from sinogram") | ||
ax3.imshow(reconstruction, cmap=plt.cm.Greys_r) | ||
fig.tight_layout() | ||
|
||
# %% | ||
# Convert the images to PyTorch tensors | ||
phantom_tensor = torch.from_numpy(phantom).float().unsqueeze(0).unsqueeze(0) | ||
reconstructed_tensor = torch.from_numpy(reconstruction).float().unsqueeze(0).unsqueeze(0) | ||
|
||
# %% | ||
# Calculating the Spatial Correlation Coefficient | ||
scc = SpatialCorrelationCoefficient() | ||
score = scc(preds=reconstructed_tensor, target=phantom_tensor) | ||
|
||
print(f"Spatial Correlation Coefficient between the images: {score}") | ||
fig.suptitle(f"Spatial Correlation Coefficient: {score:.5}", y=-0.01) |
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
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