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
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 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 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 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 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]) |
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 os, tqdm, glob | |
import multiprocessing as mproc | |
ls_images = glob.glob("plant-pathology/train_images/*.jpg") | |
print(f'found images: {len(ls_images)}') | |
def _convert(pimg: str): | |
# it can be replaced by opencv implementation... | |
os.system(f'convert -resize 640 point {pimg} {pimg}') |
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 pydicom | |
from pydicom.pixel_data_handlers import apply_voi_lut | |
# load the DICOM file | |
dicom = pydicom.dcmread(dicom_path) | |
# extract the image bitmap | |
img = apply_voi_lut(dicom.pixel_array, dicom) | |
import matplotlib.pyplot as plt |
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
""" | |
Make a simple repository statistic about user contributions. | |
## Resources | |
- https://developer.github.com/v3/pulls/ | |
- http://zetcode.com/python/requests/ | |
- https://developer.github.com/v3/#authentication | |
**Requirements:** | |
``` |
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 string | |
import random | |
__version__ = '0.1.1j' | |
DEFAULT = 0.5 | |
def jirkify(message, jirkaness=DEFAULT): | |
""" traslation to spoken/written form |