Skip to main content

A collection of the common python3 codes used in Cmpltrtok's projects

Project description

A brief intro to PyCmpltrtok

PyCmpltrtok is a collection of the common python3 codes used in Cmpltrtok's projects, such as:

Currently, only Linux platforms are considered. Maybe the user could run it on other Unix-like platforms, but it is not tested.

Install

pip install PyCmpltrtok

Organization of the code

PyCmpltrtok
├── common_np.py (Common code for numpy.)
├── common_opencv.py (Common code for opencv.)
├── common.py (Normal Common code collection.)
├── data (To provide some data.)
│   └── cifar10 (To provide cifar10 data.)
│       ├── load_cifar10.py (The script to download, decompress, and return training and validating data of cifar10.)
...

Note:

  • ~/.cache/PyCmpltrtok/data/cifar10/

This directory and its content are generated by the script the first time to invoke data/cifar10/load_cifar10.py, so the user at least should have privildge to create it and write files into it when the user firstly run the load_cifar10.py script.

  • ~/.cache/PyCmpltrtok/data/cifar10/cifar-10-python.tar.gz

The code will download this file at here when it runs at the first time. Or the user could just copy it to here if she already has one, especially when it will be very slow to download with a bad Internet connection.

How to use

They are just normal python3 codes.

For instance, the user could use them as below: ( Here the author just demonstrates how to load the cifar10 data. )

from PyCmpltrtok.common import *
from PyCmpltrtok.common_np import *
from PyCmpltrtok.common_opencv import *
import PyCmpltrtok.data.cifar10.load_cifar10 as cifar10

x_train, y_train, x_test, y_test, label_names = cifar10.load()
shape_ = cifar10.shape_  # The shape of very image, it is (3, 32, 32), i.e. (C, H, W).
x_train = x_train.reshape(-1, *shape_)
x_test = x_test.reshape(-1, *shape_)
x_train = uint8_to_flt_by_lut(x_train)
x_test = uint8_to_flt_by_lut(x_test)

Use the cifar10 data

The user could use the above invocation to use the Cifar10 data. It will download cifar-10-python.tar.gz if it is not at there.

The user could also invoke PyCmpltrtok/data/cifar10/load_cifar10.py to download and check the data.

The user will see the information below if the entire tar file is downloaded and decompressed normally. In the last 2 steps of this script, it will try to visualize the data by matplotlib. So please run it in a GUI terminal or set up the environment variable DISPLAY and an X11 server to get the visualization result.

--------------------------------Label names--------------------------------
0 airplane
1 automobile
2 bird
3 cat
4 deer
5 dog
6 frog
7 horse
8 ship
9 truck
--------------------------------Data loaded--------------------------------
x_train <class 'numpy.ndarray'> (50000, 3072) uint8
x_test <class 'numpy.ndarray'> (10000, 3072) uint8
y_train <class 'numpy.ndarray'> (50000,) uint8
y_test <class 'numpy.ndarray'> (10000,) uint8
--------------------------------Check data--------------------------------
Checking x_train and y_train ...
Check and close the plotting window to continue ...
Checking x_test and y_test ...
Check and close the plotting window to continue ...
Over! Data loaded and checked!
--------------------------------All over--------------------------------

The visualization result will be like below. They are the first 25 and last 25 images with their category labels.

About the author

Hi, my name is Yunpeng Pei, an AI engineer working in the City of Beijing, China. I developed these projects in my spare time just for interest. I will be very happy if you find them to be very little help to the community. I must say sorry that they are far away from perfect and their document is not finished yet, because of my limited ability and limited resources on these projects; although I have tried my best. You could contact me freely by email to my personal email belarc@163.com.

Project details


Download files

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

Source Distribution

pycmpltrtok-0.0.1.tar.gz (46.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyCmpltrtok-0.0.1-py3-none-any.whl (57.9 kB view details)

Uploaded Python 3

File details

Details for the file pycmpltrtok-0.0.1.tar.gz.

File metadata

  • Download URL: pycmpltrtok-0.0.1.tar.gz
  • Upload date:
  • Size: 46.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for pycmpltrtok-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7e8f194507d8e3d3aeb527866a5f63dba9e90850e8cc99928ebf5c0f8d42f00c
MD5 b07600b46dac1574016356468f33a86e
BLAKE2b-256 cc1027a36ff66029880f4931d1b74fe35bb0a65cb398f09a4c9bc91710619f89

See more details on using hashes here.

File details

Details for the file PyCmpltrtok-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: PyCmpltrtok-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 57.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for PyCmpltrtok-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 427352dfe43609a9965d57bcc70417fa90f99162e9d2ab4f634c7ec98ccbc6b5
MD5 8bdb03a42e035b082356b84b3ffe8a70
BLAKE2b-256 c6a505dd3854eb562a654f16192ac8bcfdba37fb2da6a87cf5edd6dd88bcd560

See more details on using hashes here.

Supported by

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