This file contains hidden or 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
| #!/usr/bin/env bash | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| # archive-repos.sh | |
| # | |
| # Archive GitHub repos listed in one or more CSV files. Reads the first | |
| # column (repo slug) of each CSV, deduplicates across files, and calls | |
| # `gh repo archive --yes` on each. | |
| # | |
| # Defaults to DRY RUN — prints what would happen but doesn't touch anything. | |
| # Set APPLY=1 to actually archive. Note: GitHub's API does NOT support |
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| # list-inactive.sh | |
| # | |
| # Find repos in an org/user account with no push activity since a cutoff date, | |
| # so they're candidates for archiving. | |
| # | |
| # Uses the pushedAt field from a single GitHub API call — fast (one request), | |
| # no per-repo lookup. Computes days since last push and sorts the output | |
| # from least stale (recent) to most stale (oldest). |
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| # list-clean-forks.sh | |
| # | |
| # Find forks in an org/user account that never diverged from their upstream, | |
| # so they're safe to archive or delete. | |
| # | |
| # For each non-archived fork, compares the fork's default branch against the | |
| # upstream's default branch via the GitHub compare API. A fork is "clean" if | |
| # ahead_by == 0 — i.e., zero commits on top of upstream. |
This file contains hidden or 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 glob | |
| import torch | |
| import scipy | |
| import random | |
| import matplotlib.pyplot as plt | |
| from PIL import Image | |
| from torchvision import transforms | |
| from train import LitClassification, ClassificationData | |
| # load test association to the numerical labels |
This file contains hidden or 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 torch.optim as optim | |
| from torch.utils.data import DataLoader | |
| from torchvision import models, datasets, ops | |
| from torchvision.transforms import v2 as transforms | |
| import pytorch_lightning as pl | |
| # Step 1a: Define the transform | |
| transform = transforms.Compose([ |
This file contains hidden or 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
| name: Update git submodules | |
| on: | |
| pull_request: | |
| branches: ["main"] | |
| paths: | |
| - ".github/workflows/ci-update-submodules.yml" | |
| schedule: | |
| # on Sundays | |
| - cron: "0 0 * * 0" |
This file contains hidden or 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
| name: Sample build | |
| on: | |
| - push | |
| - pull_request | |
| - workflow_dispatch | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: |
This file contains hidden or 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
| preds = [] | |
| # move model to GPU for faster inference and set evaluation | |
| model.cuda().eval() | |
| for imgs, names in dm.test_dataloader(): | |
| # for the prediction we do not need gradients | |
| with torch.no_grad(): | |
| onehots = model(imgs.cuda()).cpu() | |
| # aggregate particular preditions | |
| for oh, name in zip(onehots, names): | |
| lbs = dm.onehot_to_labels(oh) |
This file contains hidden or 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 pytorch_lightning import Trainer | |
| from kaggle_plantpatho.data import PlantPathologyDM | |
| from kaggle_plantpatho.models import LitResnet, MultiPlantPathology | |
| # create DataModule with training/validation split | |
| dm = PlantPathologyDM(batch_size=98) | |
| # initialize ResNet50 network | |
| net = LitResnet(arch='resnet50', num_classes=dm.num_classes) | |
| # initialize PL module with ResNet50 | |
| model = MultiPlantPathology(model=net, lr=6e-4) |
This file contains hidden or 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
| fig = plt.figure(figsize=(3, 7)) | |
| for imgs, lbs in dm.val_dataloader(): | |
| # some stats about the batch - label distribution | |
| print(f'batch labels: {torch.sum(lbs, axis=0)}') | |
| print(f'image size: {imgs[0].shape}') | |
| # similar as above show just first images from the batch | |
| for i in range(3): | |
| ax = fig.add_subplot(3, 1, i + 1, xticks=[], yticks=[]) | |
| ax.imshow(np.rollaxis(imgs[i].numpy(), 0, 3)) | |
| ax.set_title(lbs[i]) |
NewerOlder