forked from fastai/fastai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imports.py
59 lines (52 loc) · 1.92 KB
/
imports.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from IPython.lib.deepreload import reload as dreload
import PIL, os, numpy as np, math, collections, threading, json, bcolz, random, scipy, cv2
import pandas as pd, pickle, sys, itertools, string, sys, re, datetime, time, shutil, copy
import seaborn as sns, matplotlib
import IPython, graphviz, sklearn_pandas, sklearn, warnings, pdb
import contextlib
from abc import abstractmethod
from glob import glob, iglob
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
from itertools import chain
from functools import partial
from collections import Iterable, Counter, OrderedDict
from isoweek import Week
from pandas_summary import DataFrameSummary
from IPython.lib.display import FileLink
from PIL import Image, ImageEnhance, ImageOps
from sklearn import metrics, ensemble, preprocessing
from operator import itemgetter, attrgetter
from pathlib import Path
from distutils.version import LooseVersion
from matplotlib import pyplot as plt, rcParams, animation
from ipywidgets import interact, interactive, fixed, widgets
matplotlib.rc('animation', html='html5')
np.set_printoptions(precision=5, linewidth=110, suppress=True)
from ipykernel.kernelapp import IPKernelApp
def in_notebook(): return IPKernelApp.initialized()
def in_ipynb():
try:
cls = get_ipython().__class__.__name__
return cls == 'ZMQInteractiveShell'
except NameError:
return False
import tqdm as tq
from tqdm import tqdm_notebook, tnrange
def clear_tqdm():
inst = getattr(tq.tqdm, '_instances', None)
if not inst: return
try:
for i in range(len(inst)): inst.pop().close()
except Exception:
pass
if in_notebook():
def tqdm(*args, **kwargs):
clear_tqdm()
return tq.tqdm(*args, file=sys.stdout, **kwargs)
def trange(*args, **kwargs):
clear_tqdm()
return tq.trange(*args, file=sys.stdout, **kwargs)
else:
from tqdm import tqdm, trange
tnrange=trange
tqdm_notebook=tqdm