{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Show4DSTEM in Google Colab\n", "\n", "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/?url=https%3A%2F%2Fhuggingface.co%2Fdatasets%2Fbobleesj%2Fquantem-data%2Fresolve%2Fmain%2Fnotebooks%2Fshow4dstem_colab.ipynb)\n", "\n", "Open a 4D-STEM dataset in your browser - **no install, no GPU setup**. Runs on Colab's\n", "Open a 4D-STEM dataset in your browser - **no install, no GPU setup**. On Colab's free **Tesla T4**, Show4DSTEM runs on the **GPU via PyTorch (CUDA)** - NumPy is only the input format; it is uploaded to the GPU. (On a CPU-only runtime it falls back to CPU.)\n", "any runtime (CPU or GPU).\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Install (one cell)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!pip install -U -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \"quantem.widget>=0.0.1rc0\" huggingface_hub\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. Download a sample + open it\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from quantem.widget import Show4DSTEM\n", "from quantem.widget.io import download\n", "\n", "path = download('gold_512_npy_bin4') # ~25 MB from Hugging Face\n", "data = np.load(f'{path}/data.npy') # (512, 512, 48, 48) 4D-STEM\n", "Show4DSTEM(data)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Interact:** drag the detector ROI (left) -> the virtual image (right) updates live.\n", "Drag the scan cursor on the virtual image -> the diffraction pattern follows your finger.\n", "\n", "To use your own data, upload an Arina `*_master.h5` and run\n", "`Show4DSTEM(load('your_master.h5', det_bin=2))` (`from quantem.widget import load`).\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" }, "accelerator": "GPU", "colab": { "provenance": [], "gpuType": "T4" } }, "nbformat": 4, "nbformat_minor": 5 }