diff --git a/examples/basic/pysdk_hello_world.ipynb b/examples/basic/pysdk_hello_world.ipynb index 76f4b65..e27c0bb 100644 --- a/examples/basic/pysdk_hello_world.ipynb +++ b/examples/basic/pysdk_hello_world.ipynb @@ -25,21 +25,31 @@ "### Setting the token\n", "Since we’ll be using hardware hosted in the cloud by DeGirum, you’ll need to set a token to access these resources. This token serves as your secure key to connect to DeGirum’s cloud infrastructure and enables you to run the examples provided in this notebook seamlessly.\n", "\n", - "To guide you through the process of obtaining your token, refer to the video below: \n", + "To guide you through the process of obtaining your token and adding it as a new secret in Google Colab, refer to the videos below: \n", "\n", - "[![How to Obtain and Set Your Token](https://img.youtube.com/vi/PLACEHOLDER/0.jpg)](https://www.youtube.com/watch?v=PLACEHOLDER) \n", + "[![Generating a Token for the DeGirum AI Hub](https://img.youtube.com/vi/iyii0RzyFm8/0.jpg)](https://youtu.be/iyii0RzyFm8)\n", + "[![How to Add a New Secret in Google Colab](https://img.youtube.com/vi/GmevDVlT0OQ/0.jpg)](https://youtu.be/GmevDVlT0OQ) \n", "\n", "*Click on the thumbnail to watch the tutorial video.* \n", "\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You may verify your token with this code:" + ] + }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "degirum_cloud_token = ''" + "import degirum_tools\n", + "# print cloud token\n", + "degirum_tools.get_token()" ] }, { @@ -48,7 +58,7 @@ "source": [ "### Running Your First Inference\n", "\n", - "In this section, we’ll demonstrate how to use the DeGirum PySDK to perform object detection on an example image using a cloud-hosted AI model. Here’s what the code does:\n", + "In this section, we’ll demonstrate how to use PySDK to perform object detection on an example image using a cloud-hosted AI model. Here’s what the code does:\n", "\n", "1. **Import Required Libraries**: The `degirum` package is used for loading and using AI models, and `degirum_tools` provides utility functions such as obtaining a token and displaying results.\n", "\n", @@ -62,7 +72,7 @@ "\n", "4. **Display the Results**: The numeric results of the inference, including detected bounding boxes and class IDs, are printed to the console. Additionally, using `degirum_tools.Display`, the inference results are visualized with object overlays on the input image.\n", "\n", - "This code provides a simple yet powerful introduction to the DeGirum PySDK, demonstrating how to load a cloud-hosted model, run inference, and interpret the results in just a few lines of code." + "When you run this code, you should see hardware hosted on the cloud run an object classification model, identify detected objects, and show bounding boxes for those detected objects with only a few lines of code." ] }, { @@ -78,7 +88,7 @@ " model_name=\"yolov8n_relu6_coco--640x640_quant_hailort_hailo8_1\",\n", " inference_host_address=\"@cloud\",\n", " zoo_url='degirum/models_hailort',\n", - " token=degirum_cloud_token,\n", + " token=degirum_tools.get_token(),\n", ")\n", "\n", "# perform AI model inference on given image source\n", @@ -86,7 +96,7 @@ "\n", "# show results of inference\n", "print(inference_result) # numeric results\n", - "with degirum_tools.Display(\"AI Camera: Press q or x to Quit\") as display:\n", + "with degirum_tools.Display() as display:\n", " display.show_image(inference_result)" ] }, @@ -95,7 +105,9 @@ "metadata": {}, "source": [ "### Unified AI Inference with DeGirum PySDK\n", - "We now highlight the core capabilities of the DeGirum PySDK, showcasing its flexibility and simplicity in deploying AI models across multiple hardware platforms. By specifying the appropriate model name and model zoo, users can seamlessly run different types of models, such as classification, detection, keypoint detection, or segmentation, using the same unified interface. The JSON configuration provided below illustrates how users can select the model name based on the desired AI task and hardware option, as well as how to choose the appropriate model zoo URL. This approach abstracts hardware-specific complexities, enabling a consistent experience for diverse AI tasks. Additionally, the `result.image_overlay` feature ensures that outputs—whether bounding boxes, keypoints, or segmentation masks—are visualized in a unified manner, simplifying result interpretation. Combined with `degirum_tools.Display`, this enables intuitive visualization of inference outputs directly overlaid on the input image. This example underscores PySDK’s design philosophy: different models, same code, unified visualization." + "We will now highlight the core capabilities of PySDK, showcasing its flexibility and simplicity in deploying AI models across multiple hardware platforms. By specifying the appropriate model name and model zoo, you can seamlessly run different types of models, such as classification, detection, keypoint detection, or segmentation, using the same unified interface. The JSON configuration provided in the code below enables you to select the hardware you want to use for the AI task you want to perform. We assign a model zoo URL as well as the model names from the DeGirum AI Hub for each AI task. Our approach abstracts hardware-specific complexities, driving a consistent experience for diverse AI tasks. \n", + "\n", + "In the code below, `degirum_tools.Display`, overlays an intuitive visualization of the model's inference results on the input image. This example underscores PySDK’s design philosophy: different models, same code, unified visualization." ] }, { @@ -119,6 +131,15 @@ " \"segmentation\": [\"yolov8n_relu6_coco_seg--640x640_quant_hailort_hailo8_1\"],\n", " },\n", " },\n", + " \"Google\": {\n", + " \"zoo_url\": \"degirum/models_tflite\",\n", + " \"model_names\": {\n", + " \"classification\": [\"yolov8s_silu_imagenet--224x224_quant_tflite_edgetpu_1\"],\n", + " \"detection\": [\"yolov8n_relu6_coco--640x640_quant_tflite_edgetpu_1\"],\n", + " \"keypoint_detection\": [\"yolov8n_relu6_widerface_kpts--640x640_quant_tflite_edgetpu_1\"],\n", + " \"segmentation\": [\"yolov8n_relu6_coco_seg--640x640_quant_tflite_edgetpu_1\"],\n", + " },\n", + " },\n", " \"Intel\": {\n", " \"zoo_url\": \"degirum/models_openvino\",\n", " \"model_names\": {\n", @@ -146,15 +167,6 @@ " \"segmentation\": [\"yolov8n_relu6_coco_seg--640x640_quant_rknn_rk3588_1\"],\n", " },\n", " },\n", - " \"Google\": {\n", - " \"zoo_url\": \"degirum/models_tflite\",\n", - " \"model_names\": {\n", - " \"classification\": [\"yolov8s_silu_imagenet--224x224_quant_tflite_edgetpu_1\"],\n", - " \"detection\": [\"yolov8n_relu6_coco--640x640_quant_tflite_edgetpu_1\"],\n", - " \"keypoint_detection\": [\"yolov8n_relu6_widerface_kpts--640x640_quant_tflite_edgetpu_1\"],\n", - " \"segmentation\": [\"yolov8n_relu6_coco_seg--640x640_quant_tflite_edgetpu_1\"],\n", - " },\n", - " },\n", "}\n", "\n", "source_images = {\n", @@ -167,7 +179,7 @@ "# Create widgets\n", "hardware_dropdown = widgets.Dropdown(\n", " options=model_configurations.keys(),\n", - " value=\"Intel\",\n", + " value=\"Hailo\",\n", " description=\"Hardware:\",\n", ")\n", "\n", @@ -205,13 +217,13 @@ " model_name=model_name,\n", " inference_host_address=inference_host_address,\n", " zoo_url=zoo_url,\n", - " token=degirum_cloud_token,\n", + " token=degirum_tools.get_token()\n", " )\n", " inference_result = model(source_image)\n", "\n", " print(\"Inference result:\")\n", " print(inference_result)\n", - " with degirum_tools.Display(\"AI Camera: Press x or q to quit\") as display:\n", + " with degirum_tools.Display() as display:\n", " display.show_image(inference_result)\n", "\n", "# Link the Run button to the inference function\n", @@ -227,7 +239,7 @@ "source": [ "### Explore and Experiment with DeGirum PySDK\n", "\n", - "This example demonstrates how to perform AI inference using DeGirum PySDK with a pre-trained model hosted in the cloud. We encourage you to experiment further by trying out different **model zoos**, **model names**, and **image sources**. For instance, you can explore various AI tasks such as object detection, classification, keypoint detection, or segmentation by selecting models from different model zoos (e.g., `models_hailort`, `models_openvino`, `models_n2x`, etc.) and providing images of your choice. This flexibility showcases PySDK's unified API, allowing you to customize and test AI inference across multiple hardware platforms and tasks effortlessly. Dive in and discover the possibilities!" + "This example demonstrates how to perform AI inference using PySDK with a pre-trained model hosted in the cloud. We encourage you to experiment further by trying out different **model zoos**, **model names**, and **image sources**. For instance, you can explore various AI tasks such as object detection, classification, keypoint detection, or segmentation by selecting models from different model zoos (e.g., `models_hailort`, `models_tflite`, `models_openvino`, etc.) and providing images of your choice. This flexibility showcases PySDK's unified API, allowing you to customize and test AI inference across multiple hardware platforms and tasks effortlessly. Dive in and discover the possibilities!" ] }, { @@ -239,7 +251,7 @@ "import degirum as dg, degirum_tools\n", "\n", "hw_location = \"@cloud\" # \"@cloud\" for cloud inference, \"@local\" for local inference, or IP address for AI server inference\n", - "model_zoo_url = \"degirum/models_hailort\" # models_hailort, models_openvino, models_n2x, models_rknn, models_tflite\n", + "model_zoo_url = \"degirum/models_hailort\" # models_hailort, models_tflite, models_openvino, models_n2x, models_rknn\n", "model_name = \"yolov8n_relu6_coco--640x640_quant_hailort_hailo8_1\"\n", "image_source = \"https://raw.githubusercontent.com/DeGirum/PySDKExamples/main/images/Mask1.jpg\"\n", "\n", @@ -248,7 +260,7 @@ " model_name=model_name,\n", " inference_host_address=hw_location,\n", " zoo_url=model_zoo_url,\n", - " token=degirum_cloud_token\n", + " token=degirum_tools.get_token()\n", ")\n", "\n", "# perform AI model inference on given image source\n", @@ -256,7 +268,7 @@ "\n", "# show results of inference\n", "print(inference_result) # numeric results\n", - "with degirum_tools.Display(\"AI Camera\") as display:\n", + "with degirum_tools.Display() as display:\n", " display.show_image(inference_result)" ] }