Jekyll2023-02-27T13:13:34+00:00https://ddak.github.io/feed.xmlThe idea factory; and more.My random thoughts and opnions on some of the topics I care about.
ddakdawood.khan@gmail.comThe Power of Metaphors- data is the new oil.2023-02-27T00:00:00+00:002023-02-27T00:00:00+00:00https://ddak.github.io/data,/ai,/ml/2023/02/27/The%20Power%20of%20Metaphors:Data%20is%20the%20new%20Oil<p>#Metaphors are not mere slogans to communicate a profound idea, but also have transformative power, to bring the invisible process by which “slogans” come into being. Take the example of “Data is the new oil” and how it has transformed AI. The AI revolution is by and large established on the pillars of Algorithms, Compute, Communication, and Data. Importantly, the data is the “fuel” that propels AI into different areas at warp speed, and aptly data was coined as “the new oil”.</p>
<p>As the data is harvested/mined/siphoned, we need to brace and mitigate the impacts that might come. Albeit these “impacts” can be big and may be largely unknown, the nations need to build strategies for them. TV series like The Capture TV series, Black Mirror etc are a dramatization of some of the impacts of such “far of dystopia”. But are these some future perspectives or current predicaments? Take an example of a “digital twin”, which is a digital replica of a person (audio/video/behavioural quarks). Often, these twins are AI trained on vast amounts of data such as video, audio, and images of the person. We have, in the recent past, seen AI systems demonstrating a deep fake model of remarkable quality:</p>
<ol>
<li>[Obama] https://www.youtube.com/watch?v=cQ54GDm1eL0</li>
<li>[Leonardo DiCaprio] https://www.youtube.com/watch?v=17_xLsqny9E</li>
</ol>
<p>This has implications for national security, as well. Take the example of, Killing of <a href="https://www.npr.org/sections/thetwo-way/2010/02/dubai_police_chief_99_sure_mos.html">Mahmoud al-Mabhouh</a> and how Dubai’s police used digital forensics to identify the perpetrators, and how “<a href="https://www.haaretz.com/israel-news/security-aviation/2022-12-26/ty-article-magazine/.premium/this-dystopian-cyber-firm-could-have-saved-mossad-assassins-from-exposure/00000185-0bc6-d26d-a1b7-dbd739100000">Toka</a>” is creating technology to counter such forensic analysis– turning BBC’s The Capture TV series into something of a reality.</p>
<p>How should we leverage the data then?
One example is that of <a href="https://tonomus.neom.com/en-us">#TONOMOUS</a> #Neom. What they say on the webpage goes like this: “A cognitive world is built on trust, using more than 90% of consented data rather than the 1% used by today’s smart cities. Hyper-connected cognitive cities will use that data to seamlessly interact with community members, interpreting and mapping future needs and adding unprecedented value to humanity”. Though the idea is great, I don’t know what they mean by 90% consented–90% of what? And what about the last 10% is it un-consented? Besides consent can be tricky, for example, deliberately buried under some dark UI pattern, “on/accepted” by default, transitive acceptance, incomprehensible legal language etc which makes it difficult & may be impossible to be an informed consent. Take the example of the usage of audio data by apple to train their AI, courtesy agreement with Spotify (https://www.wired.com/story/apple-spotify-audiobook-narrators-ai-contract/) and the concerns of voice artists and their concerns about “consent”.</p>
<p>On the flip side of data usage and collection, we have China. A sort of blanket data collection. As Kai-Fu Lee mentions in his book “AI Super-Powers China, Silicon Valley, and the New World Order”, “….By immersing themselves in the messy details of food delivery, car repair, shared bike, and purchases at the corner store, these companies are turning China into the Saudi Arabia of data: a country that suddenly finds itself sitting atop stockpiles of the key source that powers this technological era.”. In an interview with Forbes, Kai-Fu lee when asked about investment philosophy of Sinovation VC, he said..”..Instead of seeking rocket science AI companies, we seek companies that have data. Data that is well structured, large in quantity, connects to a business metric and ideally, is proprietary…”. Perhaps such investment philosophies fueled and incentivized the data collection by the Chinese tech companies, with an assumption that “<a href="https://www.scmp.com/abacus/tech/article/3028402/chinese-internet-users-criticize-baidu-ceo-saying-people-china-are">..Chinese people are willing to give up data privacy for convenience..</a>”. However, <strong>The Personal Information Protection Law (PIPL), November 2021</strong>, may give Chinese data subjects new rights as it seeks to prevent the misuse of <a href="https://www.dataguidance.com/notes/china-data-protection-overview">personal data</a>.</p>
<p>Similarly, the attitude of BigTech about the data hasn’t been much different either; take the examples of Cambridge Analytica &Facebook (Meta), WiFI data collection during Street View data collection by Google etc.</p>
<p>What am I getting at?</p>
<p>The AI engine needs data to train and improve itself. For the groups that are building these models, the proliferation of data is a must to achieve AI supremacy. Data is much different to “oil”. You can’t have two copies of the same litre of oil; the ownership is based on the custody and that is transferred once physical custody of oil is transferred. Data, on the other hand, is much different. Perhaps, maybe, we should follow something which is analogous to “the smart grid approach”, where the surplus energy produced by the household is sold to the grid– that is incentivize consent-based data sharing. I would love to hear your thoughts, ideas, and feedback.</p>
<p>John Oliver did a great job. in explaining some of the nuances in a fun way <a href="https://www.youtube.com/watch?v=Sqa8Zo2XWc4">Artificial Intelligence: Last Week Tonight with John Oliver (HBO)</a></p>["Dawood A Khan"]#Metaphors are not mere slogans to communicate a profound idea, but also have transformative power, to bring the invisible process by which “slogans” come into being. Take the example of “Data is the new oil” and how it has transformed AI. The AI revolution is by and large established on the pillars of Algorithms, Compute, Communication, and Data. Importantly, the data is the “fuel” that propels AI into different areas at warp speed, and aptly data was coined as “the new oil”.Real-time 3D Path Planning for UAVs based on SoC2023-02-23T00:00:00+00:002023-02-23T00:00:00+00:00https://ddak.github.io/ai,/ml,/programming,/c++/2023/02/23/%20AI%20in%20Drones%20(AKA%20UAVs)<h2 id="prologue">Prologue</h2>
<p>Most of this write-up is based on an old proposal I submitted back circa 2014 for funds. However, I hope to continue the research & development, when I get an opportunity, to extend the edge-AI work in UAV domain in one of the following directions (priority based):</p>
<ol>
<li>Development of autonomous unmanned aerial vehicles (UAVs) that use machine learning and computer vision to perform surveillance, reconnaissance, and target acquisition.</li>
<li>Use of big data and machine learning algorithms to identify and predict security threats, such as cyber-attacks and physical breaches, in government-related technology systems.</li>
<li>Application of machine learning and computer vision to automate the detection and classification of pests, diseases, and other anomalies in agricultural crops to improve yield and reduce losses.</li>
<li>Use of machine learning and NLP to develop natural language interfaces for military personnel to access and process vast amounts of data more efficiently and accurately.</li>
<li>Development of machine learning algorithms for autonomous decision-making in defence systems, such as target prioritization, route planning, and resource allocation.</li>
<li>Integration of IoT technologies and big data analytics to improve the situational awareness of military operations, including the tracking and management of military assets and personnel.</li>
<li>Development of deep learning models to improve the accuracy and reliability of remote sensing data for precision agriculture, enabling more efficient use of resources and increased crop yields.</li>
<li>Use of machine learning and computer vision to automate the monitoring and analysis of environmental factors, such as weather patterns and soil moisture levels, to support more informed decision-making in agriculture.</li>
<li>Exploration of the potential of machine learning and big data analytics in educational technology to improve student learning outcomes and personalize instruction.</li>
<li>Use of IoT technologies and machine learning to develop smart classrooms that can optimize learning environments for individual students based on their preferences and performance.</li>
</ol>
<p>The theme of these research ideas is in the domains of defence/security, agriculture, and education. These ideas mostly use deep learning (computer vision, NLP) techniques in conjunction with a UAV platform, as such, edge-AI skills/experiences/concerns are the most relevant in this context due to UAVs being payload/energy-constrained.</p>
<p>The rest of the write-up is the original proposal of 3D path planning in \(\mu\) UAVs; with minor comments from [Future ME].</p>
<h2 id="introduction">Introduction:</h2>
<p>\(\mu\) Unmanned Aerial Vehicles (\(\mu\) UAVs) are small man-portable air vehicles (usually of around 20 cm in size) which are widely used in various contexts; for example:</p>
<p>(a) In military contexts, \(\mu\) UAVs are used for missions which involve target and decoy, reconnaissance, combat and logistics operations.</p>
<p>(b) In the civilian context, \(\mu\) UAVs are deployed for environmental and agricultural purposes such as weather forecasting, storm, bush fire detection, farm field seeding etc.</p>
<p>However, all \(\mu\) UAV use cases have common tasks which require human operator involvement. One such task performed by human operators is Path Planning.</p>
<p>Definition [Path Planing]: is to find an optimal collision-free path, amidst obstacles, for a \(\mu\) UAVs from the source point to the destination point.</p>
<p>Planning consists of finding a sequence of actions that transforms some initial state into some desired goal state. In path planning, the states are \(\mu\) UAV locations and transitions between states represent actions the \(\mu\) UAVs can take, each of which has an associated cost. A path is optimal if the sum of its transition costs (edge costs) is minimal across all possible paths leading from the initial position (start state) to the goal position (goal state). A planning algorithm is complete if it will always find a path in finite time when one exists, and will let us know in finite time if no path exists. Similarly, a planning algorithm is optimal if it will always finds an optimal path.</p>
<h2 id="statement-of-problem">Statement of Problem</h2>
<p>In order to survey small size areas or non-moving scenes the flying robot must be able to perform a stationary flight. In addition, it must be rapidly deployable. The project will therefore concern rotary wing unmanned aerial vehicles (UAV)–e.g. Quadcopters. This machine will be a small-size VTOL (Vertical Take Off and Landing) UAV designed for autonomous inspection and survey tasks in urban areas or more generally in a constrained outside environment (known and unknown environment with moving obstacles). Using the autonomy faculty of the \(\mu\) UAV, users will be able to devote their attention to the exploitation of the data coming from the mission sensors and not to the navigation of the vector.</p>
<p>Most often \(\mu\) UAVs have a Small onboard computer which is used for various avionics-related tasks, due to weight and limited battery power consideration. However, the functionality provided/executed by these small onboard computers is limited and not suitable for computation-intensive features/algorithms like path planning, object detection & tracking etc. In order to do autonomous path planning on these \(\mu\) UAVs we need a computational platform (Hardware and software) which is capable of real-time path planning with robustness— besides being power efficient (due to battery limitations) and low on weight. We propose using a System of Chip (SoC) approach for the development of a robust path planner; wherein we have an SoC with an on-chip energy-efficient processor (like ARM core) and some FPGA fabric for dedicated implementation of resource-intensive logic (object detection, path planning, tracking etc). As such, the central hypothesis of this research project is that the overall performance can be improved by implementing robust Path Planning algorithms on a SOC. This hypothesis is based on the fact that with the FPGA parts, the ARM processor can have a much bigger data throughput capacity and greater parallel computing ability, which is crucial for this type of application.</p>
<h2 id="objectives-and-expected-outcomes">Objectives and expected outcomes</h2>
<p>The heart of the project is the research and development of software and hardware modules for the autonomy of small-size drones in terms of Path Planning for navigation with robustness to unexpected events. To reach this goal, different scientific fields will be addressed: mission planning, collision avoidance, trajectory and localisation algorithms, and drone hardware.</p>
<h3 id="technical-objectives-and-expected-results">Technical objectives and expected results:</h3>
<p>The users will use a dedicated Mission Control System (MCS) with Man Machine Interface (MMI) to define the start and endpoint that the drone will follow autonomously and the target areas to focus on.</p>
<p>This MMI is the main link between the drone system and the user. The objectives and outcome can be summarised as:</p>
<ul>
<li>display a map of the area to explore as a 2D or 3D view of the environment. It may be connected to a Geographical Information System.</li>
<li>enable the user to define the start and end points of the trajectory which will be used by the Path Planner to generate the trajectory to be followed by the drone.</li>
<li>display the estimated position of the drone and the data coming from the mission sensors (video, IR, …) and the estimated battery autonomy.</li>
<li>obstacle avoidance will be achieved based on volumetric data from the Lidar or Kinect sensor, without explicit object recognition.</li>
<li>the robust planner in 3D using probabilistic and Evolutionary techniques for unseen events.</li>
<li>the parallel and energy-efficient realisation of hybrid Path Planning algorithms.</li>
<li>Applicability study of SoC for Avionic applications</li>
<li>Real-time volumetric analysis of 3D space.</li>
</ul>
<h2 id="review-of-literature">Review of Literature</h2>
<p>Hota et al in [4] address optimal path planning in three-dimensional space for an aerial vehicle with a bounded turn radius. However, the objective of their work is to calculate a feasible path of minimum length when the initial and final positions and orientations of the vehicle are given. The proposed method is based on 3D geometry. However, even though the approach has simplicity and low computational requirements this approach cannot be implemented on an \(\mu\)UAVs with unconstrained turn radius, i.e. particularly rotary-type air vehicles. Carsten et. al [5] present an interpolation-based planning and replanning algorithm that is able to produce direct, low-cost paths through three-dimensional environments. The algorithm builds upon recent advances in 2D grid-based path planning and extends these techniques to 3D grids. Thus, presenting a number of results demonstrating its advantages and real-time capabilities. However, the robustness of this approach to dynamic changes in the environment is unknown. Fichter et. al in [1] presents a path-planning approach for UAVs, however, this approach is applicable to fixed-wing UAVs and not to the rotary type UAVs. Moreover, these approaches have not been realised in the SoC and their performance in resources-constrained computers is to be investigated. Hachour O. in [2] present a Genetic Algorithm based approach for path planning in autonomous robots. The applicability of this approach is not extendible to UAVs which require planning in the 3D space. Moreover, Genetic Algorithms may not necessarily provide an optimal solution like that of A* or D* algorithms. This work will take more of a hybrid approach and will improve upon the work of Kok et. al[3]; wherein issues with optimality and robustness will be incorporated.</p>
<h2 id="significance-of-study">Significance of Study:</h2>
<p>The results of this research project will augment various emerging realities [Future ME: I don’t claim to see/know the future. But, I think the significance of UAVs is mostly realized and recognised after the Nagorno-Karabakh conflict between Armenia and Azerbaijan. However, many strategists I believe were pointing to this reality a long time ago] and national and regional plans. As such, the results of this work could contribute in the following areas:</p>
<p>Scientific Research: can assist science where the desired locations of study are either remote or dangerous. An example of such areas includes the Fukushima Nuclear disaster, hazardous material sites, and volcanic eruption sites.</p>
<p>Disaster Prevention and Management: can be used for monitoring flood situations, and accident sites and mitigating the situation efficiently and effectively. Moreover, we could use this technology for traffic management during traffic jams.</p>
<p>Environmental Protection/monitoring: this can assist in monitoring illegal fishing, illegal logging in our forests, wildlife protection, and water resources protection. </p>
<h2 id="proceduremethodology">Procedure/Methodology</h2>
<p>Flying in a constrained (obstacles etc) environment under out-of-sight scenarios poses new challenges for the control and navigation of \(\mu\) UAVs. A collision avoidance system is the first step in the direction of autonomous flight capability. Kinect [Future me: due to funding constraints I have to resort to using Kinect for this POC] is used for real-time dense 3D mapping. It is geared towards games and augmented reality, but could also be of great use for robot/UAV perception. Therefore, the acquired depth details are used to generate a 3D map of the space; i.e a space for which we desire an optimal navigation path. Based on the user-specified start and endpoints, the generated 3D map and user-specified coordinates will be used by a Path Planner to find an optimal path— various path-finding algorithms like A<em>, D</em>, Random Graphs, Genetic Algorithm Planner shall be compared for performance evaluation (robustness, energy use, parallelism etc) and a hybrid planning algorithm will be developed. The planner, for a chosen path, will output a sequence of moves for the autopilot of \(\mu\) UAVs, (e.g. PX4 board for autopilot used in Parrot AR drones) will be a trajectory of the \(\mu\) UAV in the space which it is navigating.</p>
<h2 id="impact">Impact</h2>
<p>This research has a direct impact on the applicability of \(\mu\) UAVs in day-to-day uses, from courier service to aerial surveying(land, flood, terrain etc)— in the civilian domain. In the recent past, the autonomy of \(\mu\) UAVs have become as much of a selling point in the UAV industry. However, today’s systems are still designed with user intervention for Path Planning, to some degree. I am committed to studying leading technologies for Onboard Realtime Path Planning solutions, complete with an evaluation of existing techniques, a hybrid extension of the evolutionary algorithm approach for 3D space, and complete documentation— which meets the increasing demand for open knowledge and makes the technology available for civilian use with greater autonomy.</p>
<h2 id="financial-details-future-me-redacted-the-funding-numbers">Financial Details [Future me: redacted the funding numbers]</h2>
<ol>
<li>SoC Board (Xilinx Zedboard) ————————————————— around XXXX INR</li>
<li>Volumetric Sensor (Microsoft Kinect) —————————————— around XXXX INR</li>
<li>Display Panel (HDMI LCD TFT Touch panel) ——————————- around XXXX INR</li>
</ol>
<p>[Future me: nvidia Jetson is a popular choice and works well. However, I was trying to implement the custom FPGA based HW version of the critical components; this is not available in nvidia jetson that only provides gpu accelaration and can be limited by CPU-GPU memory bandwith]</p>
<p>The reason for choosing ZedBoard is that it is an evaluation and development board based on the Xilinx Zynq-7000 Extensible Processing Platform (EPP). Combining a dual Corex-A9 Processing System (PS) with 85,000 Series-7 Programmable Logic (PL) cells, the Zynq-7000 EPP can be targeted for broad use in many applications. The ZedBoard’s robust mix of onboard peripherals and expansion capabilities make it an ideal platform for both novice and experienced designers. The onboard memories, video and audio I/O, dual-role USB, Ethernet, and SD slot will have our design up-and-ready with no additional hardware needed. Target Applications for Zedboard are Embedded vision, Test & Measurement, Motor control, and Software-defined radio— applicability diversity gives this equipment longevity for use in later projects. Kinect is a low-cost COTS sensor for 3D sensing. Moreover, it also has an integrated RGB camera and a microphone. The display panel is for the display of paths during development and demo.</p>
<h2 id="references">References</h2>
<p>[1] Fichter, W. Path Planning for Fixed-Wing UAVs with Small Onboard Computers. In SADCO A2CO.</p>
<p>[2] Hachour, O. (2008). The proposed genetic fpga implementation for path planning of autonomous mobile robot. International Journal of Circuits, Systems and Signal Processing, 2(2), 151-167.</p>
<p>[3] Kok, J., Gonzalez, L. F., Walker, R. A., Gurnett, T., & Kelson, N. A. (2010). A synthesizable hardware evolutionary algorithm design for unmanned aerial system real-time path planning. In Proceedings of the 2010 Australasian Conference on Robotics & Automation.</p>
<p>[4] Hota, S.; Ghose, D., “Optimal path planning for an aerial vehicle in 3D space,” in Decision and Control (CDC), 2010 49th IEEE Conference on , vol., no., pp.4902-4907, 15-17 Dec. 2010.</p>
<p>[5] Joseph Carsten, Dave Ferguson, and Anthony Stentz. 3D Field D*: Improved Path Planning and Replanning in Three Dimensions. IEEE International Conference on Intelligent Robots and Systems October 9 - 15, 2006.</p>["Dawood A Khan"]Prologue Most of this write-up is based on an old proposal I submitted back circa 2014 for funds. However, I hope to continue the research & development, when I get an opportunity, to extend the edge-AI work in UAV domain in one of the following directions (priority based): Development of autonomous unmanned aerial vehicles (UAVs) that use machine learning and computer vision to perform surveillance, reconnaissance, and target acquisition. Use of big data and machine learning algorithms to identify and predict security threats, such as cyber-attacks and physical breaches, in government-related technology systems. Application of machine learning and computer vision to automate the detection and classification of pests, diseases, and other anomalies in agricultural crops to improve yield and reduce losses. Use of machine learning and NLP to develop natural language interfaces for military personnel to access and process vast amounts of data more efficiently and accurately. Development of machine learning algorithms for autonomous decision-making in defence systems, such as target prioritization, route planning, and resource allocation. Integration of IoT technologies and big data analytics to improve the situational awareness of military operations, including the tracking and management of military assets and personnel. Development of deep learning models to improve the accuracy and reliability of remote sensing data for precision agriculture, enabling more efficient use of resources and increased crop yields. Use of machine learning and computer vision to automate the monitoring and analysis of environmental factors, such as weather patterns and soil moisture levels, to support more informed decision-making in agriculture. Exploration of the potential of machine learning and big data analytics in educational technology to improve student learning outcomes and personalize instruction. Use of IoT technologies and machine learning to develop smart classrooms that can optimize learning environments for individual students based on their preferences and performance.Modern C++ for ExaScale AI2023-01-15T00:00:00+00:002023-01-15T00:00:00+00:00https://ddak.github.io/ai,/ml,/programming,/c++/2023/01/15/Modern%20C++%20for%20ExaScale%20AI<h2 id="outline">Outline:</h2>
<ul class="task-list">
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Introduction (This one)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />Package Managers (conan) and Build systems (cmake)</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />C++ Computer vision demo projects: Haar and HOG (added to git repo and referenced here).</li>
<li class="task-list-item"><input type="checkbox" class="task-list-item-checkbox" disabled="disabled" />Visual search & recommendation engine for ExaScale</li>
</ul>
<h2 id="introduction">Introduction</h2>
<p>C++ is a powerful programming language that can be used for a wide range of applications, including AI. One of the reasons why it is well-suited for these tasks is that it offers a high level of control over the underlying hardware, which can be important for optimizing performance on edge devices and embedded systems. C++ language, on low-power edge devices, allows for more efficient use of memory and other resources on devices with limited resources. Additionally, C++ has a rich set of libraries and frameworks that can be used for machine learning and other AI-related tasks, such as PyTorch, TensorFlow, Faiss, dlib, OpenCV, and many more.</p>
<p>To complement the rapid development of AI systems we have a plethora of libraries available in the C++ ecosystem. Here is a list (not exhaustive) of some C++ libraries for AI development:</p>
<ol>
<li>TensorFlow: <a href="https://github.com/tensorflow/tensorflow">https://github.com/tensorflow/tensorflow</a></li>
<li>PyTorch: <a href="https://github.com/pytorch/pytorch">https://github.com/pytorch/pytorch</a></li>
<li>dlib: <a href="https://github.com/davisking/dlib">https://github.com/davisking/dlib</a></li>
<li>Eigen: <a href="https://github.com/eigenteam/eigen-git-mirror">https://github.com/eigenteam/eigen-git-mirror</a></li>
<li>OpenCV: <a href="https://github.com/opencv/opencv">https://github.com/opencv/opencv</a></li>
<li>CatBoost: <a href="https://github.com/catboost/catboost">https://github.com/catboost/catboost</a></li>
<li>ArmNN: <a href="https://github.com/Arm-software/ArmNN">https://github.com/Arm-software/ArmNN</a></li>
<li>lightgbm: <a href="https://github.com/microsoft/LightGBM">https://github.com/microsoft/LightGBM</a></li>
<li>mlpack: <a href="https://github.com/mlpack/mlpack">https://github.com/mlpack/mlpack</a></li>
<li>Faiss: <a href="https://github.com/facebookresearch/faiss">https://github.com/facebookresearch/faiss</a></li>
<li>shogun: <a href="https://github.com/shogun-toolbox/shogun">https://github.com/shogun-toolbox/shogun</a></li>
<li>GRT (Gesture Recognition Toolkit): <a href="https://github.com/nickgillian/grt">https://github.com/nickgillian/grt</a></li>
<li>MXNet: <a href="https://github.com/apache/incubator-mxnet">https://github.com/apache/incubator-mxnet</a></li>
<li>Armadillo: <a href="http://arma.sourceforge.net/">http://arma.sourceforge.net/</a></li>
<li>MLPACK: <a href="https://github.com/mlpack/mlpack">https://github.com/mlpack/mlpack</a></li>
<li>XGboost: <a href="https://github.com/dmlc/xgboost">https://github.com/dmlc/xgboost</a></li>
<li>Shark: <a href="https://github.com/Shark-ML/Shark">https://github.com/Shark-ML/Shark</a></li>
<li>CNTK: <a href="https://github.com/Microsoft/CNTK">https://github.com/Microsoft/CNTK</a></li>
<li>ONNX: <a href="https://github.com/onnx/onnx">https://github.com/onnx/onnx</a></li>
</ol>
<p>There are many other libraries and framworks, however, some of them are not in active development or have been merged/included with the popular frameworks mentioned above.</p>
<p>For example, PyTorch (LibTorch) is written in C++, this is designed to address the use cases where the use of the Python is infeasible due to performance and portability requirements, such as in low latency, high performance or multithreaded environments, such as embedded systems, video games or production servers. With LibTorch, ML engineers can build and deploy their models in C++ environments, such as native mobile and embedded systems, or in multithreaded environments with strict latency requirements.</p>
<h2 id="project-setup-for-a-dummy-project">Project setup for a dummy project</h2>
<p>I will use a simple structure for this application. Here is the output of the tree command to get the folder structure (pre-build stage)</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>|____APP
|____application.cpp
|____application.h
|____CMakeLists.txt
|____conanfile.txt
</code></pre></div></div>
<h2 id="conan">Conan</h2>
<p><a href="https://conan.io/">Conan</a> is a package manager for C++. It is used to manage and distribute dependencies in your C++ projects. To install Conan, you need to have Python installed on your system (I am using python 3.9). Conan provides packages via <a href="https://conan.io/center/">Conan center</a>, which is a repository of prebuilt binaries for various machine architectures, that the Conan python client uses to download the required packages.</p>
<p>Here are the steps to install Conan on your system:</p>
<ol>
<li>Install the Conan CLI: You can install Conan using pip, which is the Python package manager. To do this, open the terminal and run the following command:
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pip <span class="nb">install </span>conan
</code></pre></div> </div>
</li>
<li>Configure Conan: After installing Conan, you need to configure it to work with your system. You can do this by running the following command:</li>
</ol>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>conan config <span class="nb">install</span>
</code></pre></div></div>
<ol>
<li>Add remote repository: By default, Conan doesn’t have any remote repositories to search packages. You can add a remote repository to search packages. For example, you can add the Conan center repository, which is the default public repository for Conan packages, by running the following command:</li>
</ol>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>conan remote add conan-center https://center.conan.io
</code></pre></div></div>
<p>For more details about Conan check the <a href="https://academy.jfrog.com/path/conan">Jfrog’s conan</a> course and/or <a href="https://docs.conan.io/en/latest/">Conan documentation</a>.</p>
<p>setting conanfile.txt:</p>
<p>To use Conan in your project, you need to create a <code class="language-plaintext highlighter-rouge">conanfile.txt</code> file in our project root directory. This file will contain information about your project’s dependencies (open cv and dlib). Here’s an example <code class="language-plaintext highlighter-rouge">conanfile.txt</code>:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">[</span><span class="n">requires</span><span class="p">]</span>
<span class="n">opencv</span><span class="o">/</span><span class="mf">4.5</span><span class="p">.</span><span class="mi">5</span>
<span class="p">[</span><span class="n">generators</span><span class="p">]</span>
<span class="n">cmake</span>
</code></pre></div></div>
<p><strong>Note</strong>: I only have <code class="language-plaintext highlighter-rouge">opencv</code> as a dependency; getting <code class="language-plaintext highlighter-rouge">dlib</code> to work with my <code class="language-plaintext highlighter-rouge">Mac M1 Pro</code> was problematic. I had to install dlib from source- check the instruction in <code class="language-plaintext highlighter-rouge">dlib</code> <a href="https://github.com/davisking/dlib">repo</a>. For other architecture types, you should be able to specify <code class="language-plaintext highlighter-rouge">dlib</code> dependency in the <code class="language-plaintext highlighter-rouge">conanfile.txt</code>. Here is how I built and installed <code class="language-plaintext highlighter-rouge">dlib</code>.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone git@github.com:davisking/dlib.git
<span class="nb">cd </span>dlib
<span class="nb">mkdir </span>build <span class="o">&&</span> <span class="nb">cd </span>build
cmake ..
cmake <span class="nt">--build</span> <span class="nb">.</span>
make <span class="nb">install</span>
</code></pre></div></div>
<h2 id="cmake">cmake</h2>
<p>setting CMakeLists.txt</p>
<p>To use the <code class="language-plaintext highlighter-rouge">cmake</code> build system in your project you need to create a <code class="language-plaintext highlighter-rouge">CMakeLists.txt</code> file in your project root directory. This file will contain information about your project’s dependencies. Here’s an example of <code class="language-plaintext highlighter-rouge">CMakeLists.txt</code>:</p>
<pre><code class="language-Python">cmake_minimum_required(VERSION 2.8.12)
project(APP)
# C++ 20 standard
add_compile_options(-std=c++20)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
find_package(dlib REQUIRED)
# Using the "cmake" generator
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
add_executable(app application.cpp)
target_link_libraries(app CONAN_PKG::opencv dlib::dlib)
</code></pre>
<p>Note: I use <code class="language-plaintext highlighter-rouge">find_package</code> in CMakeList to find and reference the <code class="language-plaintext highlighter-rouge">dlib</code> package I built in the previous step. This step is not needed if you were able to install <code class="language-plaintext highlighter-rouge">dlib</code> using the Conan package manager, and in that case, you may have to add <code class="language-plaintext highlighter-rouge">CONAN_PKG::dlib</code> reference in the <code class="language-plaintext highlighter-rouge">target_link_libraries</code>; if not already done so by Conan. This can be controlled in Conan, see <a href="https://docs.conan.io/en/latest/integrations/build_system/cmake/cmake_find_package_generator.html">conan generators</a>.</p>
<p>In this writeup, I give a basic overview of how to install conan, use Conan, and use CMake build system. For more details, you can refer to CMake and Conan documentations. Moreover, there are many other package managers (vcpkg, hunter etc.) and build systems (bazel, ninja etc.) for C++ development. I am just going over one particular combination of a package manager and a build system (albeit, a popular one) to set up some demo projects, <a href="https://github.com/DDAK/AI_CPP">which I have put in my git repo</a>.</p>
<h2 id="building-and-running-projects">Building and running projects</h2>
<p>I will take the example of the <code class="language-plaintext highlighter-rouge">haar</code> project in the above-mentioned repository. However, the build instructions are mentioned for each project in the corresponding readme.md.</p>
<h3 id="compiling-haar-c--program">Compiling haar C++ program</h3>
<p>Go into the haar folder and type:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir </span>build <span class="o">&&</span> <span class="nb">cd </span>build
conan <span class="nb">install</span> ..
cmake ..
cmake <span class="nt">--build</span> <span class="nb">.</span>
</code></pre></div></div>
<p>This will build the program. Sometime, you might need to install packages with <code class="language-plaintext highlighter-rouge">conan install .. --build=missing</code> option enabled, when precompiled binaries are not available in the conan-center (remote repository).</p>
<p>Running the program
Download the pre-trained cascade detector for the opencv git <a href="https://github.com/opencv/opencv/tree/master/data/haarcascades">repo</a>. The opencv repo has many pre-trained haar detectors and I am using one of those in the example below.</p>
<p>You can run the <code class="language-plaintext highlighter-rouge">haar</code> program from the build folder while passing the pre-trained haar cascade file with the path.</p>
<p>For example:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>bin\haar haarcascade_frontalcatface.xml
</code></pre></div></div>
<p>[Coming NEXT…]the Exascale AI project using Modern CPP.</p>["Dawood A Khan"]Outline: Introduction (This one) Package Managers (conan) and Build systems (cmake) C++ Computer vision demo projects: Haar and HOG (added to git repo and referenced here). Visual search & recommendation engine for ExaScaleMundanity of Excellence2023-01-01T00:00:00+00:002023-01-01T00:00:00+00:00https://ddak.github.io/tech,/programming,/tdd,/xp/2023/01/01/Mundanity<h1 id="im-not-a-great-programmer-im-just-a-good-programmer-with-great-habits--kent-beck">“I’m not a great programmer; I’m just a good programmer with great habits.” ― Kent Beck</h1>
<p>Daniel F. Chambliss in his paper “The Mundanity of Excellence: An Ethnographic Report on Stratification and Olympic Swimmers”
studied and examined the swimmers in their natural social settings, in order to understand their culture and practices.</p>
<p>He found that the key to excellence in swimming is not just natural talent or intense training, but also the development of certain
“habits and routines” that allow the swimmers to consistently perform at a high level. Chambliss found that these “habits and routines”
were often mundane and unremarkable, but they were crucial for maintaining the discipline and focus needed to succeed in the competitive
world of Olympic swimming.</p>
<p>Overall, excellence in “any field” <requires> a combination of <talent, hard work, and the development of habits and routines> that allow
individuals to consistently perform at a high level and produce excellent results (of great quality). The important key is to: recognize
the mundane aspects of excellence, as they can be just as important as more visible factors like talent and training.</requires></p>
<p>If you are interested in the paper follow <a href="https://academics.hamilton.edu/documents/themundanityofexcellence.pdf">this link</a></p>["Dawood A Khan"]“I’m not a great programmer; I’m just a good programmer with great habits.” ― Kent BeckThe meeting madness and some creative antidotes.2020-02-23T00:00:00+00:002020-02-23T00:00:00+00:00https://ddak.github.io/productivity/2020/02/23/meetings<p><img src="/images/meet_1.jpeg" alt=""Too much information sharing cartoon, Global Integrations” licensed under CC BY-NC-SA 2.0"" /></p>
<p>I have taken part in way too many meetings during my professional career that was still going on an hour so later. Some of the reasons for such long meetings usually boiled down to:</p>
<ol>
<li>the discussion revolving around things that didn’t need to be raised with everyone present,</li>
<li>discussing things that weren’t part of the original agenda, repetition of content, etc.</li>
</ol>
<p>The feelings at the end of such meetings were far from being satisfied. We should not have a meeting as a reason to drag everyone into a room and put everything on hold for the duration of the meeting. Meetings that are called at the last minute or constantly postponed are an indication that the person does not have respect for the attendees.</p>
<p>A meeting is when attendees explain and discuss their viewpoints with each other regarding an issue to reach common ground, an agreement, or understanding. The reasoning is an essential basis which helps us to express ideas. This enables us to have a dialogue, discussion, argument, and debate to reach a common understanding. As attendees of a meeting, when we are presenting our point of view, we should accept that other attendees are reasonable, and have intellect, potential, abilities, and desires. On the contrary, if we believe that other attendees are lacking any of the above capabilities then we should forgo any expectation of having a meaningful meeting. Such a meeting is always biased by the attendee who thinks of others as without reason or intellect.</p>
<p>We should have a clear objective for a meeting (including for regular ones).</p>
<p><img src="/images/meet_2.jpeg" alt=""Not all discussions need a meeting, Global Integrations, licensed under CC BY-NC-SA 2.0"" /></p>
<ol>
<li>
<p>If you have to communicate(one-way); just send an email with a communique and don’t hold everyone hostage to a meeting where just one person is just talking.</p>
</li>
<li>
<p>If it is a chance to catch up on what everyone is doing — have a better process and product, rather than drag everyone to a meeting.</p>
</li>
<li>
<p>If it is an opportunity to gauge how each individual is doing, where an individual sees himself, and to identify potential problems — Just have proper one-on-ones.</p>
</li>
</ol>
<p>In general, we can think of meetings clustered into the following groups:</p>
<ol>
<li>For warning: with a rebuke, there is usually no disagreement between the two parties as they believe in the same ideas and principles; unless the warning is unreasonable and based on wrong pretexts.</li>
<li>For discussion: there can be a disagreement among those who are involved in the dialogue. This should be carried out respectfully. Constructive disputes and debates are recommended it can lead to success and cooperation.</li>
<li>For dispute: we should avoid useless dialogue, destructive dispute or argument for it wastes time and effort and leads to hate, bitterness, and hostility.</li>
</ol>
<p><img src="/images/meet_3.jpeg" alt=""Who is your unnecessary meeting participant?, Global Integrations, licensed under CC BY-NC-SA 2.0"" /></p>
<p>Duration and flow of a meeting:</p>
<p>IMHO, the meeting should always be finished within 30 minutes or so, the agenda should be pre-shared with all attendees. Impromptu meetings are useless and just one-way communication. If a topic needs more than 30 mins then chunk the agenda into several meetings of 30 mins each. The minutes should be recorded by one of the participants. Minutes of the meeting (a summary of items discussed and action items) should be sent to every stakeholder in an email promptly after the meeting. The meeting should be recorded on the calendar for all the participants.</p>
<p>How to conduct a meeting?</p>
<p>The primary objective of a meeting should be to engage, inspire and achieves results.</p>
<ol>
<li>
<p>The meeting should be goal-oriented. If your goal is to solve an issue or add a new feature, then everything discussed at the meeting should (only) reflect this in some way. Multiple issues cutting across multiple experiences should be part of separate meetings.</p>
</li>
<li>
<p>If you have a purpose, you must have a meeting agenda. This is a list of the things you want to cover in the time available and must be shared with stakeholders ahead of the time. Itemizing the agenda allows us to estimate the time required for the meeting and identify the relevant people who should be part of the meeting.</p>
</li>
<li>
<p>A meeting should always start on time and only go for the allotted time. If some items on the agenda require more time than is available, they should be moved to the next meeting or, if urgent, a separate meeting should be held with those immediately involved.</p>
</li>
<li>
<p>The purpose of a meeting should be relevant to those in attendance (and if it isn’t, why are they there then?), and the intent of having the attendance is that you want them to participate in the discussion and be involved in the decision-making. People will become genuinely enthused about your meetings if they are encouraged to participate and can see that something is being achieved.</p>
</li>
</ol>
<p><img src="/images/meet_4.jpeg" alt=""Meetings, Nothing More Than Meetings, Brian Solis, licensed under CC BY 2.0"" /></p>
<p>Mannerism for attendees:</p>
<ol>
<li>
<p>Be sincere: we should not speak to display our knowledge or show our eloquence in a matter at hand. Let others speak as well.</p>
</li>
<li>
<p>Lower your voice: speak without raising your voice as it reflects a lack of manners and shows you being emotionally attached to the topic. Shun excessive talk and badmouthing others.</p>
</li>
<li>
<p>Don’t insult: don’t insult, abuse, use obscene words, or denigrate others.</p>
</li>
<li>
<p>Know about the topic: It is also important to study the issue beforehand, to consider the words you will say beforehand. It is very serious not to understand the meaning of words and it is insincere talk without the knowledge (Note: for the same reason it important to pre-share the agenda of the meeting with a summary and purpose).</p>
</li>
<li>
<p>Levels of understanding: an etiquette of a proper dialogue is to address people according to their understanding and knowledge.</p>
</li>
<li>
<p>Choice of vocabulary: use simple wording and terminology, even when discussing certain special fields of knowledge. After all the agenda of the meeting is to make people understand and allow them to extend their cooperation.</p>
</li>
<li>
<p>Don’t interrupt: If a person is talking let him finish; we should not interrupt them.</p>
</li>
<li>
<p>Discuss based on facts and figures: firstly, put forth the obvious/self-evident truths which everyone agrees with. With everyone on the same page, the gaps get bridged allowing the discussion to proceed in a positive direction. On the contrary, if we raise controversial issues at the outset, it can make a meeting restricted and tense with a debate.</p>
</li>
<li>
<p>Avoid: finally, it is very important to avoid useless disputes and arguments because it leads to resentment and hostility.</p>
</li>
</ol>
<p>PS: Errors and omissions are regretted and are my own.</p>["Dawood A Khan"]Stranded on a “recommendation-island”2020-02-09T00:00:00+00:002020-02-09T00:00:00+00:00https://ddak.github.io/tech/2020/02/09/recommendation-hell<p>When signing up for a Netflix account I was asked about the ‘shows that interest me’ –I presume to build my recommendation profile. However, since that day I have been stuck on a “recommendation-island” which is rife with the monotonicity based on my interest at the signup time.</p>
<p>Seasons change, our mood changes, our situations change, our circumstances changes. Human tastes can change/adapt over time. Then why should a recommendation engine get stuck on an island, based on the interests I selected at the start, and not adapt?</p>
<p>Why do these engines and people building them forget that:</p>
<ol>
<li>Our interests change over time,</li>
<li>We often don’t know what actually interests us?</li>
</ol>
<p>The Recommendation engine thinks that I like Japanese anime; when in fact I just liked one particular series.</p>
<p>a.) To avoid being stuck on an island, a user should be, maybe, periodically asked to update their interests.</p>
<p>b.) We could also use an 80-20 rule, 80% allocated to my expressed interest and allocate 20% to random choices. Thereafter, update the profile if a selection is made from the random-set; maybe use something that is elegant (bayesian, multi-arm bandit etc) to update the recommendation profile.</p>
<p>The idea of these update mechanisms is to identify and capture the implied interests, periodically. The implied interest should tailor the recommendation engine to my current taste somewhat accurately; albeit with a grain of salt. Nevertheless, at the very least this scheme will rescue me from the “recommendation-island”.</p>
<p>PS: it is not just Netflix; Amazon Prime has the same problem, the engine assumes I like Bollywood movies and it is fair for me to browse through multiple pages to get to the actual content I want to watch. Just because there is some inferred feature in my profile – that indicates to the recommendation engine that I like to watch Bollywood movie– doesn’t mean/indicate that I like to watch Bollywood movies.</p>
<p><a href="https://www.linkedin.com/pulse/stranded-recommendation-island-dawood-khan/">Originally on linkedin</a>
#ML, #AI, #Netflix #Amazon #Prime</p>["Dawood A Khan"]When signing up for a Netflix account I was asked about the ‘shows that interest me’ –I presume to build my recommendation profile. However, since that day I have been stuck on a “recommendation-island” which is rife with the monotonicity based on my interest at the signup time.