Skip to main content

One line functions for common tasks

Project description

Utilities for simple needs

torch snippets does a lot of default importing for you

Whether it is numpy, pandas, matplotlib or the useful functions that are mentioned below Simply call

from torch_snippets import *

All the imports are lightweight and thus should not take more than a couple of seconds

Auxiliary Functions

There are simple functions that are overloaded to take inputs and perform repetitive tasks that usually take a few lines to write

Images

show, inspect, Glob, read, resize, rotate

Files and Paths

stem, Glob, parent, name, fname,

makedir, zip_files, unzip_file,

find, extn,

readlines, writelines

Lists

L, flatten

Dump and load python objects

loaddill,dumpdill

Misc

Tqdm, Timer, randint, Logger

Sets

unique, diff, choose, common

Pytorch Modules

Reshape and Permute (nn.Modules)

Report as Pytorch Lightning Callback

LightningReport

Charts

Chart from altair

and many more to come...

Install

pip install torch_snippets

Usage

%time from torch_snippets import *
CPU times: user 1.79 s, sys: 672 ms, total: 2.46 s
Wall time: 2.62 s
dir()
['AttrDict',
 'B',
 'BB',
 'Blank',
 'C',
 'Chart',
 'DataLoader',
 'Dataset',
 'Debug',
 'E',
 'Excep',
 'F',
 'Float',
 'Glob',
 'Image',
 'ImportEnum',
 'In',
 'Inf',
 'Info',
 'Int',
 'L',
 'LightningReport',
 'NullType',
 'Out',
 'P',
 'PIL',
 'Path',
 'Permute',
 'PrettyString',
 'Report',
 'Reshape',
 'Self',
 'ShowPrint',
 'Stateful',
 'Str',
 'StrEnum',
 'T',
 'Timer',
 'Tqdm',
 'Warn',
 '_',
 '__',
 '___',
 '__builtin__',
 '__builtins__',
 '__doc__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 '_dh',
 '_i',
 '_i1',
 '_i2',
 '_ih',
 '_ii',
 '_iii',
 '_oh',
 'add',
 'add_props',
 'alt',
 'anno_ret',
 'annotations',
 'arg0',
 'arg1',
 'arg2',
 'arg3',
 'arg4',
 'argnames',
 'argwhere',
 'attrdict',
 'basic_repr',
 'bbfy',
 'bind',
 'camel2snake',
 'charts',
 'choose',
 'chunked',
 'class2attr',
 'common',
 'compose',
 'copy_func',
 'crop_from_bb',
 'custom_dir',
 'cv2',
 'cycle',
 'defaults',
 'detuplify',
 'device',
 'df2bbs',
 'diff',
 'display',
 'dumpdill',
 'enlarge_bbs',
 'eq',
 'even_mults',
 'exec_local',
 'exit',
 'extn',
 'fastcores',
 'fastuple',
 'filter_dict',
 'filter_ex',
 'filter_keys',
 'filter_values',
 'find',
 'first',
 'flatten',
 'fname',
 'fname2',
 'ge',
 'gen',
 'get_class',
 'get_ipython',
 'getattrs',
 'glob',
 'groupby',
 'gt',
 'hasattrs',
 'ifnone',
 'ignore_exceptions',
 'in_',
 'inspect',
 'instantiate',
 'inum_methods',
 'is_',
 'is_array',
 'is_not',
 'isdir',
 'jitter',
 'last_index',
 'le',
 'line',
 'lines',
 'listify',
 'load_torch_model_weights_to',
 'loaddill',
 'loader',
 'logger',
 'lt',
 'lzip',
 'makedir',
 'map_ex',
 'maps',
 'maybe_attr',
 'md5',
 'merge',
 'mk_class',
 'mul',
 'ne',
 'nested_attr',
 'nested_idx',
 'nn',
 'not_',
 'now',
 'np',
 'null',
 'num_cpus',
 'num_methods',
 'nunique',
 'optim',
 'os',
 'otherwise',
 'pad',
 'parent',
 'partialler',
 'patch',
 'patch_property',
 'patch_to',
 'pd',
 'pdb',
 'pdfilter',
 'pl',
 'plt',
 'properties',
 'puttext',
 'quit',
 'rand',
 'randint',
 'range_of',
 're',
 'read',
 'readPIL',
 'readlines',
 'rect',
 'remove_duplicates',
 'rename_batch',
 'renumerate',
 'replicate',
 'resize',
 'risinstance',
 'rnum_methods',
 'rotate',
 'save_torch_model_weights_from',
 'see',
 'set_logging_level',
 'setattrs',
 'setify',
 'show',
 'shrink_bbs',
 'snake2camel',
 'sorted_ex',
 'stem',
 'stems',
 'stop',
 'store_attr',
 'str_enum',
 'sub',
 'subplots',
 'sys',
 'th',
 'to_absolute',
 'to_relative',
 'tonull',
 'torch',
 'torch_loader',
 'torchvision',
 'tqdm',
 'trange',
 'transforms',
 'true',
 'truediv',
 'try_attrs',
 'tuplify',
 'type_hints',
 'typed',
 'uint',
 'unique',
 'uniqueify',
 'unzip_file',
 'using_attr',
 'val2idx',
 'with_cast',
 'wrap_class',
 'write',
 'writelines',
 'xywh2xyXY',
 'zip_cycle',
 'zip_files']

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torch_snippets-0.499.23.tar.gz (49.3 kB view details)

Uploaded Source

Built Distribution

torch_snippets-0.499.23-py3-none-any.whl (55.4 kB view details)

Uploaded Python 3

File details

Details for the file torch_snippets-0.499.23.tar.gz.

File metadata

  • Download URL: torch_snippets-0.499.23.tar.gz
  • Upload date:
  • Size: 49.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.13.0 pkginfo/1.8.2 requests/2.28.2 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.9.9

File hashes

Hashes for torch_snippets-0.499.23.tar.gz
Algorithm Hash digest
SHA256 b4d3181c795a174a8828e46ea0e6acb379f195db1f065b321104d449ecc23152
MD5 8ad23affbb360acd583bf8ac43e7de76
BLAKE2b-256 12205a9595e193d1fc2c7c4a5ed9aaa6804af7c255f175eb320d31e280875253

See more details on using hashes here.

File details

Details for the file torch_snippets-0.499.23-py3-none-any.whl.

File metadata

  • Download URL: torch_snippets-0.499.23-py3-none-any.whl
  • Upload date:
  • Size: 55.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.13.0 pkginfo/1.8.2 requests/2.28.2 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.9.9

File hashes

Hashes for torch_snippets-0.499.23-py3-none-any.whl
Algorithm Hash digest
SHA256 ab72b881eafe74831e7714926ad85a6b2bda7b7454806878bf280a426d6a86a0
MD5 6c2b528d70457cf0aa4bf1f7b380d70c
BLAKE2b-256 0bf85fd1515dbdbd82d9a2fc6149a212f21ae25bc315f79d08a5be08c43212c7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page