5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10



3.1 Web-Jupyter Lab

Posted by Fiona Su on

1. What is Jupyter Lab?

Jupyter Lab (IPython notebook, Jupyter notebook) is an interactive notebook that supports more than 40 programming languages. The essence of the Jupyter Lab is an open source web application that facilitates the creation and sharing of literary program documentation, supporting real-time code, mathematical equations, visualization and markdown.

Wide range of using:

Data cleansing and transformation, numerical simulation, statistical modeling, machine learning, and more. We can use it to create and share code and documentation. It uses Python (also has kernels in other languages, such as R, Julia, Node, etc.) for good documentation, data analysis, visualization, and teaching.

The Jupyter Lab is an extension of Jupyter that provides a better user experience, such as the ability to simultaneously open and edit multiple Notebook, Ipython console and terminal terminals in a single browser page, and to preview and edit more types of files, such as code files. , Markdown documents, json, yml, csv, images in various formats, vega files (a language that uses json to define charts) and geojson (geographic objects with json), and you can use Jupyter Lab to connect to cloud storage services such as Google Drive. 

It provides us with an environment where you can write your code, run code, view output, visualize data, and view results. Therefore, it is a convenient tool for performing end-to-end data science workflows, including data cleansing, statistical modeling, building and training machine learning models, visualizing data, and more.

As described above, the Jupyter Lab is very flexible and provides powerful interactive capabilities and tools for data scientists. They are more interactive than the pure IDE platform, they are widely used to present code in a more pedagogical way.

2. How to install Jupyter Lab?

The installation method on Jetbot is already in 【2.4 Install Jetbot】---【5.Install Jupyter Lab】

3. Get started!

First, you need a PC to connect to Jetbot.

If our Jetbot is connected to the same LAN as the PC network via WIFI, we can log in directly on the PC-side Google Chrome or other browser (Jetbot IP address): 8888 to Jetbot's Jupyter Lab, for example: http://192.168.1.67:8888

If there is no network environment support, we can use Jetbot's "headless mode" to connect to the network channel established by the PC via USB, and log in to the browserhttp://192.168.55.1:8888

To Jupyter Lab of Jetbot robot car , if we are using the current PC environment to log in to Jetbot for the first time, we need to enter the password for verification. The password is 【2.4 Install Jetbot】---【5.Install Jupyter Lab】the password set when Jupyter Lab installed.

If you are using Yahboom_jetbot_car_image our official Jetbot image, the default password is yahboom.

When you enter the password once in this environment, Jupyter Lab will record the current environment. You will not need to enter the password here next time. The URL will be available to the Jupyter Lab interface for immediate use.

The interface after login is as shown below: image.png

The JupyterLab interface is a dashboard that provides access to interactive iPython notebooks, as well as Jetbot's folder structure and terminal windows into the Ubuntu operating system.

The interface shown below includes the menu bar at the top, the directory tree in the left sidebar, and the main workspace that was originally opened to the Launcher page.

As shown below: image.png

For complete details on all features and menu operations, see the JupyterLab interface:

https://jupyterlab.readthedocs.io/en/stable/user/interface.html

Here are some key features that are especially useful in this course:

 File Browser:

The file browser in the left column allows you to navigate the Jetson Nano file structure. Double-clicking on a notebook or file will open it in the main workspace.

 iPython notebook:

The interactive notebook used in this course has an ".ipynb" file extension.

When you double-click a notebook from the file browser, it will open in the main workspace and the process will begin. The notebook includes text and code "cells". When the code unit is "running", by clicking the Run button at the top of the notebook or the keyboard shortcut 【CTRL】 + 【ENTER】, the code block in the cell is executed and the output is displayed below the laptop.

On the left side of each executable cell, there is an "execution count" or "prompt number" in parentheses. If the cell is running for more than a few seconds, you will see an asterisk mark there, indicating that the cell has not completed execution. When the cell is processed, a number will appear in parentheses.

As shown below:

image.png

③Kernel operation:

The kernel of each running notebook is a separate process running user code. When you open your notebook from the file browser, the kernel starts automatically.

The kernel menu on the main menu bar contains commands to close or restart the kernel, and you need to use them regularly. No code units can be executed after the kernel is shut down.

When the kernel is restarted, all memory is lost due to imported packages, variable assignments, and so on.

As shown below:

image.png 

④Cell label:

You can move any cell to the new window tab in the main workspace by right-clicking on the cell and selecting “Create New View for Output”.

image.png 

⑤Terminal window:

You can work directly in the terminal window of the Jetbot Ubuntu OS via Jupyter remote login, As shown below.

In the Launcher page, click the terminal icon under "Other" to bring up the Launcher page. If it is no longer visible, click the "+" icon at the top of the left column.

image.png

4. Interactive Dashboard in Notebooks

Before you consider adding widgets, you need to import the widgets package:

from ipywidgets import widgets

The basic types of widgets are typical text input widgets, input-based widgets, and button widgets.

The following example from Dominodatalab gives some appearance of interactive widgets:

image.png 

5. Keyboard shortcuts

Shortcuts are one of the biggest advantages of Jupyter Notebooks. When you want to run arbitrary blocks of code, just press Ctrl+Enter. Jupyter Notebooks provides a lot of keyboard shortcuts that can help us save a lot of time.

Jupyter Notebooks offers two different keyboard input modes - command and editing.

The command mode is to bind keyboard and notebook level commands and is represented by a gray cell border with a blue left margin.

Edit mode allows you to enter text (or code) in the active cell, represented by a green cell border.

You can switch between command mode and edit mode using Esc and Enter respectively.

Press Esc button on your keyboard to enter the command mode, you can try the following shortcuts:

   Shift+Enter : Run this unit and select the next unit

   Ctrl+Enter : Run this unit

   Alt+Enter : Run this unit and insert a new unit below it

   Y: unit into code status

   M: unit goes to markdown state

   A : Insert a new unit above

   B: Insert a new unit below

   X: Cut the selected unit

   Shift +V: Paste the unit above

6. Save and share your notebook

Go to the 【Files】 menu and you will see the 【Export Notebook As...】 option:

image.png

You can export and save your notebook in 8 optional formats.

The most common ones are .ipynb files and .html files. Using the .ipynb file allows others to copy your code to their machine, and .html files can be opened in web format (it's handy when you need to save images embedded in your notebook).

You can also manually convert your notebook to HTML or PDF using the nbconvert option.

You can also use jupyterhub at https://github.com/jupyterhub/jupyterhub. It allows you to host your laptop on its servers and share it with multiple users.

7. JupyterLab - Evolution of Jupyter Notebook

JupyterLab supports a more flexible and powerful way of working with projects, but with the same components as Jupyter Notebooks. The JupyterLab environment is exactly the same as the Jupyter Notebooks environment. 

JupyterLab allows you to arrange your notebook, terminal, text file and output result workspaces in one window. You just drag and drop the units you need. You can also edit common file formats such as Markdown, CSV and JSON. The impact of real-time preview changes.

image.png

 Tutorial

Buy Yahboom Jetbot AI robot with HD Camera Coding with Python for Jetson Nano

0 comments

Leave a comment

Please note, comments must be approved before they are published