Python Packaging: Hosting Code at Github

Github Code Sharing and Development Platform

Github is a great platform for open source software. It grew so much in recent years as the interest in computer programming grew but it’s also such a great platform for sharing, collaborating and contributing.

A lot of people even create repos (or repositories) as archiving their information in an open environment. 

It’s common to see lists of links, books, movies, knowledge sources etc although it’s mainly developed as a platform to share code.

So, our advice is don’t be shy, jump on the wagon if you don’t have a Github account yet, you will soon discover it offers so many amazing synergies and it’s not that complicated either.

Github Logo

So, in a nutshell, you host and share code on Github, no matter how advanced or basic it is. There is no such criteria as your code must be extraordinary so don’t be intimidated. You can start with something like:

msg = "Hello World!"
print(msg)

just to test the waters…

Creating a Github Account

You can sign up for Github from the top right corner.

Creating a Github Account is simple. Just go to Github Signup Page. Just pick s unique username, set your password and game is on!

Github Sign Up Page

Once you sign up, you can start a repo. Think of repositories as individual projects, libraries, software, notebooks or products.

You can have any amount of repository in your Github account.

Just click New Repository and it will take you to repository initialization page.

Github New Repository Menu

Creating a Github Repository

Creating a repository is also easy. Just pick up a unique name. This name only has to be unique in your account. It doesn’t have to be globally unique. It will let you know with a green or red pop up message anyway.

You can also write a short description, why not. Although it’s optional it makes sense to at least jot a couple of words.

Recommended Reading:

Steps for Creating a Github Repository

Some important criteria to consider are:

    • Public vs Private: This option is straightforward. If you’d like to keep your repo as private no one will be able to see it except you and people you assign it to. Public repos are open to public view and contribution. You can also change it later.
    • Adding a README file: Checking this option almost always makes sense. It’s great to have a Readme file, content of which also shows up on the main page of your repository. You can always delete it later if you don’t want it or you can change it as well.
    • Adding a gitignore file: This file tells setup file which files not to include in a setup. So, it’s an ignore template. This is genius because there can be lots of irrelevant files like temp files from your IDE or from Python itself that you actually want to avoid in software development.
    • Adding a licence: Adding license can be more serious than it sometimes seems. If you’re in a rush you can always uncheck this option and add a license you choose later.

Thank you for checking out Github component of the Python packaging series. When you are ready you can also consider uploading your unique Python library to PyPI.

If you need some inspiration check out this post:

I’ve been learning coding. What’s next? (Python Edition)

Nvidia’s New Maxine Platform is Phenomenal Applied AI Example

Nvidia just announced an innovative artificial intelligence application a couple of days ago and it’s big deal for a few reasons.

Let’s take a look at what it is and what it does first:

Friends doing teleconference with an open book on laptop

What is Nvidia Maxine?

Nvidia Maxine is an AI powered video streaming platform for developers. While it’s the platform that provides the technology that can be used for video calls or video conferencing, it’s not the end user product such as:

  • Skype, 
  • BlueJeans, 
  • Microsoft Teams, 
  • Google Duo, 
  • Hangouts,
  • Zoom 

It’s more the technology platform that applications could use if they wanted to.

AI became a chic word that’s used in so many products and/or services today but true AI innovation instantly shows off.

Traditionally, current video codecs (such as H.264) can be quite heavy on the internet connection due to its high quality and data size that comes with it. H.264 has been great for videos that are already recorded such as online movies, Netflix, Hulu, Youtube Videos etc. But when it comes to streaming it has the quality we want at a high internet speed cost.

Publicly trading video communications company Zoom has already seen a massive surge in stock prices going up to $485 in the spot market (as of October 7, 2020) from only approximately $70 in early January 2020 shortly before pandemic has broken out ZM:NASDAQ stock price on Google Finance.

What if we could have the support of predictive AI technology that made the application require 1/10 of the data size for a very similar image quality? That’s what Nvidia did.

Zoom shares price chart screenshot from Google Finance.

At this level Zoom’s market capitalization surpasses IBM’s approximate market cap of $110 billion US (IBM Market Capitalization Data on Nasdaq: IBM:NASDAQ) with $125 billion US.

Why is Nvidia Maxine special?

Nvidia’s Maxine implements Generative adversarial network, GANs, to create a deep fake of your own self.

Basically, what happens is, once the deep fake structure is created your movements, mimics, facial expressions, gestures and mannerism are transferred through the AI powered image that’s displayed to your counterparty. Apparently this allows massive amounts of data saving without overwhelming GPU or CPU too much.

We have already been seeing funny (or scary depending on the application and from where you look at) deep fake videos surface the internet recently. This is the immature phase of a technology when it first emerges and nobody is quite sure what to do with it.

Nvidia Maxine vs H.264 Demonstration Screenshot

I believe if Nvidia Maxine is mass adapted, which it definitely might especially if it can achieve its promises like 10x data saving, this will be the beginning of a new are where AI and particularly GAN are becoming mature end-user products and services.

Given the pandemic, more people than ever need this technology at affordable rates and 

Nvidia’s AI innovation couldn’t be timelier.

Given the public activities on Nvidia’s public Github repository and their extensive usage of Pytorch and Tensorflow for machine learning applications, Nvidia is highly likely to be using Python for their Maxine streaming platform as well.

Although Nvidia states the data size savings are up to 10x on the official webpage of Maxine here. In the promotion video Bandwidth usage per frame is announced as almost 900x ( 97KB vs 0.11KB ). There seems to be a confusion here but moving passed that, 10x data reduction without much quality loss is still huge deal.

On top of data savings Nvidia Maxine also promises to convert videos with 360p quality to 720p in a very realistic way. Here is the interesting promotion video from Nvidia AI Research:

Global Internet Usage

As of 2020, approximately 4.5 billion people have some form of internet access while 3.5 billion people still has no internet access whatsoever. 

According to UNESCO data this approximately corresponds to a ratio of 55% to  45% over the global population. This is absolutely a heart-breaking number considering how much we get done through the internet today both for business and pleasure.

During the pandemic times of Covid-19, for 100s of millions of people video conferencing has been a life saver (in addition to yoga, online shopping, dark chocolate, video games, video streaming services and remote work to name a few). Unfortunately, not all of us are equally blessed with the availability of tech at the tip of our fingers. 

On the flip side though, we have some good news. Internet usage stats will continue to get better and according to Cybersecurity Almanac (co-published by Cybersecurity Ventures and Cisco), global internet access percentage will increase to 6 billion in 2022 and all the way up to 7.5 billion in 2030 (90% of the projected population of 6+ yo ).

And, although 55% of the world seems to have access to internet, it doesn’t mean they all have high broadband connections. 6% of internet users in the US and 13% of internet users in Australia still has slow speed internet. (Reference: Weforum Internet Access Article)

Internet access statistics are approximately 9 in 10 in developed countries, 5 in 10 in developing countries and only barely 1 in 10 in underdeveloped countries.

Internet Logo in Front of Store

Also, when the internet is less available it tends to be very expensive and restricted and this can be a huge deal breaker for someone trying to put food on the table.

One thing these numbers expose is that video streaming, whether it’s for entertainment, online education (MOOCs) or video conferencing, is still nearly impossible for billions of people in 2020.

This statistical contrast makes it easier to comprehend the need of innovation in video streaming and to what extent it can change lives.

Future of Nvidia Maxine

It’s probably safe to conclude that this is just the beginning. Beginning of a very powerful and disruptive technology starting to creep into our lives.

Given the potential Maxine platforms enables, it’s probably safe to assume that its adaptation will be widespread very fast. We will watch and see how thing unfold for Nvidia’s Maxine platform.

Although Maxine already has the potential to make video conferencing available for millions of people with poor internet connection and save data at global scale we can see this application going further in terms of technological innovation.

Some of the applications Nvidia’s Maxine implementation can pioneer are:

  • VR
  • 3-D holograms
  • Online News
  • Presentations
  • MOOCs
  • Podcasts
  • Suitable Vlogs

On the flip side, this technology will inevitably also be used by people with malintent and we can see a surge in unpleasant experiences caused by:

  • online telemarketing
  • impersonation fraud 
  • more sophisticated scams
  • pranks
Let’s hope that our averaged out mutual conscious as the human kind continues improving as fast as technologies. We can also do more than hoping though. Best thing to do is familiarize and educate yourself and Holypython already offers a plethora of basic Python lessons, Python tutorials and Python exercises for online practice.
 
Techradar also has a pretty nice coverage on the news of Nvidia Maxine, you can find the Techradar article here.
 

You are also more than welcome to visit our recent Machine Learning section.

How to Use Watermarkd: A Batch Watermarking Library with GUI

What is watermarking?

Watermarking is a technology of printing less opaque text or symbols on images and items. Believe it or not it’s considered an ancient technology as old as paper since it’s been used on special letters, stamps and printed currency.

As digital imaging has never been such a humongous part of humans’ lives, the usage, creation and demand related to digital images rises as well. Despite the rise of open source and sharing mentality in the digital community, there seems to still be significant room for watermarking applications and so the demand for innovation continues.

Star shaped watermarks among with other patterns on 100 Euro banknote

Why Watermarkd?

Watermarkd is a Python library published by Holypython.com under the open source license Apache-2.0.

In this post we will try to demonstrate what can be accomplished with Watermarkd library.

Watermarkd library allows users to handle watermarking operations in Python directly from the terminal or through use of an optional GUI component.

Since it’s specialized only for watermarking tasks, Watermarkd has a very light graphical user interface. You can probably get an image watermarked (or watermarkd!) during the time it takes to start up a major Image Manipulation software.

It has the most commonly used features when it comes to watermarking and expected to cater to 90% or more of the people looking to watermark an image.

How does Watermarkd work?

Currently, Watermarkd library consists of one sole class named Spread which houses two functions that spread out watermark text on image(s):

  • single function: Spread.single() can be used to apply watermark on a single image (photo).
  • batch function: Spread.batch() can be used to apply watermark to multiple images in a folder.
Here are some images created with Watermarkd on the go.
Medical Field Watermarking
Business confidentiality communicated through watermark

Below you can see various usage types of Watermarkd Library under four titles:

– Single Function Usage

– Batch Function Usage

– Single Function Usage with GUI

– Batch Function Usage with GUI

Single Function Usage

Single function can be used in two main ways:

  • through command line without any interface using its parameters
  • through GUI by enabling gui parameter via True boolean.

as simple as passing True argument to gui as below:

single(gui=True)

Let’s first investigate usage scenarios without gui:

import Watermarkd as wmd

wmd.Spread.single(img_path=r"c:/myimage.png")

This code, once executed, will create a watermarkd image on the user’s Desktop. You don’t have to assign gui parameter to False since it’s the default option. So, basically it’s the same thing as this code:

wmd.Spread.single(gui=False, img_path=r"c:/myimage.png")

Also, please note that, when not using gui, the only parameter you have to pass an argument to is img_path, since all the other parameters have default values and hence, they are optional.

Let’s continue to explore other parameters that can be passed to the single function:

 

  • gui, (bool), default False : enables GUI
  • img_path, (string), mandatory parameter :signifies image path
  • wm_text,  (string), default= “Watermarkd”) : Watermark Text
  • wm_trans, (int [1-255]), default= 85 : Signifies Watermark Transparency 
  • font_size, (int), default= 55) : Watermark Font Size
  • font_name, (string), default= “arial.ttf” : Font Type
  • filename, (string), default=”Watermarkd” : File Name for Saving
  • save_to_path, (string), default=”Desktop/watermarkd_” : Saving Folder Path
  • save_to_suffix, (string), default=”.png” : File Type for Saving 
  • output_filename, (default= r”c:/Users/”+user_path+”/Desktop/watermarkd.png”) : File Name For Saving

Here is another example, in which watermark text is assigned to “Inception”:

from Watermarkd import Spread

f = r"c:/Users/ABC/Desktop/film.png"
Spread.single(img_path=f, wm_text="Inception")
Film Making Industry Watermarking

Batch Function Usage

Batch function is very similar to single function with a few subtle differences. First and foremost, it handles a folder of images rather than a single image. 

So, img_path parameter is exchanged with folder_path parameter.

Otherwise the rest of the differences are mainly internal which you can check out in the source code if you like.

from Watermarkd import Spread

Spread.batch(folder_path=r"c:/User/ABC/New_Photos")

This code will read all the images from the given folder New_Photos, and create an output folder named Watermarkd_ in user’s Desktop and save all the watermarked files there with the default values for optional parameters. Check out a list of parameters below for adjusting different values such as: watermark text, font size, font type, file name, path name, transparency etc.

If you check out the source code, most of the variable names are also conveniently borrowed from the single function.

Regarding the inner workings of the batch function, the main thing is: it doesn’t apply the watermarking algorithm to a single image, instead watermarking algorithm and positioning etc are placed inside a for loop which iterates through the images in the given folder.

So, in simpler words, folder is iterated with a for loop, image file name is taken which becomes the img_path similar to single function, then watermarking is applied and then files is saved and next iteration starts with the next file.

Here is another example:

from Watermarkd import Spread

f=r"c:/User/ABC/New_Photos"
Spread.batch(folder_path=f, wm_text="Photographer A. C. Jonah, #927-654-92**")
  • gui, (bool), default False : enables GUI
  • folder_path, (string), mandatory parameter  :signifies folder path
  • wm_text,  (string), default= “Watermarkd”) : Watermark Text
  • wm_trans, (int [1-255]), default= 85 : Signifies Watermark Transparency 
  • font_size, (int), default= 55) : Watermark Font Size
  • font_name, (string), default= “arial.ttf” : Font Type
  • filename, (string), default=”Watermarkd” : File Name for Saving
  • save_to_path, (string), default=”Desktop/watermarkd_” : Saving Folder Path
  • save_to_suffix, (string), default=”.png” : File Type for Saving 
  • output_filename, (default= r”c:/Users/”+user_path+”/Desktop/watermarkd.png”) : File Name For Saving
More Photo Examples:
Model Promoting Holypython.com Watermarked with Watermarkd
Young Model Posing For Photography Agency with Watermarkd
Univeristy of Utah Campus Watermarked with Watermarkd
New Release Poster for Software

Watermarkd Usage: Single Function with GUI

Usage with GUI is pretty straightforward.

  1. Pick an image file
  2. Type your watermark text
  3. Choose a watermark text size. Options are:
    • Normal (by default)
    • Small
    • Large
    • Value: Let’s a custom font value to be entered. Possibly something like ~150 for high rez images where something like 30 might suffice for a low resolution image.
  4. Transparency: This value defines the transparency (or opacity) of your watermark text. 85 is the default value but you can go all the way down to 0 for a completely transparent text (Watermark would be invisible then). 255, the maximum value will create a solid white watermark text (which is more just a white text than watermark since it’s not transparent at all. It can sometimes be useful nevertheless.)
  5. Save as: Different options to save watermarked image as different image types such as:
    1. png (default)
    2. jpg
    3. gif
    4. bmp
  6. Save to: Path or folder that you’d like to save your watermarked image to. You can either type it or choose it with the help of the Path button.
  7. Filename: Filename you’d like to save your watermarked image under.

Once submit is pressed all the inputs from the user get registered and watermarking process starts.

It can last anywhere between miliseconds to a couple of seconds depending on the resolution of the image. (For the very high resolutions you might need to allow 2-3 seconds which also depends on the availability of computation resources.)

Just as GUI is a new dimension for the Python coder, Packaging also is a new dimension that opens up a whole new world of opportunities and skillset.

To activate GUI component all you have to do is:

Spread.single(gui=True)

You don’t have to pass any other arguments to setting parameters since they’ll be overridden after the GUI is executed.

from Watermarkd import Spread

Spread.single(gui=True)
Single Function's GUI Component in Watermarkd

Watermarkd Usage: Batch Function with GUI

Usage with GUI in batch function is also simple and straightforward. It’s mostly overlapping with single function’s steps. Here are the main differences:

  • Pick a folder instead of a single image through the Browse button.
  • At the bottom file name will be used as a seed to generate multiple images with watermark. For instance, if you choose Work as file name, files will be saved as Work1.jpg, Work2.jpg, Work3.jpg etc.

Once submit is pressed all the inputs from the user get registered and watermarking process will start.

It can last anywhere between miliseconds to a couple of seconds per image depending on the resolution of the image. (For the very high resolutions you might need to allow 2-3 seconds per image which also depends on the availability of computation resources.)  After that time watermarked images will be created in the specified folder or default folder if none is specified.

Activate graphical user interface for bath watermarking a folder of images similar to the code in single() function’s case:

from Watermarkd import Spread

Spread.batch(gui=True)
Watermarkd batch function's GUI window

Further Steps with Watermarkd

As much as I’d love to see Watermarkd getting used by people with different backgrounds such as:

  • Photographers 
  • Bloggers
  • Entrepreneurs and Business Owners
  • Students
  • Teachers
  • Media Agencies
  • Artists, Illustrators

I’d also love to see it being checked out as a learning tool for Python packaging and Python coding in general. It has all the ingredients necessary to comprehend packaging in Python.

Besides packaging topics such as: Pypi repository publishing, Github hosting, licensing etc. It also has fundamental coding topics, but nothing too complicated to discourage an intermediate or even beginner coder, such as:

Additionally, it’s pretty simple to understand and demonstrates all the ingredients needed to publish a library on PyPI (Python Package Index), such as:

    • setup.py
    • requirements.txt
    • License
    • Readme.md
    • __init__.py
Every great coder was a beginner at some point. So, don’t be too shy. One step at a time you too can become great, and create great programs,  there is no doubt about it. Some helpful topics to discover can be:

Such topics open up whole new worlds for a programmer to progress towards, you can see them as paths you can take in your journey(Oftentimes you can combine these paths for a great product as well).

Final Thoughts

If you’re a beginner or intermediate programmer go ahead and create a Github account. Maybe create a trivial repository where you take some notes and save some files if you like, just to start getting familiar with the environment.

If you like Watermarkd or Holypython’s work in general, you’re welcome to visit our Github repos as well. You can read the Watermarkd.py source code along with other necessary files there (setup.py, requirements.txt, __init__.py etc.). 

As simple as it is, I hope Watermarkd library serves as a practical solution for people who might need watermarking and I’d love to see it serve educational purposes for coders and developers who never had a chance to explore packaging and publishing topics related to Python.

Thank you so much for visiting.

ps: I’d like to thank creators and contributors of Pillow the Friendly PIL Fork and PySimpleGUI libraries for creating such fantastic libraries and influencing further developments. Also, a huge thank you to Stack Overflow community for sharing so much expert level knowledge and being so kind.