Skip to content

Instantly share code, notes, and snippets.

View tmabraham's full-sized avatar
💻
Researching deep learning

Tanishq Abraham tmabraham

💻
Researching deep learning
View GitHub Profile
@tmabraham
tmabraham / consistency-miniai-model-comparison.ipynb
Created April 10, 2023 09:42
comparing consistency model performance of miniai model with batchnorm or groupnorm
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from timm import create_model
from fastai.vision.learner import _add_norm
class TimmBody(nn.Module):
def __init__(self, arch:str, pretrained:bool=True, cut=None, n_in:int=3):
super().__init__()
model = create_model(arch, pretrained=pretrained, num_classes=0, in_chans=n_in)
if isinstance(cut, int): self.model = nn.Sequential(*list(model.children())[:cut])
elif callable(cut): self.model = cut(model)
elif cut is None: self.model = model

For each function/class please check the following:

  • Is every argument on a new line, unless it's a self or cls keyword?
  • Is it formatted like this? (Pay attention to the location of the arguments on the newline and the closing parentheses):
def __init__(self, 
    a, 
    b, 
    c
)
import gradio as gr
import fastai
import skimage
learn = load_learner('export.pkl')
labels = learn.dls.vocab
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
@tmabraham
tmabraham / tpu_distributed_fastai.py
Last active April 25, 2020 03:57
Using fastai on the TPU (draft 1)
import warnings
warnings.filterwarnings('ignore')
import torch_xla
import torch_xla.distributed.data_parallel as dp
import torch_xla.utils.utils as xu
import torch_xla.core.xla_model as xm
import torch_xla.distributed.parallel_loader as pl
import torch_xla.distributed.xla_multiprocessing as xmp
import torch