• Stars
    star
    475
  • Rank 91,835 (Top 2 %)
  • Language
    Python
  • Created almost 7 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tool-box for efficient build and debug in Python. Especially for Scientific Computing and Computer Vision.

Language : English Chinese


Box-X

Hack Python and Vision
A Tool-box for Efficient Build and Debug in Python. Especially for Scientific Computing and Computer Vision.

Code with ❤︎ by DIYer22 and contributors


1. Introduce

Box-X is a Tool-box for Efficient Build and Debug in Python.

Especially for Scientific Computing and Computer Vision.

So, all Tools are divided into 2 parts by wether the tool is general used:

  • General Python Tool: Tools could be used anywhere in Python

  • Scientific Computing and Computer Vision Tool: Those tools are useful in Scientific Computing and Computer Vision field

P.S. boxx supports both Python 2/3 on Linux | macOS | Windows with CPython | IPython | Spyder | Notebook environment.

2. Install

pip install boxx

3. Tutorial

Box-X's Tutorial is a Jupyter Notebook file

There are 3 methods to run or view this Notebook file

Method 1: Executable Interactive Online Notebook

We use Binder to run Tutorial Notebook in an executable interactive online jupyer environment.
That's mean you can run code in notebook rightnow in your browser without download or install anything.

Method 2: Download and Run at Local

git clone https://github.com/DIYer22/boxx
cd boxx/
python setup.py install
jupyter notebook

Then open ./tutorial_for_boxx.ipynb in notebook.

Method 3: Static Noetbook

Just view the Tutorial Notebook.

4. Examples

Examples are divided into 2 parts too.

General Python Tool on left, Scientific Computing and Computer Vision Tool on right.

💡 Note:

  • Click the image will see more clearer image, and if image is GIF, GIF will be replayed
  • The following content is layout of desktop browser, if you are viewing through a mobile browser, it is recommended to visit => Static Tutorial

General Python Tool


p/x is better way to print(x)

p/x will print(x) and return x click to restart GIF and see more clearer GIF
💡 Note: p/x is easy to print value in expression.






▶ Use g.name = x or g.name/x to transport variable to Python interactive console

click to restart GIF and see more clearer GIF
💡 Note:

  • gg is the meaning of "to Global and log", has same usage as g, but gg will print the transported variable.
  • if variable name exists in console before, the variable's value will be covered by new value.




g() to transport all vars that in the function to Python interactive console

click to restart GIF and see more clearer GIF
💡 Note: g() is a useful tool for debug. import boxx.g is convenient way to use g() instead of from boxx import g;g()(import boxx.gg is avaliable too)






with p, with g, with gg are mulit variables version of p, g, gg that work under "with statement"

Only act on interested variables which is under "with statement" click to restart GIF and see more clearer GIF
💡 Note:

  • with p, with g, with gg only act on assignment variables under "with statement".

  • If variable's name exists in locals() before and id(variable) not change ,variable may not be detected


Scientific Computing and Computer Vision

Useful tools in Scientific Computing and Computer Vision field. All tools support array-like types, include numpy, torch.tensor, mxnet.ndarray, PIL.Image .etc

💡 Note: If you are using ssh to execute code on a remote server, it is recommended that ssh plus -X make visualized plt charts can be transferred to the local and display, like ssh -x user@host.


loga to visualization matrix and tensor

loga is short of "log array", loga will show many attributes of array-like object. click to restart GIF and see more clearer GIF
💡 Note: loga analysis array-like object by it's shape, max, min, mean, and distribute. Support numpy, torch.tensor, mxnet.ndarray, PIL.Image .etc






show is easy to do imshow, even images are in complex struct

show could find every image in complex struct and imshow they. click to restart GIF and see more clearer GIF
💡 Note: if args inculde function(like torgb). those functions will process all numpys befor imshow.






tree for visualization complex struct

like tree command in shell, boxx.tree could visualization any struct in tree struct view. click to restart GIF and see more clearer GIF
💡 Note: tree support types include list, tuple, dict, numpy, torch.tensor/Dataset/DataLoader, mxnet.ndarray, PIL.Image.etc


boxx debug tool matrix

How many vars \ Operation print transport print & transport
Single variable p/x g.name/x gg.name/x
Multi variables with p: with g: with gg:
All locals() p() g() gg()
All locals()_2 import boxx.p import boxx.g import boxx.gg

💡 Note:

  • transport mean "transport variable to Python interactive console"
  • All locals() mean operation will act on all variables in the function or module
  • All locals()_2 : when boxx are not imported, import boxx.{operation} is a convenient way to execution operation


what to know "What's this?"

click to restart GIF and see more clearer GIF
💡 Note: what(x) will show "what is x?" by pretty print it's Self, Document, Father Classes, Inner Struct and Attributes. It is a supplement of help(x).


timeit is convenient timing tool

click to restart GIF and see more clearer GIF
💡 Note: timeit will timing code block under "with statement" and print spend time in blue color.


mapmp is Multi Process version of map

mapmp is the meaning of "MAP for Multi Process", has the same usage as map but faster.
click to restart GIF and see more clearer GIF
💡 Note:

  • pool parameter in mapmp mean the number of Process, the default is the number of CPUs in the system.
  • In multi process programs, display processing progress is troublesome. printfreq parameter in mapmp can handle this problem.
  • Like map, mapmp support muliti args to as input to function, like mapmp(add, list_1, list_2).
    • It's better to run multi process under __name__ == '__main__' environment.
  • If you speed up the numpy program, note that in the MKL version of numpy, multiple processes will be slower. You can run boxx.testNumpyMultiprocessing() to test how friendly the current environment is to a multi-process numpy.


heatmap to show the time heat map of your code

click to restart GIF and see more clearer GIF
💡 Note: heatmap also support python code string.


performance could statistic function calls and visualize code performance

click to restart GIF and see more clearer GIF
💡 Note: performance also support python code string.


5. Acknowledgments

  • Thanks to Xiaodong Xu, Guodong Wu, Haoqiang Fan, Pengfei Xiong for their suggestions
  • I develop boxx in Spyder IDE, Spyder is a awesome Scientific Python Development Environment with Powerful Qt-IPython
  • performance is supported by SnakeViz
  • heatmap is supported by csurfer/pyheat

More Repositories

1

bpycv

Computer vision utils for Blender (generate instance annoatation, depth and 6D pose by one line code)
Python
464
star
2

add_service

🚀 Effortlessly create and manage systemd startups with just one command.
Python
65
star
3

hik_camera

Easy-to-use Python API for Hikrobot Ethernet Industrial Camera (Pythonic 风格的海康网口工业相机 SDK)
Python
62
star
4

retail_product_checkout_tools

Tools for "Retail Product Checkout Dataset"(RPC)
Python
38
star
5

calibrating

Calibrate camera's intrinsic/extristric, and build stereo depth camera with OpenCV python.
Python
33
star
6

smartImgProcess

手工实现的智能图片处理系统 包含基础的图片处理功能 各类滤波 seam carving算法 以及结合精细语义分割信息 实现智能去除目标的功能
Python
27
star
7

process_raw

A python package to process raw and dng file, supporting demosaicing with gamma correction.
Python
25
star
8

auto_merge_ppt

自动排序并合并ppt
Python
10
star
9

ShowFoldersSize

Windows 上查看文件夹大小及文件结构
Python
10
star
10

zcs

Z Configuration System: a flexible powerful configuration system which takes advantage of both `argparse` and `yacs`
Python
9
star
11

jetInKinect

use Kinect to control jet in *GTA: San Andreas*
Python
8
star
12

stereo_matching_crestereo

Effortlessly deploy CREStereo in PyTorch with a simple pip install.
Python
7
star
13

BuctLibCrx

北化图书馆助手 Chrome 插件:将北化图书馆检索结果自动增加豆瓣图片,评分以及简介
JavaScript
7
star
14

salience-ELM

code of "Saliency Detection via CNN Coarse Learning and Compactness Based ELM Refinement"
Python
7
star
15

calibdiff

A PyTorch-based differential camera calibration library for intrinsic, extrinsic, and stereo camera calibration.
Python
6
star
16

RetroPython

用手机的重力感应操作 在树莓派的LED阵列上运行 类似贪吃蛇的双人对战游戏
JavaScript
4
star
17

Backpropagation

纯numpy实现的人工神经网络及反向传播算法
Python
3
star
18

photo_on_web

用Pyhton 和 JS 开发,对照片的GPS信息映射到地图上的照片展示网页
Python
2
star
19

securityAlgorithm

Python实现 Vigenere, DES, RSA, MD5, DSA 算法,其中 RSA算法手工完成
Python
2
star
20

MyMarkDown

我的文章
2
star
21

dataMining

基于Python的 apriori,FP tree fp growth算法实现及求其强关系
Python
2
star
22

quickSeg

(stop maintain)A deep learning Semantic Segmentation scaffolding(图像分割脚手架+模型库)
Python
2
star
23

bpycv_example_data

Example data for try bpycv
HTML
2
star
24

diyer22.github.com

HTML
1
star
25

poster_hackathon

Poster Hackathon's Python code
Python
1
star
26

graph_optimization

Example code for graph optimization
Python
1
star
27

MyLinear

为熟悉线性代数,将矩阵常用运算用Python实现
Python
1
star
28

fisheye_calibration_undistortion

Fisheye calibration and undistortion example by Python OpenCV
Python
1
star
29

ram_manage_visualization

模拟实现动态分区存储管理可视化
HTML
1
star
30

dete-toolbox

My detection toolbox
Python
1
star
31

paper-note

Write Paper Note in Issue
1
star
32

ELM

基于ELM的图像显著区域检测
Python
1
star