<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jaimin-k on Medium]]></title>
        <description><![CDATA[Stories by Jaimin-k on Medium]]></description>
        <link>https://medium.com/@jaimin-k?source=rss-5b28ba3cf255------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YtrqCAenBDuzVn6l3-iEjA.png</url>
            <title>Stories by Jaimin-k on Medium</title>
            <link>https://medium.com/@jaimin-k?source=rss-5b28ba3cf255------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 21:35:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jaimin-k/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Wise Words & Wisdom Winnings: Teaching the words before work]]></title>
            <link>https://medium.com/@jaimin-k/wise-words-wisdom-winnings-teaching-the-words-before-work-d54ea5043437?source=rss-5b28ba3cf255------2</link>
            <guid isPermaLink="false">https://medium.com/p/d54ea5043437</guid>
            <category><![CDATA[education]]></category>
            <category><![CDATA[education-reform]]></category>
            <category><![CDATA[language-learning]]></category>
            <category><![CDATA[higher-education]]></category>
            <category><![CDATA[edtech]]></category>
            <dc:creator><![CDATA[Jaimin-k]]></dc:creator>
            <pubDate>Thu, 12 Nov 2026 20:03:17 GMT</pubDate>
            <atom:updated>2026-11-16T04:16:23.086Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Bridging the gap between knowing the words and using them to think, reason, and solve.</em></p><h3>Abstract</h3><p>This study is about vocabulary: which words to teach, and how to get students using them instead of just recognizing them. I followed 17 students in a computer science course through three checkpoints: a word-awareness check, a data and algorithms check, and a game they code</p><p>At baseline, 13 of the 17 (76%) reached High or Medium proficiency. At the mid check, when the questions asked students to apply the words, that fell to 10 (59%). On the final project, 15 of 17 (88%) reached High or Medium proficiency, beating our goal of about 80%.</p><h3>Knowing a word is not the same as using it</h3><p>Early in the study, my students could tell me what a loop was. Ask them to build one that stops when a score reaches ten, and half the room froze. They had the word. They did not yet have what the word lets you do.</p><p>Students often skip past the key words in a problem. This study looked at the step before that. Engineers live with the same gap. A specification full of words like <em>tolerance</em>, <em>constraint</em> and <em>requirement</em> is only useful to someone who can turn each word into a decision. That is the skill I wanted to teach: from recognizing a word, to applying it, to building with it.</p><h3>The words and the routine</h3><p>Explicit vocabulary teaching is one of the best-documented strategies in education. One synthesis links it to a 33-percentile-point gain in achievement (Marzano, 2004), and a meta-analysis found a large effect on comprehension (Stahl &amp; Fairbanks, 1986). It also matters for fairness: students who start with more words learn new words faster, so the gap widens unless school closes it, a pattern known as the <em>Matthew effect</em> (Stanovich, 1986).</p><p>The study followed one rule: less is more. I taught five to seven subject words per unit and three to five academic words per week, because a long list adds load without adding learning.</p><p>It then ran as a loop of plan, act, analyze and adjust. Give a baseline task, sort the student work into High, Medium and Low proficiencies, pick one strategy, set a goal, teach, check again, adjust, and check a final time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e9oVbPwC66f3PAbILkZ2Bw.png" /><figcaption><em>The study in sequence. The counts are the 17 students in the focus group.</em></figcaption></figure><h3>Where the three tiers &amp; Look, Aim, Mark fits</h3><p>The study used the Beck’s approach with three tiers of words (Beck, McKeown &amp; Kucan, 2013). Tier 1 words are everyday words. Tier 2 words are academic words that show up in every class, like <em>analyze</em>, <em>interpret</em> and <em>justify</em>. Tier 3 words belong to one subject, like <em>algorithm</em>, <em>metadata</em> and <em>primary key</em>.</p><p>Computer science adds a twist that makes it a good test case. It borrows everyday words and gives them exact meanings: <em>loop</em>, <em>table</em>, <em>key</em>, <em>class</em>, <em>string</em>, <em>bug</em>. A student who knows the Tier 1 meaning can be more confused than one who knows nothing, because the familiar meaning gets in the way.</p><p>This is where the <strong>Look, Aim, Mark</strong> routine also fits. <em>Look</em> became the moment to spot the words you are unsure of. <em>Aim</em> meant reading the Tier 2 verb, because <em>analyze</em> and <em>construct</em> ask for different products. <em>Mark</em> gained a vocabulary layer: box the Tier 3 terms, circle the task verb, and put a question mark by any word you cannot use yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3hsbA8tI9j9XrxIpIvuQDA.png" /><figcaption>The three tiers, the mark each one gets, and four words computer science borrows from everyday speech.</figcaption></figure><h3>The vocabulary strategies implemented</h3><p>I built the study on two strategies which fits best for my CS course. <em>Target Term Spotlight</em> gets students to recognize a word. <em>Concept Connections</em> gets them to apply it. Together they aim at mastery: recognition plus application. The rest came in as adjustments after the mid check.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZAH0XFmcgyN8wbCXyvDvw.png" /></figure><p>The common thread is that every strategy makes students say or write the word in use, not just hear it. That is the gap the mid check exposed.</p><h3>Three checkpoints</h3><p>Each checkpoint asked for more than the one before: first recognize the words, then apply them, then build with them. The results below follow a focus group of 17 students who completed all three. Two sections took the first two checks: 36 students the baseline and 32 the mid check.</p><ol><li><strong>Baseline: a word-awareness check.</strong> Students rated 33 words from 1 (“I have never seen this word”) to 5 (“I can use it correctly in context”), then answered 18 short items: multiple choice, matching, and picking the best example of a word. It was not graded.</li><li><strong>Mid: a data and algorithms check.</strong> Twenty-three items in three parts: Tier 2 task verbs, database terms, and pseudocode.</li><li><strong>Post: a game built in Scratch.</strong> Students planned and built a maze game, then explained their design using the target words.</li></ol><p>Every paper was sorted with the same three criteria. <strong>High</strong> uses all the subject language accurately and in context. <strong>Medium</strong> uses most of it, but the application is incomplete or slightly off. <strong>Low</strong> uses less than half, or gives definitions with no application. Our goal was that at least 79.5% of the focus group would reach High or Medium performance on the final task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7EzV97LsKFXo80k3Ob6Eg.png" /></figure><h3>Observations</h3><p>The class met its goal on the final project: 15 of 17 students reached High or Medium (88%), against a target of 79.5%. The path there was not a straight line, and the dip in the middle taught me the most.</p><p><strong>Students knew the everyday words, not the ones the course runs on.</strong> At baseline, 36 students rated 33 words. About 80% said they could explain or use the everyday words, 60% the academic words, and 41% the computer science words. The lowest were <em>metadata</em> (11%), <em>pseudocode</em> (17%) and <em>data cleaning</em> (19%). <em>Artificial intelligence</em> sat near the top at 72%: students hear about it everywhere, which is not the same as knowing what it is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l5kjmRaW3E2faGeVA2huSw.png" /><figcaption><em>How 36 students rated 33 words at baseline. The colored box beside each word gives its tier.</em></figcaption></figure><p><strong>Recognition looked strong, until the checks asked for use.</strong> At baseline, 13 of the 17 (76%) were High or Medium, because picking the right definition is the easiest thing to show. At the mid check the questions asked students to apply the words to databases and pseudocode, and High or Medium fell to 10 (59%).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ykjr3cgu10x5hMWRhyYzzA.png" /><figcaption>The focus group at each checkpoint. Right: the share at High or Medium against the goal.</figcaption></figure><p><strong>The mid check showed exactly where students stalled.</strong> Every word tested at both checks improved: among the 24 students who took both, <em>condition</em> went from 15 to 20 correct and <em>loop</em> from 17 to 22. But across the 23 mid-check items, students got 83% of the Tier 2 task verbs right, 65% of the database terms and 61% of the pseudocode. The hardest items asked for precise use: the structure of an ER diagram (44%), predicting a program’s output (44%) and spotting a derived attribute (47%).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qj5BWlmH1zjTIVOXQ8bR6w.png" /><figcaption><em>Left: words tested at both checks. Right: every mid-check item, grouped by the kind of word it tested.</em></figcaption></figure><p><strong>After the adjustments, students moved up.</strong> I added talk turns, sentence frames, pseudocode think-alouds and quick writes after the mid check. Between mid and post, 8 of the 17 students moved up a level and 1 moved down. Low fell from 7 to 2 (down 71%), Medium rose from 7 to 10 (up 43%) and High performance batch of students rose from 3 to 5 (up 67%).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NfHBu2q521GvLfTKLZxdWA.png" /><figcaption><em>How the 17 students moved between levels. Each band is a group of students.</em></figcaption></figure><p><strong><em>A caution on all of this</em></strong>: 17 students is a small group, and each checkpoint measured something harder than the one before. Students could name the words early, needed help to use them, and used them well once the teaching made them say and write the words in context.</p><h3>Looking at the Low, Medium and High</h3><p>The criteria stayed the same at every checkpoint, but the evidence changed shape.</p><ul><li><strong>Baseline.</strong> Most students could pick the right definition, but few could say what a word does. Familiarity was high and depth was low: a student might rate <em>loop</em> a 4 and still be unable to give an example of one.</li><li><strong>Mid, a Medium level.</strong> The student matched Tier 3 words to the right Tier 2 job. Sorting students by grade is <em>classifying</em> data. Age worked out from a birthdate is a <em>derived</em> attribute. The same paper then missed how an ER diagram connects two entities through a relationship.</li><li><strong>Post, a High level.</strong> The student split a maze game into three parts before building anything: user input, score and game over. The game ran inside a loop, a variable tracked the score, and conditions checked for walls, coins and a win.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fKqhbBlXFA1o5pfRYtiIdA.png" /><figcaption><em>A High level task: a maze game planned in three parts and built with a loop, a variable and conditions.</em></figcaption></figure><p>The project rubric shows the same order of learning. Most students had every part of the game at least partly working. Loops came easiest (94%) and conditions were harder (71%). Explaining the design with the target words came last (65%). Students could build before they could talk about what they built, which is why the sentence frames and talk turns mattered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MCRGC8AJTnwbJe7fU5oCw.png" /><figcaption><em>The final project scored part by part for each student in the focus group.</em></figcaption></figure><h3>The chemistry of vocabulary words:</h3><p>Stanich teaches physics and chemistry, including AP and dual-credit chemistry, and ran a parallel study in his classes. His students faced a different word problem. AP free-response questions are scored on their task verbs, and students were losing points on words they thought they understood.</p><ul><li><em>Explain</em> means give the cause, not just the fact.</li><li><em>Justify</em> means make a claim and back it with evidence.</li><li><em>Predict</em> means state an outcome and the reasoning behind it; a prediction alone earns no credit.</li></ul><p>His strategy was to teach the rubric itself. Once per unit, students scored their own answer with the official AP rubric, then scored a classmate’s answer and gave feedback, then wrote their own rubric for a prompt he set. High answers went from 5 to 9 to 15 of 26 students, and Low answers fell from 7 to 4 to 2. Answers became more structured, used more Tier 3 terms, matched the task verb more often, and left out fewer parts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EOGu-WfMRnk4e_ZiQ9Ht8Q.png" /><figcaption><em>Computer science and chemistry against the same goal.</em></figcaption></figure><p>Both classes ended in the same place: most students using the language of the subject, not just recognizing it.</p><h3>From basics to college work</h3><p>The course is built like a ladder of words, and each step uses the last one. Students start by recognizing basic terms like <em>hardware</em>, <em>input</em> and <em>output</em>. With data they learn to interpret: <em>dataset</em>, <em>outlier</em>, <em>metadata</em>. With algorithms they learn to decompose a problem using <em>variable</em>, <em>condition</em>, <em>loop</em> and <em>pseudocode</em>. With projects, they build by applying what they learn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTBb8J-hfhqs1ZonPqKpOg.png" /><figcaption><em>How the course’s words build from basics to college-level work.</em></figcaption></figure><p>The top step is where this pays off. In a dual-credit course taken in high school, such as our networking and cybersecurity course, the words become <em>protocol</em>, <em>encryption</em> and <em>authentication</em>, and students are graded the way a college grades them. In engineering, a requirement like “must hold 2 kilograms with a safety factor of 2” is a sentence of Tier 3 words: a number, a unit and a condition. A student who has practiced turning words into decisions since ninth grade reads that line as a plan, not as noise.</p><h3>Why this matters?</h3><p>Every subject in schools runs on words students half know. In math, a student who can define slope still stalls when a problem asks them to <em>interpret</em> it, and verbs like <em>determine</em>, <em>estimate</em> and <em>justify</em> decide what a complete answer looks like. In world languages, every word is new, so connecting a word to something familiar and breaking it into parts is the subject itself. In social studies, <em>primary source</em>, <em>bias</em> and <em>checks and balances</em> only become useful when students use them to <em>evaluate</em> a document. In engineering, a design brief is a list of requirements, and missing one word like <em>maximum</em> can sink a project. And in computer science, a program is vocabulary that runs: every loop, condition and variable is a word doing a job.</p><h3>What I would keep, adjust and do differently</h3><p>Three questions close the study: what would I keep, what would I adjust, and what would I do differently next time?</p><ul><li><strong>Keep:</strong> Target Term Spotlight at the start of every lesson, and the limit of five to seven subject words per unit. Fewer words, used more often, stuck better.</li><li><strong>Adjust</strong> the baseline. A self-rating and a recognition quiz measured familiarity, not use, so the baseline made the class look stronger than it was. Next time it will include one short task where students have to use the words.</li><li><strong>Do differently:</strong> start talk turns and sentence frames in the first week instead of after the mid check. The dip at mid was partly the cost of waiting.</li></ul><h3>The intriguing goal</h3><p>The goal was met. 15 out <strong>of 17</strong> students reached High or Medium on a project that asked them to build with the words, up from 10 at the mid check, and Low fell from 7 students to 2. In chemistry, High answers tripled. Two subjects with two different strategies reached the same finding: <strong>students learn a word when they have to use it to do something</strong>.</p><p>The take away for me is what I found in the analysis of evidence of student’s work. The way students use words shows how far they understand a subject, just as their marks on a page show how they read a problem. Both are evidence that a final grade hides that a student scores.</p><p>This intrigues me more for how to see a student’s understanding while it is still forming, in the words and marks they produce, and how to give each student one small, specific next step. A teacher can do that for one class. With careful tools, including language models that read student work and suggest feedback a teacher approves, it could be done for every student in every course, from a ninth-grader to a college senior working on a problem.</p><h3>Acknowledgments</h3><p>This study grew out of our school’s professional development on vocabulary, led by our instructional coaches, including Kenton Armbruster, whose guidance helped shape my work and thinking throughout this process. I also want to acknowledge Anthony Stanich, my partner in this comparative collaboration examining vocabulary teaching strategies. Together, we explored these strategies and presented our findings to fellow teachers through a poster <em>Wise Words and Wisdom Winnings</em>. Anthony contributed to the chemistry results and shared insightful perspectives during our conversations about how students read and interpret problems.</p><h3>Citations</h3><ul><li>Beck, I. L., McKeown, M. G., &amp; Kucan, L. (2013). <a href="https://www.guilford.com/books/Bringing-Words-to-Life/Beck-McKeown-Kucan/9781462508167"><em>Bringing Words to Life: Robust Vocabulary Instruction</em></a> (2nd ed.). Guilford Press.</li><li>Marzano, R. J. (2004). <a href="https://www.ascd.org/books/building-background-knowledge-for-academic-achievement?variant=104017E4"><em>Building Background Knowledge for Academic Achievement: Research on What Works in Schools</em></a>. ASCD.</li><li>Stahl, S. A., &amp; Fairbanks, M. M. (1986). <a href="https://doi.org/10.3102/00346543056001072">The effects of vocabulary instruction: A model-based meta-analysis</a>. <em>Review of Educational Research, 56</em>(1), 72–110.</li><li>Stanovich, K. E. (1986). <a href="https://doi.org/10.1598/RRQ.21.4.1">Matthew effects in reading: Some consequences of individual differences in the acquisition of literacy</a>. <em>Reading Research Quarterly, 21</em>(4), 360–407.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d54ea5043437" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Look, Aim, Mark (LAM): What students scribbles told me more than their answers]]></title>
            <link>https://medium.com/@jaimin-k/look-aim-mark-lam-what-students-scribbles-told-me-that-their-answers-didnt-b4b4b8e4af10?source=rss-5b28ba3cf255------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4b4b8e4af10</guid>
            <category><![CDATA[education]]></category>
            <category><![CDATA[engineering-education]]></category>
            <category><![CDATA[higher-education]]></category>
            <dc:creator><![CDATA[Jaimin-k]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 18:45:01 GMT</pubDate>
            <atom:updated>2026-11-11T18:59:03.559Z</atom:updated>
            <content:encoded><![CDATA[<p>A study on making students thinking visible through LAM</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mg5RC9u0sk1y9SGVtpsp1g.png" /><figcaption>LAM routine for classrooms</figcaption></figure><p><strong><em>Abstract</em></strong></p><p>Over the course of a semester at Southport High School, the Look, Aim, Mark routine was implemented as a structured classroom strategy to help students read, interpret, and understand tasks before beginning to solve them. The routine was incorporated into my instruction across multiple courses, including Introductory Computer Science and the dual-credit courses IT Fundamentals and Cybersecurity, which are part of the school’s broader course offerings. Student use of the strategy and task performance were evaluated at three points: baseline, mid-check, and post-check. The percentage of students who marked the page increased from 46% at baseline, when no explicit instruction was provided, to 64% after the routine was introduced. Fully correct responses decreased from 64% at baseline to 57% at the mid-check before increasing to 86% at the post-check, which involved the most challenging task of the three.</p><p>These are classroom observations from a small group: 42 students and three tasks of rising difficulty. This study was not just specific to computer science but was aimed to make students thinking visible because knowing and analysing <em>what</em> they marked shows how they read the task, and a final grade never shows that.</p><h3>The teachers did the homework first:</h3><p>The routine did not just start directly in the classrooms. The instructional coaches placed it on a simple ladder. First <em>what does it say</em>, then <em>what does it mean</em>, then how it connects to other ideas, then what you think about it.</p><p>The coaches surveyed the teachers on how we each start students on a new text or task. Most of us said we have students read or look the whole thing over first. Fewer said we name the purpose, and fewer still said we have students annotate. Those three habits became three verbs that every department could share.</p><p>Then we did the homework ourselves. We marked up a task from our own subject the way we would want a student to, and departments compared notes. The main question of discussion was why is it hard for an expert to stand in a novice’s shoes? People who are fluent at something forget what it was like before, and they skip steps without noticing (Ambrose et al., 2010).</p><p>If every class begins a task the same way, students stop spending effort on how to start and spend it on the thinking (Sweller, 1988). One line from those sessions stayed with me: “Fostering thinking requires making thinking visible” (Ritchhart &amp; Perkins, 2008).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q2UsMm2GlUxXc8Q1hGLqSQ.png" /><figcaption><em>The professional development cycle and three checkpoints, side by side.</em></figcaption></figure><h3>Look, Aim, Mark</h3><ul><li><strong>Look: get the gist.</strong> Read it once with the pen down. There is no pressure to understand everything yet.</li><li><strong>Aim: know your goal.</strong> What am I being asked to produce? If nobody gave you a question, write your own.</li><li><strong>Mark: find your evidence.</strong> Go back in with a pen and tag only what serves the aim.</li></ul><p>Students were free to mark in whatever way made sense to them: circles, boxes, arrows, a few words in the margin. For the mid and post checks I offered three kinds of mark that come naturally in computer science and carry over to other classes. Students could use them, change them or ignore them.</p><ul><li><strong>Given.</strong> What the task hands you. In math, the numbers and units. In a program’s requirements, the inputs. In a database problem, the things to store and their details.</li><li><strong>Logic.</strong> The small words that decide how the pieces connect: <em>each</em>, <em>only</em>, <em>per</em>, <em>unless</em>, <em>at least</em>. They are the easiest words to read past.</li><li><strong>Missing.</strong> What the task assumes but never states, a word you cannot define, or the value you must find first. Put a question mark or a short note in the margin.</li></ul><h4><strong>Plan Backwards</strong></h4><p>Deciding what a good marked-up paper looks like, then what students must do to produce it, then what the teacher must do. So I started with the paper.</p><p>The clearest example from my classes is a database design problem. My students use the same routine when they read the requirements for a program before writing any code. This is the problem statement from the post check.</p><blockquote><em>A tutoring center keeps information about its students, including their name, grade level, and parent contact. It also keeps information about its tutors, such as their name, subject taught, and employee ID. Each time a student meets with a tutor, the center creates a session with the date, duration, subject, student ID, and tutor ID. Every session has a payment, which includes the amount, date, method, and the session ID it belongs to. A tutor can teach many students, and a student can attend many sessions, but each session has only one payment.</em></blockquote><p>From this one paragraph students had to list the entities and their attributes, classify the attributes, name each relationship as one-to-one, one-to-many or many-to-many, and draw the entity-relationship diagram.</p><p>The paragraph has two traps for anyone who skims. A session records a <em>student ID</em>, but the sentence about students never lists one, so the reader has to notice the gap and add a key. And the last sentence packs all three relationship rules into twenty words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r587HfvyP60hj0KMGk5XRg.png" /><figcaption><em>exemplar for the post check</em></figcaption></figure><h3><strong>Checkpoints</strong></h3><p>Grading asks whether the answer is right. Analyzing asks what the paper shows about how the student was thinking, and it sorts papers by pattern, not by score. Each teacher ran one small cycle of that: collect, sort, interpret, plan.</p><p>In about two months at certain intervals the same tallies were recorded three times. Each task asked for more than the one before:</p><ol><li><strong>Baseline, no instruction.</strong> One section, 28 students. A short data task set out as a table. I said nothing about marking, because what students do unprompted is the data.</li><li><strong>Mid, after a spoken reminder.</strong> Two smaller sections pooled, 14 students. A harder task: read graphs and charts, then say what the pattern means. Before they started I talked through how to break a problem down by annotating it.</li><li><strong>Post, after a written instruction.</strong> The same two sections. The hardest task: turn a written paragraph into a full design, with a written instruction to annotate the key parts.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*miGsUzrcOqt-qCXnOLmM4w.png" /><figcaption><em>The tallies in the layout of our data-collection sheet. Partly correct counts at baseline and post come from my observation notes.</em></figcaption></figure><p>The baseline group and the mid and post group are different students. These are three snapshots of a routine being taught, and I read them that way.</p><p>The mid and post tasks had several parts, so a paper could be right in most places and wrong in one. I followed our coaches’ protocol: a paper scoring 80% or more counts as correct, and one scoring 60% to 79% counts as partly correct. The post task was out of 25 points.</p><p>The plan for teaching the routine had four steps: start from the need the baseline shows, model the routine by thinking aloud, give guided practice, then release students to mark alone.</p><h3>What happened</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhRQOVns3a1FJVxExDukmA.png" /><figcaption><em>Marking, fully correct and partly correct answers at each checkpoint. The baseline is a different group of students from the mid and post checks.</em></figcaption></figure><p><strong>Marking went up when I asked for it.</strong> At baseline 13 of 28 students (46%) marked the page. At the mid check 9 of 14 (64%) did, and at the post check 8 of 14 (57%).</p><p><strong>The baseline score needs careful reading.</strong> 18 of 28 students (64%) were fully correct at baseline, 6 more were partly correct and 4 missed it. But that was the simplest task of the three. The table had already organized the information for them.</p><p><strong>Accuracy dipped at mid, on a harder task.</strong> 8 of 14 students (57%) were fully correct and the other six were partly correct. They could read a value off a chart but could not always say what the trend meant. This was also the check where marking peaked, so more marks did not buy more correct answers.</p><p>One mid paper was an outlier. That student marked more than anyone in the room, a line from nearly every bar to its value on the axis, and was still only partly correct. Every number was found and none of them was explained.</p><p><strong>Accuracy was highest at post, on the hardest task.</strong> 12 of 14 students (86%) were fully correct and the other 2 were partly correct. The same students closed two-thirds of their gap while the task got harder. Holding steady would already have been progress.</p><p><strong>Weighed against difficulty, the gain is larger than it looks.</strong> Counting a partly correct answer as half, the class earned 75% of the available credit at baseline, 79% at mid and 93% at post. Each task asked for more than the one before, and the credit still went up at every step.</p><h3>Reading the marks: low, mid and high</h3><p>My reflection after the third task cycle says it plainly: what matters most is the correctness of what students annotate. A yes-or-no tally cannot see that, reading the annotations on a three-level scale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5krfQ3AkdBngxYdHzr0eA.png" /><figcaption><em>The three levels, shown on papers H, D and A from the post check.</em></figcaption></figure><blockquote><strong>Low.</strong> No marks at all, or marks everywhere. A clean page and a fully highlighted page tell the teacher the same thing: nothing was selected.</blockquote><blockquote><strong>Mid.</strong> Marks that select. The key things are boxed or circled, but the small logic words are untouched and there are no notes. The student has found the pieces and not yet how they connect.</blockquote><blockquote><strong>High.</strong> Marks that get used. The givens are marked, the logic words are caught, and there is at least one note in the margin: a definition, a missing detail, a quick sketch. The same items show up again in the answer.</blockquote><p>The mid check is where my students’ marking was most mixed. Nine of 14 marked the page, and most of those marks were the selecting kind: a line traced from a bar to the axis to read off a number.</p><p>The post check shows the scale more clearly. Here are eight of the fourteen post-check papers. No two students listed the tables in the same order or wrote the same columns, and most papers that counted as correct still left something out. Six have marks and two do not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QAzn8SANJk1v1e1c8eFdog.jpeg" /><figcaption><em>Eight post-check papers</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*T2NvCDWNv--LmlkD7nyWSw.png" /></figure><p>Often the gaps line up with the marks. A wrote “PK?” beside the student ID and B wrote “IDs!!”, and both papers have every key. D circled the nouns and nothing else, and missed exactly the keys the paragraph never states. E boxed “tutoring center” and “information,” made a table out of the center, and never marked the payment, which was the one table missing. H highlighted everything, so nothing singled out “only one payment,” and the payment details ended up inside Session.</p><p>It does not always line up. F and G marked nothing and still scored well, each dropping a detail or two that a quick underline might have caught. That is the honest shape of it: marks do not guarantee a good answer, but when an answer goes wrong, the marks usually show where.</p><h3>Observations</h3><p>Three things from the performed routine that the percentages do not show:</p><p><strong>The task decides whether marking is worth it.</strong> The baseline task was set out as a table, and many students scanned the rows for patterns without picking up a pen. That was reasonable. A table is already organized. A paragraph is not, and the pen is how a reader organizes it.</p><p><strong>Confident students do not mark unless asked.</strong> If a student can see the answer from the question, annotating feels like a tax. An unmarked page can mean “I didn’t need to” or “I didn’t know how,” and I have to look at the answer to tell which.</p><p><strong>Marked papers are easier to teach from.</strong> When a student had marked, I could see more nuance in the answer, and when the answer was wrong I could see where it went wrong. A wrong answer on a clean page gives me nothing to respond to. A wrong answer with one small word left uncircled tells me exactly what to say.</p><h3>LAM beyond computer science:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UdJ88f7PO7-PykNXbA_IIQ.png" /></figure><p>In <strong>calculus</strong>, a related-rates problem might say a 13-foot ladder leans against a wall while its base slides away at 2 feet per second. “Leans against a wall” is the logic: a right triangle, so x² + y² = 1³² before any derivative is taken. “How fast is the top sliding down” names the missing piece, dy/dt, and a student who flags it knows what to solve for.</p><p>In <strong>physics</strong>, “thrown horizontally” means the starting vertical speed is zero, and “ignoring air resistance” means the horizontal speed never changes. Neither phrase is a number, and both decide the setup. In <strong>chemistry</strong>, “in excess” and “goes to completion” tell a student which reactant limits the yield.</p><p>Marks also catch vocabulary. A student who circles <em>stoichiometric</em> in a lab handout, or <em>ambivalent</em> in a short story, and writes a meaning in the margin has turned a word they would have skipped into one they can use.</p><p>That last habit is also a professional one. Engineers read a specification before they build, and many costly mistakes begin with a requirement nobody read closely. A student who learns to mark a task in high school is practicing the first skill of that career.</p><h3>Why it works!</h3><p>Psychologists call the skill underneath this <em>metacognition</em>: knowing what you are doing while you do it, and noticing when it is not working (Flavell, 1979). The rubric my lessons are observed against asks for the same thing in plainer words: students should know which strategy they are using and why. A mark is a small metacognitive act. To circle “only one,” a student has to decide that it matters.</p><p>The research on highlighting carries a warning that fits my data. A large review rated highlighting and underlining as low-utility study techniques, because on their own they do not reliably improve performance (Dunlosky et al., 2013). Marking helps when it follows an aim, and the routine puts the aim before the pen.</p><h3>Retain, Refine, and Rethink</h3><p>At the conclusion of this cycle, the instructional coaches posed an important question: If I were to conduct this process again, what would I keep, adjust, and do differently?</p><p><strong>What I would keep:</strong> I would retain the unprompted baseline assessment and consistently use the same three-word routine, Look, Aim, Mark, across all instructional settings. Maintaining consistent language helps students develop a familiar approach to reading and interpreting tasks before beginning to solve them.</p><p><strong>What I would adjust:</strong> I would strengthen the study design by following the same students across all three assessment points. In this cycle, the baseline data came from one section of 28 students, while the mid-check and post-check involved two other sections totaling 14 students. I would also establish clear criteria for evaluating task difficulty before administering each assessment rather than relying on informal judgment.</p><p><strong>What I would do differently:</strong> I would systematically document each student’s annotations alongside the accuracy of their responses. I would also evaluate every assessment using a consistent low-, mid-, and high-difficulty scale. The original aggregate results did not show which students both annotated the task and answered correctly. Reviewing the individual papers revealed that both partially correct responses on the post-check came from students who had annotated the task. This reinforced the importance of evaluating not only whether students annotate, but also what they choose to annotate and how those annotations support their understanding.</p><h3>Acknowledgments</h3><p>The guidance and routine feedbacks from the instructional department by coaches <strong>Courtney Worley</strong> and <strong>Aimee Hultman</strong> were insightful, who helped develop the Look, Aim, Mark routine and data-collection cycle through our 2025–26 professional development. I also appreciate the collaboration with <strong>Anthony Stanich</strong> in our engineering department. Many of the strategies shared in this post grew out of our conversations and the connections between engineering and computer science, where students must approach, interpret, and analyze problems before developing solutions.</p><h3>Citations</h3><ul><li>Ambrose, S. A., Bridges, M. W., DiPietro, M., Lovett, M. C., &amp; Norman, M. K. (2010). <a href="https://www.wiley.com/en-ie/How+Learning+Works:+Seven+Research+Based+Principles+for+Smart+Teaching-p-9780470617601"><em>How Learning Works: Seven Research-Based Principles for Smart Teaching</em></a>. Jossey-Bass.</li><li>Dunlosky, J., Rawson, K. A., Marsh, E. J., Nathan, M. J., &amp; Willingham, D. T. (2013). <a href="https://doi.org/10.1177/1529100612453266">Improving students’ learning with effective learning techniques</a>. <em>Psychological Science in the Public Interest, 14</em>(1), 4–58.</li><li>Flavell, J. H. (1979). <a href="https://doi.org/10.1037/0003-066X.34.10.906">Metacognition and cognitive monitoring: A new area of cognitive–developmental inquiry</a>. <em>American Psychologist, 34</em>(10), 906–911.</li><li>Pólya, G. (1945). <a href="https://press.princeton.edu/books/paperback/9780691164076/how-to-solve-it"><em>How to Solve It</em></a>. Princeton University Press.</li><li>Ritchhart, R., &amp; Perkins, D. (2008). <a href="https://ascd.org/el/articles/making-thinking-visible">Making thinking visible</a>. <em>Educational Leadership, 65</em>(5), 57–61.</li><li>Sweller, J. (1988). <a href="https://doi.org/10.1207/s15516709cog1202_4">Cognitive load during problem solving: Effects on learning</a>. <em>Cognitive Science, 12</em>(2), 257–285.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4b4b8e4af10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Hey Kids, the AI Future’s Already Here.”]]></title>
            <link>https://medium.com/@jaimin-k/hey-kids-the-ai-futures-already-here-4cace70e75ee?source=rss-5b28ba3cf255------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cace70e75ee</guid>
            <category><![CDATA[edtech]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[stem]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[k12-education]]></category>
            <dc:creator><![CDATA[Jaimin-k]]></dc:creator>
            <pubDate>Mon, 16 Jun 2025 02:41:32 GMT</pubDate>
            <atom:updated>2026-11-11T18:58:03.427Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hey Kids, the AI Future’s Already Here.</h3><h3>Why I’m planning on teaching AI to the next generation before the world teaches them to be consumers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBovz-AoWzjRTieJWSHTcQ.jpeg" /></figure><p>Let me take you to a classroom.<br>Not one with whiteboards and dusty textbooks.<br>I’m talking about the kind with sparks flying.<br>Not from wires, but from <em>minds</em>.</p><p>A 12-year-old training an image classifier.<br>A 10-year-old debugging a chatbot like it’s Minecraft.<br>A 9-year-old asking,</p><blockquote><em>“If AI can paint, does it have feelings too?”</em></blockquote><p>They don’t know it yet, but they’re not just learning STEM. They’re decoding the fabric of the world.</p><h3>The Problem Isn’t That Kids Don’t Learn AI.</h3><p>It’s That They Learn It Too Late.</p><p>Look around — AI is <em>everywhere</em>.<br>TikTok trends? AI.<br>Spotify recs? AI.<br>Face filters, translation, self-driving cars, even who gets a loan?<br> Yeah, its <strong>AI</strong>.</p><p>But in schools?</p><blockquote><em>“You’ll learn that in college.”<br> Too late.</em></blockquote><p>By then, the world has already shaped them into users. I think we should work towards shaping them into <strong>builders</strong>.</p><h3>What “AI Education” Gets Wrong Right Now</h3><p>There’s a race. Everyone’s launching robotics kits, coding camps, and “AI-for-kids” apps.<br>Great intentions!!<br>But too often it’s:</p><ul><li>💻 Drag-and-drop, no depth.</li><li>🤖 Robotics that’s more about wiring than reasoning.</li><li>🧠 Teaching tools, not understanding.</li><li>🧍🏽‍♂️ One-size-fits-all in a world of wildly curious minds.</li></ul><p>It’s like giving a kid a paint-by-numbers set and calling them Picasso.</p><p>They tell kids, “Here’s how to code a robot.”<br>I want to ask them,</p><blockquote><em>“What kind of world do </em>you<em> want to build with AI?”</em></blockquote><p>Because here’s the truth:<br> <strong>Kids don’t need to learn AI the way adults do.</strong><br> They need to <em>play</em> with it.<br> <em>Bend</em> it.<br> <em>Break</em> it.<br> Ask dangerous questions like,</p><blockquote><em>“Why is the AI always choosing this person and not that one?”</em></blockquote><p>That’s how they learn. Not just to code. But to think.</p><h3>So Here’s My Plan - No More “Download and Do” Learning</h3><p>I plan on building something better.<br>A new kind of curriculum.<br>Not just lessons. <strong>Experiences.</strong></p><ul><li>Projects that mix storytelling, AI, art, and ethics.</li><li>Use real-world data (Instagram filters, YouTube thumbnails, school lunch menus!) to teach ML models.</li><li>Game-based simulations where kids <em>investigate</em> how bias creeps in.</li><li>Roleplays like “AI detective” or “robot policy maker” to teach systems thinking.</li><li>️ Tools that <em>scale down</em> advanced ideas, without watering them down.</li></ul><p>It’s not just about “preparing for jobs.”<br>It’s about <strong>shaping minds that question, imagine, and lead</strong>.</p><h3>Why This Matters (Even If You Don’t Have Kids)</h3><p>Because AI isn’t “the future” anymore.<br>It’s <em>now!</em><br>And the next generation will inherit decisions made by models they didn’t design.<br>Unless we change that.</p><p>This isn’t about raising programmers.<br>It’s about raising <strong>critical, curious, ethical humans</strong>. Humans who understand what’s under the hood <em>before</em> they hand over the keys.</p><h3>What Keeps Me Up - and What Wakes Me Up</h3><p>I lie awake thinking about the millions of kids who’ll only ever see AI as a magic trick.<br>Not a tool. Not a language. Not a canvas.</p><p>But then I remember:</p><blockquote><em>That 10-year-old who built an AI that could tell if someone was being mean or kind.<br> That 8th grader who challenged a dataset for being unfair.<br> That quiet kid who said,<br> “I didn’t know I could teach the computer something.”</em></blockquote><p>That’s the revolution.</p><h3>Final Thought:</h3><p>Let’s stop underestimating the next generation.<br>Let’s stop handing them apps and start handing them blueprints.<br>Let’s raise builders. Dreamers. Debuggers of the status quo.</p><p>Because if the future is written in code — then it’s time we hand over the keyboard.</p><p><em>PS: The em dashes ( — ) in this article don’t represent ChatGPT — though its help was enlisted to shape this piece. The sparks, the urgency, the heartbeat behind it? 100% human.</em> ✨ <em>Oh, and that image of the classroom? AI-generated too. The kids aren’t real — but the mission absolutely is.</em> 🎨🤖</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cace70e75ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Computer Vision from scratch: Image Downsampling]]></title>
            <link>https://medium.com/@jaimin-k/computer-vision-from-scratch-image-downsampling-83c1be68f7af?source=rss-5b28ba3cf255------2</link>
            <guid isPermaLink="false">https://medium.com/p/83c1be68f7af</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[digital-image-processing]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Jaimin-k]]></dc:creator>
            <pubDate>Tue, 29 Aug 2023 21:52:05 GMT</pubDate>
            <atom:updated>2025-01-24T22:57:23.769Z</atom:updated>
            <content:encoded><![CDATA[<p>For digital images, finding the perfect balance between image quality and practicality is crucial. High-resolution images might look stunning, but they often come with a trade-off: they demand more storage space and processing power. One way to tackle this challenge is by first converting the image to grayscale, which not only simplifies the image but also helps reduce processing power. To further optimize image size without compromising key details, downsampling enters the scene, offering a down-to-earth solution that involves selectively reducing image dimensions by skipping some pixels.</p><p>Downsampling is about creating a more compact version of an image by leaving out some pixels while holding onto the most important details. This technique finds its way into various fields, from squeezing images for storage to making real-time visual tasks snappier, like in computer vision and graphics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*JdKjzwCesWZXf3XS7D-cTQ.png" /></figure><p>One interesting facet of this method is its ability to be implemented solely through mathematical computations, without any reliance on tools like OpenCV for image display. This underlines how the collaboration between mathematical concepts and programming can reveal the inner workings of pixel processing.</p><p>We’ll now see how we can transform a 512x512 grayscale image into a 256x256 image, understanding the mathematics behind downsampling and how it strikes an effective balance between image recognizability and the elimination of redundant pixels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*hMccmKzeDUAXFl84.png" /></figure><p>Our objective is to achieve a downsized version of the original image, typically with dimensions reduced to 256x256 pixels. At the core of this process is the creation of a new image structure like a blank black image that matches the downscaled dimensions. Initializing this new image with zero values establishes the foundation for assigning pixels. As we move through each pixel position in the output image, we systematically extract corresponding pixel values from the input image. This selection follows a specific pattern, enabling a methodical downsampling of the image’s content.</p><p>Let&#39;s break down the algorithm into steps to make the implementation easier for coding:</p><p><strong>1] Function for Downsampling: </strong>We can define the function subsample(img_in) tailored for downsampling grayscale images.</p><p><strong>2] Calculating Dimensions: </strong>Calculate the output dimensions for downsampling:</p><pre>#Input Image Dimensions <br>rows, cols = img_in.shape<br>#Output Dimensions: <br>output_height = 256<br>output_width = 256</pre><p><strong>3] Generating Output Image: </strong>Create an output image structure with zero values:</p><pre>#Output Image: <br>img_out = np.zeros((output_height, output_width))</pre><p><strong>4] Traversal Through Pixels: </strong>Loop through output image positions:</p><pre>for r in range(0, output_height): #For each row position<br>   for c in range(0, output_width): #For each column position</pre><p><strong>5] Assigning Pixel Values: </strong>Populate the output image with the chosen pixel values from the input image:</p><pre>#Pixel Selection from Input Image: <br>selected_pixel = img_in[2*r, 2*c]<br>#Assign Pixel Value to Output Image: <br>img_out[r, c] = selected_pixel</pre><p><strong>6] Providing Downscaled Output:</strong> Return the downscaled image as the function’s output.</p><p><strong>7]Displaying the Result:</strong> Optionally, use <em>cv2.imshow</em> to visualize the downscaled image.</p><p>By going through these steps, you can see the mathematical variables associated with each stage, making the process clearer and more comprehensible.</p><p>In essence, with this methodology for downsampling grayscale images underscores the harmony between mathematics and programming, employing only numpy for calculations. This efficient approach reduces image size while maintaining its essence, entirely bypassing the need for external libraries like OpenCV which can be used only for displaying the image.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83c1be68f7af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Estimating Pedestrian Intent for Crossing Roads]]></title>
            <link>https://medium.com/@jaimin-k/estimating-pedestrian-intent-for-crossing-roads-b9ed87884b89?source=rss-5b28ba3cf255------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9ed87884b89</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[autonomous-cars]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[autonomous-vehicles]]></category>
            <dc:creator><![CDATA[Jaimin-k]]></dc:creator>
            <pubDate>Sat, 04 Mar 2023 04:37:18 GMT</pubDate>
            <atom:updated>2023-03-04T04:42:34.310Z</atom:updated>
            <content:encoded><![CDATA[<p>In Autonomous driving applications, detecting pedestrians is a crucial task that can be accomplished through computer vision techniques. However, the challenge is to detect the action of pedestrians and predict their intent. A vision-based system can be used to detect pedestrians intent through their actions and from how close they are to the lanes on the road. From these parameters, a crossing intent score can thus be calculated that estimates the likelihood of each pedestrian crossing the road. Based on this score, advanced driver assistance systems (ADAS) and Autonomous vehicles (AV) can further make maneuvering decisions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TqHe-LXC4sRP3Bb-7lpqzQ.jpeg" /></figure><h4><strong>Goal</strong></h4><p>The goal is to estimate how likely a person is to cross the road. This score is useful in autonomous vehicle (AV) systems that have to be aware of any pedestrians that it risks colliding with. Most AVs have some form of pedestrian detection and additional sensors such as LIDAR, RADAR, and ultrasonic to determine if there is any object in the vehicle&#39;s path. Unlike AVs which combine different types of sensors to determine if a person is in the car’s path, the method aims to predict if a person will cross the road-based only on visual information.</p><h4><strong>Approach</strong></h4><p>To estimate the likelihood of a pedestrian crossing the street by assigning a cross intent score to each pedestrian, a pipeline can be used to achieve the desired cross intent score. Below is the process pipeline used to perform the necessary experiments to obtain the desired result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nJ6fgovc-tUtyK_eA6WH4Q.jpeg" /></figure><p>We can define a cross intent score indicating the likelihood of pedestrian crossing or not crossing the street which derives from the three parameters — pedestrian action, pedestrian distance from lane and a safe threshold distance from lane region. Each of these three parameters returns a respective score mapped between 0 and 1 which then contributes to the calculation of cross intent score.</p><p>The performance of the above proposed method is evaluated by running a video through the above experimental pipeline, which computes a score in a specified range of 0 to 1 for each pedestrian. The greater the cross intent score, the more likely the pedestrian is to cross the street.</p><p>The dataset used was the <a href="https://data.nvision2.eecs.yorku.ca/PIE_dataset/">PIE dataset</a>. This dataset contains 6 hours of recorded video of pedestrians, roads, and traffic. A few videos from the dataset are used to test our approach to obtain the results. For the videos in the used dataset being of long duration, we can extract a few short scenes from them, on which we can test our pipeline. The code for lane detection was built from scratch, while action recognition was implemented using an open source toolbox MMAction2. Here we have implemented pedestrian detection, based on the results obtained by the detected bounding boxes for action recognition.</p><p>The computed score was verified through the input video, for a higher cross intent score computed, the pedestrian crossed the street in the video. There is some uncertainty in how the model would behave on pedestrians far in the background of the image. It can be anticipated that the score will not be as accurate in those cases.</p><p>Implementation of each of the above steps has been described below:</p><p><strong>1) Action Recognition:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2jAalJpZ1IXZ5iSvlGSWVw.png" /></figure><p>The implementation was done using MMAction2 is an open-source toolbox for video understanding based on PyTorch and is a part of the OpenMMLab project. It used the MMDetection toolbox from the OpenMMLab to perform human detection for each frame of the input video. Spatio-temporal action detection is then performed for each clip, and the results are annotated in the video with bounding boxes and labels.</p><p>MMAction2 is able to recognize a total of 60 different types of actions, including walking, standing, sitting, watching, etc. In order to make our implementation more intuitive and simplify the later scoring process, we can use a different label file than the default mode during the detecting process to restrict the program to detect only two actions, walking and standing.</p><p>OpenPose is also an alternative that can estimate the pose by detecting the keypoint of the human body and then annotate the input video or image by drawing the skeletons on the detected human.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QODDgHgTlfkjpOJb7JYD6g.png" /></figure><p><strong>2) Lane Detection</strong></p><p>In the dataset used, the lane lines tend to appear in a common region of interest, with the camera being mounted at a fixed position on the vehicle, pointing the front side downwards. As a first step, we load the image or the video stream.</p><p>A pipeline was created to detect the line segments (of lane) in the video frame, apply some image processing techniques and then average/extrapolate them and draw them onto the image for display.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*GVO2tL9ajXWcbtslfmnl3Q.jpeg" /><figcaption><strong>Pipeline to detect lanes and display lane lines on street</strong></figcaption></figure><p><strong>Gray scaling: </strong>Applying the grayscale transformation to the image. Gray scaling converts the image frames of the video with more than one color channel to an image with only one color channel (gray).</p><p><strong>Gaussian blur: </strong>This is one of the pre-processing techniques which blurs or smoothens the edges of an image by applying a Gaussian kernel on it which acts as a low pass filter suppressing images’ high frequency component, thus reducing noise by smoothening the image.</p><p>Implementing Gaussian Blur in OpenCV takes an integer kernel parameter as the intensity of the smoothing. Gaussian blur is used to improve the results of the edge detection followed in the next step.</p><p><strong>Canny edge detection:</strong> It is an edge detection operator applied to an image to obtain essential structural information (edges) of an image. It is a widely used algorithm in most computer vision applications which requires edge detection.</p><p>Its implementation using OpenCV requires two additional parameters — a low and a high threshold to detect only the edges with intensity lying within the threshold.</p><p><strong>Region of interest (ROI) selection: </strong>Our image frame now consists of only the edges of the objects in the image, which includes all of those present in front of the car, along with the lane markings. Thus, it is difficult to detect the lane lines automatically in the presence of other objects.</p><p>We therefore extract and use only a segment of the edge detected image by defining a region of interest which is the boundaries of the polygon for ROI, in which the lanes would be generally visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ArIkhUJc5Ey9X0JZWSsEyQ.png" /></figure><p><strong>Hough transform: </strong>To extract the lines and highlight the lane lines, we apply the Hough Transform technique. Lines are detected by identifying the points lying on them for which there is a need to convert system (x,y) to Hough space (m,b) which uses polar coordinates. This is done by converting our current system denoted by axis (x,y) to a parametric one where axes are (m, b). In polar coordinates, a given line is expressed as (ρ, θ), where line L is at distance ρ and angle θ from the origin, thus making a right angle that is ρ = x cos θ + y sin θ.</p><p>All straight lines passing through a point correspond to a sinusoidal curve. Thus points lying on the same straight line in cartesian space yields sinosoids which will cross at point (ρ, θ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*va2Tb9ZCz2becK9Orqf93A.png" /></figure><p><strong>Hough line extrapolation:</strong> The right and left lane line distinction was done from the calculated slopes of the detected Hough lines. Upon right left categorization based on slope, all the detected left and right lines were merged into one each by calculating and averaging their intercepts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zRPKuoLCnOh8oZEvJnyCgg.png" /></figure><p><strong>3) Pedestrian Detection:</strong></p><p>To perform pedestrian detection, MMAction2 is first installed. Then demo_spatiotemporal_det.py is modified to print out the frame, action, and centers of each bounding box detected. This information gets saved to a text file, which the user needs to modify to remove the unnecessary header that gets saved to the file.</p><p><strong>4) Computing Scoring Parameters:</strong></p><p>Cross intent scores for each pedestrian can be obtained from the below 3 parameters:</p><p>a) Pedestrian action</p><p>b) Pedestrian distance from lane</p><p>c) Safe threshold distance from lane</p><p><strong>a) Pedestrian action:</strong></p><p>The pedestrian action is given 2 different weights based on whether they are walking or standing. Walking is given a weight of 0.5 while standing is given a weight of 0.2. This indicates that a person that is walking is more likely to cross the street than standing.</p><p><strong>b) Pedestrian distance from lane</strong></p><p>The distance from the lane is calculated by first finding the average center point of the lane which is obtained from lane detection. Then the distance between the center point of the lane and the center of each pedestrian bounding box is calculated. The closer the pedestrian is to the center, the larger the fraction will be.</p><p><strong>c) Safe threshold distance from lane</strong></p><p>The safety threshold determines if the pedestrian is within the lane. If the distance is less than 460 or half the width of the lane, then the person is in the lane and a weight of 1 is given to indicate high importance. If the pedestrian is not in the lane the weight is 0.3.</p><p><strong>5)</strong> <strong>Compute cross intent scores:</strong></p><p>To compute the cross intent score, we can use the following relation:</p><p><strong>cross intent score</strong>=(closeness + action+((max_dist — dist) / max_dist ))/3</p><p>We then average the 3 weights together to get a score between 1 and 0. Higher scores such as .7 indicate that the pedestrian is very likely to cross the street or is already crossing, while 0.35 is very unlikely to cross in front of the car. For pedestrians that are standing and close to the lane, their score is around .6 which is still high but less than a moving pedestrian. These scores are expected and remain consistent across the tested cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*2JFe_iryBDSNWuJfHR6hoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*fSzPI6nIH8Zy8UGuJ3nptA.png" /></figure><p><strong>Future Scope:</strong></p><p><strong>Conclusion:</strong></p><p>This article describes implementation of a pipeline process for computing a score that predicts the likelihood of a pedestrian crossing the street. Lane detection was first performed on the desired video. The lane detection video was then used to perform action and pedestrian detection. The positions of the pedestrian bounding boxes, the pedestrian action, and distance from the middle all factor into predicting how likely a person is to cross the street.</p><p>In the future, YOLOv5 could be used to detect crosswalks so that the distance between the pedestrian and crosswalk can be used as an additional score parameter. We attempted to get crosswalk detection working for this implementation, but crosswalks often either glitched in frames or generated multiple split bounding boxes rather than a large bounding box. There were also instances where the lane lines were not detected properly due to poor lighting conditions on the road caused by shadows of trees and other nearby objects. This can be fixed by making lane detection more robust by applying additional computer vision techniques like perspective transformation and detecting the lanes in a top view perspective transformed image frame of the road. Another idea that would improve the accuracy of the scores is to implement a form of depth estimation for each pedestrian to determine the true distance from the center of the lane obtained from the depth calculated from stereo cameras.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9ed87884b89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Estimating pedestrian proximity using MiDaS and YOLOv7]]></title>
            <link>https://medium.com/@jaimin-k/estimating-pedestrian-proximity-using-midas-and-yolov7-14b5a08b8740?source=rss-5b28ba3cf255------2</link>
            <guid isPermaLink="false">https://medium.com/p/14b5a08b8740</guid>
            <category><![CDATA[self-driving-cars]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[autonomous-cars]]></category>
            <category><![CDATA[autonomous-vehicles]]></category>
            <dc:creator><![CDATA[Jaimin-k]]></dc:creator>
            <pubDate>Wed, 01 Mar 2023 06:23:15 GMT</pubDate>
            <atom:updated>2023-03-01T21:17:11.887Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*DM1auNOtFGQI4zoabstSRw.png" /></figure><p>As the field of computer vision continues to advance, there is an increasing need to accurately estimate the proximity of pedestrians and objects in real-world scenarios. One promising approach to achieving this goal is through the use of MiDaS monocular depth estimation, combined with detections made using the YOLOv7-pose model.</p><p>MiDaS is a deep learning-based method for estimating the depth of an image, using a single RGB input. Meanwhile, YOLOv7-pose is a state-of-the-art object detection and pose estimation algorithm that can accurately identify the location and orientation of people and objects in an image. By combining these two powerful techniques, it is possible to estimate the distance between a camera and pedestrians or objects, enabling a wide range of applications in fields such as autonomous vehicles, robotics, and surveillance.</p><p>In this article, we will explore the potential of Midas monocular depth estimation with YOLOv7-pose detections for estimating pedestrian and object proximity.</p><p><strong>Generate depth maps with MiDaS:</strong></p><pre>midas = torch.hub.load(&#39;intel-isl/MiDaS&#39;, &#39;MiDaS_small&#39;)<br>midas.to(&#39;cuda&#39;)<br>midas.eval()<br>transformss = torch.hub.load(&#39;intel-isl/MiDaS&#39;, &#39;transforms&#39;)<br>transform = transformss.small_transform<br>cap = cv2.imread(&#39;test.jpg&#39;)<br><br>image = cv2.cvtColor(cap, cv2.COLOR_BGR2RGB)<br><br>image_batch = transform(image).to(&#39;cuda&#39;)<br><br>with torch.no_grad():<br>        prediction = midas(image_batch)<br>        prediction=torch.nn.functional.interpolate(<br>                    prediction.unsqueeze(1),<br>                    size = image.shape[:2],<br>                    mode = &#39;bicubic&#39;,<br>                    align_corners=False<br>                    ).squeeze()<br><br>        output = prediction.cpu().numpy()</pre><p>First, we load the MiDaS model using the PyTorch hub and specify the small variant of the model. We then move the model to the GPU and set it to evaluation mode using midas.to(&#39;cuda&#39;) and midas.eval(), respectively.</p><p>Next, we load the MiDaS transforms module using the PyTorch hub and specify the small_transform variant. This module contains the image preprocessing pipeline used to prepare the input image for inference with the MiDaS model.</p><p>We then read in an input image using OpenCV’s cv2.imread() function and convert it from BGR to RGB color format using cv2.cvtColor(). The image is then resized to a height of 500 pixels and a width of 600 pixels using cv2.resize().</p><p>The input image is then transformed using the MiDaS transform pipeline and moved to the GPU using .to(&#39;cuda&#39;). The transformed image is stored in image_batch.</p><p>We then used the midas model to make a depth prediction on image_batch. The prediction is upsampled to the original image size using torch.nn.functional.interpolate(). The output is a 2D array of depth values, stored in output. Below shown is the result obtained:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*zVgVvgabgCrZzBv7J_EiOw.png" /></figure><p><strong>Pose detections using YOLOv7-pose model:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*nqB71x52-1-kJkWkmkL0fQ.png" /><figcaption><strong>Human</strong> <strong>keypoints detection using YOLOv7-pose model</strong></figcaption></figure><p>We load and use the YOLOv7-pose model to perform object detection and pose estimation on an input image.</p><pre>YOLOV7MODEL = &#39;yolov7-w6-pose.pt&#39;<br><br>try:<br>    print(&quot;Loading the model...&quot;)<br>    model, yolomodel = loading_yolov7_model(yolomodel=YOLOV7MODEL)<br>    print(&quot;Using the&quot;, YOLOV7MODEL, &quot;model&quot;)<br>    print(&quot;Done&quot;)<br><br>except:<br>    print(&quot;[Error] Cannot load the model&quot;, YOLOV7MODEL)<br><br>output1, image = running_inference(cv2.imread(imagefile))<br><br>pose_image,kpts,output = draw_keypoints(output1, image, confidence=0.25, threshold=0.65)<br></pre><p>We first specify the path to the model file, yolov7-w6-pose.pt, and attempt to load the model using a function called loading_yolov7_model(). If the model is successfully loaded, we print a message indicating that the specified model is being used.</p><p>We then call a function called running_inference() to process the input image with the YOLOv7-pose model and obtain a list of keypoint coordinates.</p><p>Afterwards, we call another function called draw_keypoints() created from the utils code of YOLO to draw the detected keypoints on the processed image. This function takes the processed image, keypoint coordinates, and two threshold values as input and returns the image with keypoints drawn on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*exQgRmYmGveIuFDVUexWPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*XKtpBEBiiA33dNDnc1JZ5A.png" /><figcaption><strong>Human</strong> <strong>keypoints detection using YOLOv7-pose model</strong></figcaption></figure><p><strong>Run MiDaS inference on detected boxes:</strong></p><p>To classify the pedestrians as near or far, we define a threshold inverse depth value based on our application requirements. For example, we may define a threshold value of 0.5, which indicates that pedestrians with an inverse depth value of less than 0.5 are classified as “near” and those with a higher inverse depth value are classified as “far”. We then assign each pedestrian to the corresponding class based on their inverse depth value.</p><p>Based on the below obtained output, the detections can be visually interpreted, showing correctly classified pedestrian proximity as near or far to the vehicle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*DM1auNOtFGQI4zoabstSRw.png" /></figure><p>We also store the detection positions and inverse depth values of each pedestrian in a CSV file for further analysis and experimentation.</p><p>The above pipeline was also evaluated for video and webcam stream. We observe that the pipeline shows good results for lower frames per second, but may experience reduced accuracy and performance for higher frame rates.</p><p>Overall, the efficiency and robustness of proximity or depth sensing can be improved by also inferring depth values of objects from a stereo camera.</p><p><strong>Conclusion:</strong></p><p>In this implementation, we use the MiDaS monocular depth estimation model to estimate the distance of pedestrians from the camera. We first detect pedestrians and their keypoints using the YOLOv7-pose model, and then apply Midas depth estimation to each detected bounding box to obtain the corresponding inverse depth values.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14b5a08b8740" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Trajectory planning for 6DOF Kinova Jaco robotic arm]]></title>
            <link>https://medium.com/@jaimin-k/trajectory-planning-for-6dof-kinova-arm-b9dde1325f56?source=rss-5b28ba3cf255------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9dde1325f56</guid>
            <category><![CDATA[inverse-kinematics]]></category>
            <category><![CDATA[trajectory-planning]]></category>
            <category><![CDATA[robot-arm]]></category>
            <category><![CDATA[robotics-automation]]></category>
            <category><![CDATA[robotics]]></category>
            <dc:creator><![CDATA[Jaimin-k]]></dc:creator>
            <pubDate>Tue, 28 Feb 2023 18:23:09 GMT</pubDate>
            <atom:updated>2023-02-28T18:23:37.850Z</atom:updated>
            <content:encoded><![CDATA[<p>Using differential inverse kinematics for trajectory planning of Kinova Jaco robotic arm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*UyoTTr02SL2PclHH9vcYTw.gif" /></figure><p><strong>Introduction</strong></p><p>The 6DOF Jaco Kinova arm robot manipulator is a highly versatile and capable machine that can perform a wide range of tasks. To achieve precise and accurate movement of the robot, trajectory planning is essential. One popular method for trajectory planning is differential inverse kinematics (DIK).</p><p>DIK is a mathematical technique that allows us to compute the joint velocities required to move the robot along a desired trajectory. It involves computing the Jacobian matrix, which relates the velocities of the end-effector to the velocities of the robot’s joints. Using the Jacobian matrix, we can then calculate the joint velocities required to move the robot along the desired trajectory.</p><p>By using DIK, we can plan trajectories that take into account the kinematic constraints of the robot, such as joint limits and singularities. This ensures that the robot moves smoothly and accurately, without violating any physical constraints.</p><p><strong>Homogenous Transformations</strong></p><p>Homogeneous transformations are a key concept in robotics and are often used to represent the position and orientation of a robot’s end-effector in space. In the case of a 6DOF Jaco Kinova arm robot manipulator, we can use homogeneous transformations to represent the pose of each joint in the robot’s kinematic chain.</p><p>DH matrix, short for Denavit-Hartenberg matrix, is a transformation matrix used to describe the relationship between two adjacent links in a robotic arm. The DH matrix is defined by four parameters: link length, link twist, link offset, and joint angle. These parameters are used to describe the transformation between two adjacent coordinate frames in the robotic arm.</p><p>To describe the position and orientation of a joint in space, we use a 4x4 homogeneous transformation matrix, which is composed of a rotation matrix and a translation vector. The rotation matrix represents the orientation of the joint in space, while the translation vector represents the position of the joint relative to a fixed reference frame.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CSrhQ4miFzdB5_wg84kIVg.jpeg" /><figcaption>Homogeneous transformation matrix [<a href="https://skill-lync-portal.nyc3.digitaloceanspaces.com/tinymce/07_20/15944727422951.jpg">Source</a>]</figcaption></figure><p>Function defined in MATLAB to compute the DH matrix:</p><pre>function A = compute_dh_matrix(alpha, r, d, theta)    <br>    A = eye(4);<br>    A = [cos(theta) -sin(theta)*cos(alpha) sin(theta)*sin(alpha) r*cos(theta);<br>        sin(theta) cos(theta)*cos(alpha) -cos(theta)*sin(alpha) r*sin(theta);<br>        0           sin(alpha)                 cos(alpha)  d;<br>        0 0 0 1];<br>end</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*5fVHAioMjUTRBfC_de6LOA.png" /><figcaption>Source: <a href="https://assistive.kinovarobotics.com/resources?r=339,12494&amp;s">Kinova Jaco arm documentation</a></figcaption></figure><pre>A01 = [(compute_dh_matrix(pi/2, 0, D1, -q1))];<br><br>A12 = [(compute_dh_matrix(pi, D2, 0, q2+90))];<br><br>A23 = [(compute_dh_matrix(pi/2, 0, -e2, q3-90))];<br><br>A34 = [(compute_dh_matrix(2*aa, 0, -d4b, q4))];<br><br>A45 = [(compute_dh_matrix(2*aa, 0, -d5b, q5+180))];<br><br>A56 = [(compute_dh_matrix(pi, 0, -d6b, q6-(180-80)))];<br><br>% homogeneous transformation matrices of each frame w.r.t base frame<br><br>A02 =  simplify(A01*A12);<br>A03 =  simplify(A02*A23);<br>A04 =  simplify(A03*A34);<br>A05 =  simplify(A04*A45);<br>A06 =  (A05*A56); %end effector</pre><p>We convert symbolically computed homogeonous transformations and end effector(EE) linear velocity into a function using <a href="https://www.mathworks.com/help/symbolic/generate-matlab-functions.html">matlabFunction()</a>.</p><p><strong>Computing Jacobian matrix</strong></p><p>The Jacobian matrix relates the velocities of a robot’s joints to the velocities of its end-effector. In the case of a 6DOF Jaco Kinova arm robot manipulator, we use the Jacobian matrix to compute the joint velocities required to move the robot’s end-effector along a desired trajectory.</p><p>The Jacobian matrix relates the velocity of the end-effector to the velocity of the joints as follows:</p><p><strong>V_ee = J(q) * V_q</strong></p><p>where V_ee is the velocity of the end-effector, J(q) is the Jacobian matrix evaluated at the current joint angles q, and V_q is the velocity of the robot’s joints.</p><p>The Jacobian matrix for the Jaco arm is a 6x6 matrix that consists of both linear and angular velocity components. The linear velocity component represents the rate of change of the end-effector’s position with respect to the joint angles, while the angular velocity component represents the rate of change of the end-effector’s orientation with respect to the joint angles.</p><p>Once we have computed the Jacobian matrix, we can use it to compute the joint velocities required to move the robot’s end-effector along a desired trajectory. By computing the inverse of the Jacobian matrix, we can also compute the joint angles required to achieve a desired end-effector velocity. This is useful for trajectory planning and control of the robot, which we will discuss ahead in the article.</p><p>We compute the Jacobian matrix corresponding to the linear velocity of the EE with respect to the world frame. For simplicity of the implementation, we are only interested in the linear velocity Jacobian and not angular velocity Jacobian.</p><pre>% calculating linear Jacobian with (x,y,z)position of end effector with respect to q<br><br>linear_jacobian = jacobian(A06(1:3, 4), q);<br>matlabFunction(linear_jacobian, &#39;vars&#39;, {q}, &#39;file&#39;, &#39;linear_jacobian&#39;, &#39;Optimize&#39;, true);</pre><p>A third degree Bezier polynomial can be used for trajectory planning in robot manipulator differential inverse kinematics by defining the trajectory of the end effector as a function of time using a Bezier curve.</p><p>The Bezier curve is a mathematical curve that is defined by a set of control points. In the case of a third degree Bezier polynomial, the curve is defined by four control points. These control points can be used to specify the initial and final positions of the end effector, as well as the velocity and acceleration at these points.</p><p>Once the trajectory of the end effector has been defined as a Bezier curve, it can be differentiated to obtain the velocity and acceleration profiles for the robot joints. These velocity and acceleration profiles can then be used to solve the differential inverse kinematics problem, which involves finding the joint velocities and accelerations required to move the robot along the desired trajectory.</p><pre>function bezier = bezier_fn(t, p)<br><br>p0 = p(1:3, 1); %initial position<br>p1 = p(1:3, 2); %control point1<br>p2 = p(1:3, 3); %control point2<br>p3 = p(1:3, 4); %final position<br><br>bezier = (1 - t)^3*p0 + 3*t*(1-t)^2*p1 + 3*(t^2)*(1-t)*p2 + (t^3)*p3;<br><br>end</pre><pre>function derivative_beizer = diff_bezier(t, p)<br>%The tangent of a curve is its derivative<br>p0 = p(1:3, 1);<br>p1 = p(1:3, 2);<br>p2 = p(1:3, 3);<br>p3 = p(1:3, 4);<br>derivative_beizer = (-3*(t - 1)^2)*p0 + (3*t*(2*t - 2) + 3*(t - 1)^2)*p1 + (- 2*t*(3*t - 3) - 3*t^2)*p2 + 3*t^2*p3;<br><br>end</pre><p><strong>Differential Inverse Kinematics</strong></p><p>We nowhave the Jacobian matrix, third degree Bezier function, and its derivative, you can use differential inverse kinematics (DIK) to calculate the joint velocities and accelerations required to follow the desired trajectory.</p><p>The joint velocities can be calculated from the end effector velocity using the following equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*CsokTfbHRS_js9CH7TEo4Q.png" /><figcaption>differential inverse kinematics equation</figcaption></figure><p>where, Ja → pseudo-inverse jacobian<br>X_d → desired end effector position-given by bezier at each time step <br>X_d_dot → desired velocity<br>K → identity positive definite gain matrix<br>X → actual end effector position</p><pre>function q_dot = diff_ik(t,points,p0,q)<br><br>t_final= 10; %time in sec<br>time_scale = t/t_final; % to scale time 0-1 to 10 sec.<br><br>Ja = pinv(linear_jacobian(q)); %pseudo inverse jacobian<br>Xd = bezier_fn(time_scale, points); %desired end effector position-given by bezier at each time step <br>Xd_dot = (1/t_final)*(diff_bezier(time_scale, points)); %desired velocity<br>K = eye(3); %identity positive definite gain matrix<br>X = A06(q)*p0; %actual end effector position<br><br>q_dot = Ja*(Xd_dot + K*(Xd - X(1:3)));  %differential inverse kinematics equation<br><br>end</pre><p>We define the desired end effector trajectory using the third degree Bezier function. This function is defined by four control points.</p><p>For defined initial and final configuration as mentioned in jaco documentation were taken the configurations can also be changed if desired initial configuration — arm links angular position: [270; 180; 180; 0; 0; 0] (in degrees) and desired final arm links angular position: [180; 270; 90; 180; 180; 350] (in degrees) we attempt to compute desired joint level trajectory through differential inverse kinematics solving it with the ode45 solver to give a time varying trajectory from 0 to 10 seconds.</p><pre>%% Robot configuration<br>clearvars; <br>%robot initial configuration<br>p0 = [0; 0; 0; 1]; %base of robot<br>q_init = (pi/180)*[270; 180; 180; 0; 0; 0]; %initial position-as given in jaco documentation<br>p_init = A06(q_init)*p0; %end effector position<br><br>%desired robot final configuration<br>q_final = (pi/180)*[180; 270; 90; 180; 180; 350]; %final position- angular position as shown in jaco documentation<br>p_final = A06(q_final)*p0;<br><br>% forward kinematics<br>fk_init = fwd_kine(p0,q_init);<br>fk_final = fwd_kine(p0,q_final);</pre><p>We use the <a href="https://www.mathworks.com/help/matlab/ref/ode45.html">ODE45</a> solver of MATLAB to solve the differential inverse kinematic equations which involves defining the initial conditions (joint angles and velocities) and the time range over which to solve the equations. The time range taken is 10 seconds. Once the <a href="https://www.mathworks.com/help/matlab/ref/ode45.html">ODE45</a> solver has solved the differential equations, we can extract the joint angles as a function of time to obtain the joint-level trajectory.</p><pre>point1 = fk_init(:, 7);<br>point2 = p_final;<br>points = [point1 point1 point2 point2]; % Points for cubic bezier polynomial function<br><br>t_span = [0 10];<br><br>[t, q] = ode45(@(t,q) diff_ik(t, points,p0,q), t_span, q_init);</pre><p>After computing the q(t) profile, we can animate robot at each step over 10 seconds to obtain the q(t) profile.</p><p><strong>animating the robot and plotting q(t) profile</strong></p><p>The robot is animated using joint level trajectory obtained from ODE45 solver.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*PSrZP3k7ZHeOZD78gmf1Mw.gif" /><figcaption><strong>Animated Jaco arm trajectory</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*5ffoKPuRhLOq5Gdt0fvfQg.png" /></figure><p>In conclusion, we have successfully implemented a trajectory planning algorithm for the Jaco arm using Differential Inverse Kinematics (DIK) using MATLAB. We have computed the joint-level trajectory q(t) that corresponds to a time-varying trajectory from the initial to the final configuration of the end effector. By animating the robot at each step over 10 seconds, we can visualize and validate the q(t) profile.</p><p>This implementation serves as a fundamental step towards more advanced applications such as motion planning, control, and grasping for robotic manipulators.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9dde1325f56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring KITTI Visual Ododmetry Dataset.]]></title>
            <link>https://medium.com/@jaimin-k/exploring-kitti-visual-ododmetry-dataset-8ac588246cdc?source=rss-5b28ba3cf255------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ac588246cdc</guid>
            <category><![CDATA[kitti-dataset]]></category>
            <category><![CDATA[visual-odometry]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[autonomous-cars]]></category>
            <category><![CDATA[autonomous-vehicles]]></category>
            <dc:creator><![CDATA[Jaimin-k]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 23:04:26 GMT</pubDate>
            <atom:updated>2023-01-26T23:38:02.131Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring KITTI Dataset: Visual Odometry for autonomous vehicles</h3><p><strong>What is KITTI dataset?</strong></p><p>KITTI is a dataset for autonomous driving developed by the Karlsruhe Institute of Technology and Toyota Technological Institute at Chicago. It is a collection of images and LIDAR data used in computer vision research, such as stereo vision, optical flow, visual odometry, 3D object detection, and 3D tracking. The dataset is freely available for download at <a href="http://www.cvlibs.net/datasets/kitti/">http://www.cvlibs.net/datasets/kitti/.</a></p><p>In this article, we will explore the usage of the KITTI Odometry Dataset. The KITTI Odometry dataset is a benchmark dataset for evaluating the performance of visual odometry algorithms. It consists of a collection of stereo image sequences recorded from a moving vehicle, along with the corresponding ground truth data for the vehicle’s motion.</p><p>This article is going to be Part 1 of the KITTI Visual Odometery series. I plan to publish the remaining articles soon. We will review some fundamentals of computer vision needed to perform the tasks of stereo depth estimation and visual odometry, as well as a demonstration of how to implement these principles using OpenCV in Python.</p><h3><strong>Setting up the dataset</strong></h3><p>Download the <a href="https://www.cvlibs.net/datasets/kitti/user_login.php">velodyne laser data</a> and <a href="https://www.cvlibs.net/datasets/kitti/user_login.php]">grayscale</a> data that we intend to use. You will have to register and login to be able to download the dataset.</p><p>Once you have the dataset downloaded on your system. Create a python file in the same path where you have the folders for the two downloaded datasets.</p><h3><strong>Exploring the dataset with python code</strong></h3><p>Importing the required dependencies — OpenCV, matplotlib.pyplot , numpy, pandas, os.</p><p>Now we will take a look at the ground truth poses loading one of the trajectory sequences from the dataset.</p><pre>poses = pd.read_csv(&#39;../dataset/poses/00.txt&#39;, delimiter=&#39; &#39;, header=None)<br>print(&#39;Size of pose dataframe:&#39;, poses.shape)<br>poses.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*72AXicUKS4yHfB1bCmpBkQ.png" /></figure><p>The dataset contains 4541 rows and 12 columns, where 4541 is the number of image frames and 12 is the result of flattening a 3x4 transformation matrix (Extrinsic Parameters). This matrix stores the 3x3 rotation matrix of the left stereo camera with respect to the global coordinate frame and the 3x1 translation vector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*r_OrR2WUyfUpuybkdEBKGQ.png" /></figure><p>The 3x4 transformation matrix [R|t] store the transformation between the camera’s current coordinate frame and the coordinate frame of the camera’s initial position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*uCDhqrIvulfMJ32PylA1IA.png" /></figure><p>We can verify this by looking at the first pose and observing that the rotational component is identity, with the translation vector equaling zero on all axes.</p><pre><br>first_pose = np.array(poses.iloc[0]).reshape((3,4)).round(2)<br>second_pose = np.array(poses.iloc[1]).reshape((3,4)).round(2)<br>print(&quot;First pose:\n&quot;, first_pose)<br>print(&quot;Second pose:\n&quot;,second_pose)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*UMOcGLh3XIA-8PMiFdYdZw.png" /></figure><p>Now we can store all the ground truth poses, so we can obtain a trajectory plot using it as a sequence of poses and also access this ground truth array for which has all the position and orientation of camera relative to the global coordinate frame.</p><pre>ground_truth = np.zeros((len(poses), 3, 4))<br>for i in range(len(poses)):<br>    ground_truth[i] = np.array(poses.iloc[i]).reshape((3, 4))<br>%matplotlib widget<br>fig = plt.figure(figsize=(7,6))<br>traj = fig.add_subplot(111, projection=&#39;3d&#39;)<br>traj.plot(ground_truth[:,:,3][:,0], ground_truth[:,:,3][:,1], ground_truth[:,:,3][:,2])<br>traj.set_xlabel(&#39;x&#39;)<br>traj.set_ylabel(&#39;y&#39;)<br>traj.set_zlabel(&#39;z&#39;)</pre><p>From the below plot we can see the trajectory of the car having same starting and end points as it looks like a closed path</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*VeWSoW5JUd-bu_tAYoxTYQ.png" /><figcaption>Trajectory of the car</figcaption></figure><h3>Exploring Stereo Image Sequence Dataset</h3><p>We will now load the images captured by the cameras mounted on the car.</p><pre>left_img_files = os.listdir(&#39;data_odometry_gray/dataset/sequences/00/image_0&#39;) <br><br>plt.figure(figsize=(12,6))<br>plt.imshow(left_img_files[0])<br>#to check if we have same number of camera poses for each captured image frame<br>print(&quot;left images-&quot;,len(left_img_files)) #for sequences/00/image_0= 4541<br>print(&quot;camera poses-&quot;,len(poses)) #for dataset/poses/00.txt =4541<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TcMrte5Me3Nsz0fhiOiarw.png" /></figure><p>The number of image frames and poses are equal for each sequence of data. Our first ground truth pose is (0, 0, 0), so we are tracking the motion of the camera with respect to the first camera frame. The camera captures frames at the rate of 10fps, which can be seen using the ‘<em>times.txt</em>’ file in each sequence of the dataset.</p><pre>times = pd.read_csv(&#39;../dataset/sequences/00/times.txt&#39;, delimiter=&#39; &#39;, header=None)<br>times.head() #verify to check frames being captured @10fps</pre><p><strong>Sensor Calibration</strong></p><p>The dataset also has sensor calibration files that we can load to check the information it carries.</p><pre>calibration   = pd.read_csv(&#39;data_odometry_gray/dataset/sequences/00/calib.txt&#39;, delimiter=&#39; &#39;, header=None, index_col=0)<br>calibration</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*rQvv1TBIzfLWC3T838MJmw.png" /></figure><p>Before understanding what all these numbers in the calibration files are, let us take a look at the schematic of the sensor configuration provided by the KITTI team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*v-mr4o3i39wbrSbrcwn2Ug.png" /><figcaption>schematic of the car mounted with sensors</figcaption></figure><p>The above schematic reveals four cameras, one that is a pair of grayscale stereo cameras and another pair of RGB stereo as labelled in the schematic. The distance between a left and right stereo camera is called baseline, which is 0.54 m in this configuration.</p><p>Going back to calibration parameters of the dataset. P0,P1,P2,P3 are the camera projection matrices where P0,P1 are for the two grayscale cameras and the remaining two for RGB cameras. Tr is a translation vector that transforms points from velodyne sensor coordinates to respective rectified camera coordinate systems.</p><p>To know the Projection matrix in depth, it is a 3x4 matrix in this dataset, which has the intrinsic and extrinsic parameters of the camera. Let us print the projection matrix P1 from the calibration.txt file data.</p><pre>P0 = np.array(calibration.loc[&#39;P0:&#39;]).reshape((3,4))<br>P0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*rUvCJKHKg2aVqOFWxKaNeQ.png" /><figcaption>Projection Matrix</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*HDR23HordcDInzu2CtpkWw.jpeg" /></figure><p>A projection matrix (P) is the result of combining the intrinsic and extrinsic matrices of a camera. The intrinsic matrix holds information about the camera’s focal length and optical center, while the extrinsic matrix (R|t) represents the camera’s pose using a 3x3 rotation matrix and a 3x1 translation vector that relates each camera’s coordinate frame to the global coordinate frame, which in this case is the left grayscale camera’s coordinate frame.</p><p>Typically, a camera’s projection matrix is used to transform a 3D point in a global coordinate system into its corresponding 2D pixel coordinates on the camera’s image frame. However, the projection matrices in the calibration.txt file of this dataset are after rectification, which means it maps the points of each camera’s coordinate frame onto one single image plane that is of the left camera.</p><p>When working with standard camera projection matrices, the extrinsic matrix is responsible for transforming a point from the global coordinate frame into the frame of the camera. From the camera placement in the schematic figure displayed before if we take the origin of the global coordinate system (as seen in the left grayscale camera) and express it in the coordinates of the right grayscale camera, we would expect the X-coordinate to be -0.54, as the left camera’s origin is 0.54 meters to the left of the right grayscale camera’s origin. To verify this, we can decompose the projection matrix given for the right camera into its intrinsic matrix (k), rotation matrix (R), and translation vector (t) using a function cv2.decomposeProjectionMatrix() of OpenCV.</p><p><strong>Decomposing Projection matrix</strong></p><pre>P1 = np.array(calibration.loc[&#39;P1:&#39;]).reshape((3,4))<br>P1<br>#decomposing projection matrix<br>k1,r1,t1,_,_,_,_= cv2.decomposeProjectionMatrix(P1)<br><br>t1 = t1/t1[3] #for homogeneous coordinates<br>print(&quot;\n&quot;,t1)<br><br>print(&quot;intrinsic matrix:\n&quot;,k1)<br>print(&quot;rotation matrix: \n&quot;,r1)<br>print(&quot;translation vector:\n&quot;,t1.round(4))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*_maxDE85axdOoht9xEpCyQ.png" /></figure><p>By decomposing the projection matrix, we were able to obtain the intrinsic matrix (k), the rotation matrix (R), and the translation vector (t) for that camera. These matrices can be used to understand how the camera is positioned and oriented in the global coordinate frame and how it captures the 3D points and projects them into its 2D image frame.</p><h4><strong>Intrinsic matrix:</strong></h4><p>The intrinsic matrix, also known as the camera matrix, is a 3x3 matrix that describes the internal properties of a single camera. It includes information about the focal length, principal point, and skew of the camera.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*uCDhqrIvulfMJ32PylA1IA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*Tpq5EV9kyc6GMVjBNT4F0Q.png" /></figure><p>The intrinsic matrix can be used to map 3D world points to 2D image points by a perspective projection. The intrinsic matrix is one of the outputs of the camera calibration, expressed as k. fx, fy being the focal length the parameters c_x and c_y, is used to map incoming light rays to the correct pixel coordinates on the camera sensor. These parameters represent the optical center of the image, which may not necessarily be at the center of the sensor due to slight misalignment with the lens. This adjustment ensures that the image captured by the camera is accurate.</p><p>Let us check the optical center position comparing it with the image</p><pre>test_img = cv2.imread(&#39;data_odometry_gray/dataset/sequences/00/image_0/000000.png&#39;)<br>test_img.shape<br>cx = k1[0,2]<br>cy = k1[1,2]<br>print(&#39;Actual center of image (x, y):&#39;, (test_img.shape[1]/2, test_img.shape[0]/2))<br>print(&#39;Optical center of image (cx, cy)&#39;, (cx, cy))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*M9iC-9DUbMslzHCNb6Hcvw.png" /></figure><p>Camera calibration is critical because it accounts for the slight misalignment between the optical center of the camera and the center of the image. Without this information, the projection of points in the world onto the image would be inaccurately placed. The intrinsic matrix, which includes parameters such as c_x and c_y, is used to correct this misalignment and ensure that the projected points are correctly mapped to the appropriate pixel coordinates on the camera sensor.</p><h4><strong>Extrinsic matrix:</strong></h4><p>By using the extrinsic matrix extracted from the projection matrix, we can determine the position of the origin of the global coordinate frame (as seen in the left grayscale camera) in the right camera’s frame. The schematic indicates that we should expect the origin to be 0.54 meters to the left in the right camera’s frame.</p><pre>extrinsic_mat = np.hstack([r1, t1[:3]]) #dropping the last row of t1 as it was in homogenous coordinates<br>extrinsic_mat.round(4)<br>origin = np.array([0, 0, 0, 1])<br>T = extrinsic_mat.dot(origin).round(4).reshape(-1,1)<br>print(T)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*4bgojfIrIeGSbX-WNMkA1A.png" /></figure><p>The X value of the projection matrix being positive 0.54, indicating that the origin of the global coordinate frame is located 0.54 meters to the right of the camera frame, suggests that the projection matrix is not for the right camera but for the left camera and the origin of the right camera is being treated as the global coordinate frame. This is because the projection matrix is a rectified projection matrix for a stereo rig, designed to project points from multiple camera’s coordinate frames onto the same image plane, instead of projecting points from one camera’s coordinate frame onto multiple camera’s image planes.</p><p>The rectified projection matrices transform 3D points in the sensor’s coordinate frame to 2D pixel locations on the image plane of the left grayscale camera.</p><p>To convert the rectified projection matrix for the left grayscale camera to a regular projection matrix for the right grayscale camera, we decompose the matrix, invert the extrinsic matrix and recombine it with the intrinsic matrix.</p><p>Now let&#39;s try to find the depth or distance of the point from the left camera.</p><pre>pt = np.array([3, 2, 4, 1]).reshape(-1,1)</pre><p>To determine the depth of a point from the left camera, we need to transform the point into the coordinate frame of the left camera and then take the Z value.</p><pre>pt_transform = ground_truth[4].dot(pt)<br>depth_from_left_cam = pt_transform[2]<br><br>print(&#39;point:\n&#39;, pt)<br>print(&#39;Transformed point:\n&#39;, pt_transform)<br>print(&#39;Depth from left camera:\n&#39;, depth_from_left_cam)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*LwOsOHyK5ulb2JcpHnZ3jw.png" /></figure><p>We can use this depth and the intrinsic matrix k1 we obtained before to get the projection of the point we used to find depth onto the image plane, which will give us the pixel coordinates.</p><pre>px_coordinates = k1.dot(pt_transform) / depth_from_left_cam<br>print(&#39;Pixel Coordinates on image plane:&#39;, px_coordinates)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*6QvVGhhgtQYxV_7V6-vmYA.png" /></figure><p><strong>Getting back to the original 3D point position</strong></p><p>If we know the depth as we obtained above, we can also get the 3D position of the point which we had picked from the 2D projection of the point on the image plane by normalizing the pixel coordinate we obtained above.</p><pre>normalized_pixel_coordinates = np.linalg.inv(k1).dot(px_coordinates)<br>print(&#39;Normalized pixel Coordinates:\n&#39;, normalized_pixel_coordinates.T)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*DIg636AQJTUR7utjX8YKiw.png" /></figure><p>From these normalized coordinates we can restore the original 3D transformed point back since we now know the depth. This is done by multiplying the Normalized pixel coordinates with depth.</p><p>To get back to the original point we picked to estimate the depth in the original coordinate frame, we can take the following steps:</p><ol><li>Add a row of (0, 0, 0, 1) to the transformation matrix to make it homogeneous.</li><li>Invert this homogeneous transformation matrix.</li><li>Multiply the inverted matrix by the restored 3D coordinates in the camera frame, which should be augmented with 1 at the end to make them homogeneous.</li></ol><pre>pt_3D = normalized_pixel_coordinates.T * depth_from_left_cam<br>pt_3D.round(4)<br>print(&quot;restored originally transformed 3D point\n&quot;,pt_3D.T)<br><br>transform_homogeneous = np.vstack([ground_truth[4], np.array([0, 0, 0, 1])])<br>inv_transform_homogeneous = np.linalg.inv(transform_homogeneous)<br>pt_3D_homogeneous = np.append(pt_3D, 1)<br>restored_pt = inv_transform_homogeneous.dot(pt_3D_homogeneous)<br>print(&quot;restored original homogeneous point:\n&quot;,restored_pt)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*l3bE7kGCM-e0kqwhV8mvAQ.png" /></figure><p>To verify that we obtained back our original point, you can check the points we picked while estimating the depth in the previous section and compare them with the restored point values which are found to be the same as they need to be as shown below in the output we had obtained before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*LwOsOHyK5ulb2JcpHnZ3jw.png" /><figcaption>output from the previous section</figcaption></figure><h4>Conclusion</h4><p>In conclusion, we explored the dataset to gain a better understanding of its use in the field of visual odometry. It provides a comprehensive set of stereo image sequences along with the corresponding ground truth data for the vehicle’s motion. Overall, the KITTI Odometry dataset is an essential tool for advancing the state of the art in visual odometry and related areas.</p><p><strong>References:</strong></p><p>1] <a href="https://www.cvlibs.net/datasets/kitti/">https://www.cvlibs.net/datasets/kitti/</a></p><p>2] <a href="https://opencv.org/">https://opencv.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ac588246cdc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Learning for Autonomous Driving]]></title>
            <link>https://medium.com/@jaimin-k/deep-learning-for-autonomous-driving-ca7a4d29b852?source=rss-5b28ba3cf255------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca7a4d29b852</guid>
            <category><![CDATA[udacity]]></category>
            <category><![CDATA[autonomous-vehicles]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[self-driving-cars]]></category>
            <category><![CDATA[autonomous-cars]]></category>
            <dc:creator><![CDATA[Jaimin-k]]></dc:creator>
            <pubDate>Mon, 04 Oct 2021 08:42:32 GMT</pubDate>
            <atom:updated>2021-10-04T14:52:59.341Z</atom:updated>
            <content:encoded><![CDATA[<h4>Behavioral Cloning in Self-Driving Cars</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*yTxaOb7PeT_LHZXBmeET6Q.gif" /></figure><p><strong>Goal:</strong> To mimic the driving behavior of a human driver by training a model using Deep Neural Networks for the car to drive autonomously on the simulator and complete an entire lap for two different tracks.</p><p><strong>Udacity’s</strong> <strong>Self-Driving</strong> <strong>Car Simulator:</strong></p><p>The Udacity simulator contains two tracks and two modes:</p><p><strong>1. Training mode: </strong>The dataset is generated from the simulator by the user, driving the car in training mode.</p><p><strong>2. Autonomous mode:</strong> Evaluate how the deep learning model performs after being trained by the user data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*4wnfaatsaW4K4kDFlLyIpg.png" /><figcaption><strong>Self-Driving Car simulator window</strong></figcaption></figure><p>The challenge was to generalize the performance on different tracks of the simulator. That means, training the model using the dataset created on one of the tracks and testing it on the other track of the simulator, for which <strong>good quality</strong> of collected data to train the model was essential.</p><p>The data has to be acquired by driving the car across the track to collect the left, right, center captured images of the track while controlling the car with the keyboard. This served as the input data in the form of a driving log(.csv) to train the model. After a lot of trials, (performed over a week) I managed to collect data and train the model after many iterations for which the car was able to maneuver smoothly on both the tracks of the simulator.</p><p><strong>CLIENT — SERVER SIMULATOR CONFIGURATION:</strong></p><p><strong>SERVER:</strong> Simulator acts as a server where the program(client) can connect to and receive a stream of image frames from, in real-time.</p><p><strong>CLIENT:</strong> Python program which uses the machine learning model trained and developed on <em>keras</em> to process the track(road) images and predicts the best driving control parameter- throttle &amp; steering angles which change the car’s direction and the speed. As this happens, the program(client) will receive new image frames in real-time, sending the predicted values back to the simulator(server) to drive the car autonomously in the simulator and keep it from falling off the track.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*fTHtxx6TI3h1JkI9mxMtuQ.png" /><figcaption><strong>Client-Server simulator configuration</strong></figcaption></figure><p>This project was built on <a href="https://research.google.com/colaboratory/">Google Colab</a> due to the GPU-intensive task involved in training the model.</p><p><strong>Recording data in Training mode:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*1wSwRTY3ddPGgeXdMmJ9_A.png" /><figcaption><strong>Track-1: used to collect training data</strong></figcaption></figure><p><strong>Stored data-log:</strong></p><p><strong>Columns 1, 2, 3:</strong> path to the dataset images of center, right and left cameras respectively captured for each instance.</p><p><strong>Column 4:</strong> steering angle</p><p>0 →straight driving, positive value →right turn, negative value → left turn.</p><p><strong>Column 5:</strong> throttle value</p><p><strong>Column 6:</strong> brakes or deceleration</p><p><strong>Column 7:</strong> speed of the car(mph)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2algCzrKgk5YflwSgHasQ.png" /><figcaption><strong>driving_log.csv</strong></figcaption></figure><p>A total of 24,112x3 sample images(center, right, left camera) were recorded driving the car manually on Track_1</p><p><strong>Images from the data set:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*trloIoFonAWfW1I35W06xA.png" /></figure><p><strong>Reading the data:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*Fa5Bpe-NsseCFqxQBhUn_A.png" /><figcaption>Histogram for samples distributed for left, right turn and no turn(middle bar) in steering angle</figcaption></figure><p>Constructing a histogram from the number of samples recorded for left &amp; right turn on either side of the center. As the histogram depicts, the samples for straight steering are substantially more. For training the model on this data, there is a likelihood of overfitting on driving straight and the car not turning effectively. After removing the extraneous data for straight angle and flattened the histogram by considering samples only about 700 samples for driving straight, giving a more uniform distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*4JYhqhbrTgReK5eaa-lskw.png" /><figcaption>Histogram after removal of extraneous samples</figcaption></figure><p><strong>Splitting the data into training and validation sets:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eju0pj32_NqToq4KIAs8tA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*Qggb_HSUxsiyLH6sI_mdPw.png" /></figure><p><strong>DATA AUGMENTATION &amp; IMAGE PRE-PROCESSING:</strong></p><p>Generalizing the behavior of the car on Track_2 which it was never trained for is a challenge. It is difficult to train a self-driving car model for every track possible, as the data will be too huge to process and it is challenging to gather and have sufficient datasets for all the weather conditions and roads. Thus, there is a need of generalizing the behavior on different tracks by augmenting the existing image samples by preprocessing them before training.</p><p>The training set size was increased to reduce the risk of overfitting by applying various transforms in combination to make the model more robust to work on Track 2.</p><p><strong>i. Zooming the sample images:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*adUyogTH8ZN4WcijHdustA.png" /></figure><p><strong>ii. Panning the sample images:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*VpPjWQ1bsi5-FORz4LeMtA.png" /></figure><p><strong>iii. Altering brightness of image:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*DxTZk0kk2iGJjnj0u42b2w.png" /></figure><p><strong>iv. Flipping</strong> the sample image and steering angle associated with that image, for models to get trained for turns on the opposite side too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*70shqAr1HbUmeeLEA1tSNQ.png" /></figure><p><strong>v.</strong> Combining the above augmentation techniques &amp; randomizing its occurrence in the training data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*8MN9GQvW2G2TJvi6YiP_Hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*-Fxmy1bq123_vBOd7dWacw.png" /></figure><p><strong>Preprocessing images:</strong></p><p>The images were preprocessed to decrease training time by:</p><p>→ Cropping the image till the horizon</p><p>→ Applying Gaussian blur to the images</p><p>→ Converting the color space from RGB to YUV</p><p>→ Normalizing the range of the values of pixels</p><p><strong>Training the model and Experimental configurations:</strong></p><p>Many configurations were tried to set up the model for training the Python Client to provide the Neural Network outputs that drive the autonomous car accurately on the simulator by tweaking the parameters and experimenting rigorously to reach the best combination. Though each of the models had their unique behaviors (if the car runs smoothly on track 1 it was unable to do so on track 2 and vice versa) and differed in their performance with each tweak, the following combination of configuration can be considered as the optimal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*lmqsVOrDFKb_mco3T4mP2Q.png" /></figure><p>The proposed model has achieved maximum Accuracy when Adam optimizer and mean squared error loss function is applied to the convolutional neural network which was obtained by few modifications in the NVIDIA model</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*x9AjzjxosCXPwDFJ1cb04g.png" /><figcaption>NVIDIA Model</figcaption></figure><p>Finally, the model was tested and validated by connecting the python client with the simulator in autonomous mode, for which the car was able to complete both Track_1 and Track_2 of the simulator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*c-F3m03k91UgIUXRLaCWVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*pO0E2QIKS7Fjgyk200vx9A.png" /></figure><p><strong>Results:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxxuEDx_zlsU&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxxuEDx_zlsU&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FxxuEDx_zlsU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc699be41d7df108f038719bb2c9fb44/href">https://medium.com/media/bc699be41d7df108f038719bb2c9fb44/href</a></iframe><p><strong>Conclusion: </strong>The key takeaway was that the training data collection and augmentation was the most critical factor in creating a successful model, rather than model architecture and hyperparameter tuning.</p><p>Although the driving in the above video may not be the best ever possible, the experience of implementing the project was edifying, for having to train a model that autonomously drives the car without going off the road.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca7a4d29b852" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using CNN to Classify Handwritten Digits with TensorFlow and Keras]]></title>
            <link>https://medium.com/@jaimin-k/using-cnn-to-classify-handwritten-digits-with-tensorflow-and-keras-122962d340b2?source=rss-5b28ba3cf255------2</link>
            <guid isPermaLink="false">https://medium.com/p/122962d340b2</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Jaimin-k]]></dc:creator>
            <pubDate>Sun, 12 Sep 2021 18:42:28 GMT</pubDate>
            <atom:updated>2022-11-03T23:43:07.281Z</atom:updated>
            <content:encoded><![CDATA[<p>To build a simple neural network and train it to recognize handwritten digits using the MNIST dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/0*2Y2gPAlGU7HyWuTA.png" /></figure><p>The steps involved are:</p><ol><li>Loading the dataset</li><li>Processing the data</li><li>Building and compiling of the model</li><li>Training and evaluating the model</li></ol><p><strong>Loading the data:</strong></p><p>The <strong>MNIST database</strong> (Modified <a href="https://en.wikipedia.org/wiki/National_Institute_of_Standards_and_Technology">National Institute of Standards and Technology</a> database) is a large database of handwritten digits (0 to 9). The database contains 60,000 training images and 10,000 testing images, each of size 28x28.</p><pre>import keras<br> from keras.datasets import mnist<br> #load mnist dataset<br> (X_train, y_train), (X_test, y_test) = mnist.load_data()</pre><p>Here X_train contains 60,000 training images’ data each of size 28x28 and y_train contains their corresponding labels. Similarly, X_test contains 10,000 testing images’ data each of dimension 28x28 and y_test contains their corresponding labels. Let’s visualize few data from training to get a better idea about the purpose of the deep learning model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*1keKOjzACZXdk65Oy3l4mQ.png" /><figcaption>dataset samples</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*j2IQoiI9oLWdevdjWBhRDQ.png" /></figure><p><strong>Processing the data</strong></p><p>Resizing images: In order to train our neural network to classify images, we first have to unroll the height x width pixel format into one vector as the <em>input vector</em>. So its length must be 28 x 28 = 784.</p><p>Normalization of input: The pixel values range from 0 to 255: the background majority close to 0, and those close to 255 representing the digit.</p><p>Normalizing the input data helps to speed up the training. Also, it reduces the chance of getting stuck in local optima, since stochastic gradient descent was used to find the optimal weights for the network.</p><p>One-hot encoding: The categories — digits from 0 to 9 are encoded — using one-hot encoding. One hot encoding is a process by which categorical variables are converted into a form that could be provided to ML algorithms to do a better job in prediction. The result is a vector with a length equal to the number of categories. The vector is all zeroes <em>except</em> in the position for the respective category. Thus, ‘7&#39; will be represented by [0,0,0,0,0,0,0,1,0,0]</p><p><strong>Building &amp; compiling the network</strong></p><p>After the data is ready to be fed to the model, we define the architecture of the model and compile it with the Adam <a href="https://keras.io/optimizers/">optimizer function</a>, cross-entropy <a href="https://keras.io/losses/">loss function</a>, and its <a href="https://keras.io/metrics/">performance metrics</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*9ndwNdqJSt1WcZm8X3xtHw.png" /><figcaption>Model Architecture</figcaption></figure><p>The last layer consists of connections for our 10 classes.</p><pre>def leNet_model():</pre><pre>model = Sequential()</pre><pre>model.add(Conv2D(30, (5, 5), input_shape=(28, 28, 1), activation=&#39;relu&#39;))</pre><pre>model.add(MaxPooling2D(pool_size=(2, 2)))</pre><pre>model.add(Conv2D(15, (3, 3), activation=&#39;relu&#39;))</pre><pre>model.add(MaxPooling2D(pool_size=(2, 2)))</pre><pre>model.add(Flatten())</pre><pre>model.add(Dense(500, activation=&#39;relu&#39;))</pre><pre>model.add(Dense(num_classes, activation=&#39;softmax&#39;))</pre><pre># Compile model</pre><pre>model.compile(Adam(lr = 0.001), loss=&#39;categorical_crossentropy&#39;, metrics=[&#39;accuracy&#39;])</pre><pre>return model</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*h9RxehTfk9aae3NCWFdInA.png" /><figcaption>model summary</figcaption></figure><p>Training the model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*3iSm0jZvE18kBzpYQ5eYkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*ZIPsXS_qvMLoXU06XFMKew.png" /></figure><p>A dropout layer was added to reduce the overfitting and for the lines to converge, but the model performed quite poorly and was not able to predict the correct class accurately.</p><h4>Evaluating the Model’s Performance</h4><p>The performance of the model was checked on images with handwritten digits and was able to predict the correct class of the digit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*DJVocGe4lh6uHJauwvkKYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*DvA03vSQqZZbOT1vboX9AA.png" /></figure><p>The model also gave a few wrong predictions, as in some cases the digits were blurred to a high extent and difficult to interpret even for a human reader.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=122962d340b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>