<?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 Tao Shatoo on Medium]]></title>
        <description><![CDATA[Stories by Tao Shatoo on Medium]]></description>
        <link>https://medium.com/@shartoo518?source=rss-9561ec4f6d0a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*x_TfBCjH2D5v4v7O.</url>
            <title>Stories by Tao Shatoo on Medium</title>
            <link>https://medium.com/@shartoo518?source=rss-9561ec4f6d0a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:19:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shartoo518/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[ProgressAI: A gemma-3n based personal goal management tool]]></title>
            <link>https://medium.com/@shartoo518/progressai-a-gemma-3n-based-personal-goal-management-tool-07e3962c9d93?source=rss-9561ec4f6d0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/07e3962c9d93</guid>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[google-gemma]]></category>
            <dc:creator><![CDATA[Tao Shatoo]]></dc:creator>
            <pubDate>Sun, 03 Aug 2025 14:26:09 GMT</pubDate>
            <atom:updated>2025-08-03T14:27:10.742Z</atom:updated>
            <content:encoded><![CDATA[<p>1 Goal</p><p>Build a personal goal management assistant based on gemma-3n. Currently, two examples are used for demonstration: weight control and book reading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKIS4mPjAD00uTUOhTb_iA.jpeg" /></figure><h3>2 Drawbacks of Traditional Goal Management Assistants</h3><h4>2.1 Data Processing</h4><p><strong>Traditional apps</strong>: All interactions are text forms, forcing users to manually fill in numbers one by one, step by step. The format is very simple. Furthermore, many data points are uncertain to the user. For example, for a goal like weight control, the calorie intake for each meal and the calorie expenditure for each exercise are calculated. Traditional apps only accept predefined data formats.<br><strong>gemma-3n</strong>: Accepts input in any format, including text, audio, and images. It can interpret key data from various formats. For example, it can estimate the total calories in a photo of breakfast food and identify a user’s emotions and stress from an audio clip.</p><h4>2.2 Interaction Flow</h4><p><strong>Traditional apps</strong>: The process is standardized and routine, requiring users to follow predefined steps.<br><strong>gemma-3n</strong>: Non-standardized. The same goal can produce different interactive responses for different users. gemma-3n can act as a dynamic brain.</p><h4>2.3 Emotional Capabilities</h4><p>Thanks to gemma-3n’s multi-domain expert knowledge, it possesses the capabilities of a professional human psychologist, capable of analyzing and interpreting the emotional fluctuations hidden within a user’s data in various formats. It can not only offer appropriate encouragement when a user is feeling down, but can even attempt to guide them when they experience stress and anxiety. Human emotional fluctuations are a significant factor in achieving goals, and before the advent of LLM, no digital app had this capability</p><h4>2.4 Multi-Expert Capabilities</h4><p>Not only does no traditional app possess this capability, but the knowledge of any individual human is also limited. However, the gemma-3n model, trained on all known human knowledge, possesses knowledge across all domains and nearly reaches expert-level capabilities. For example, in a weight management scenario, a user sends gemma-3n a body image. Leveraging its medical expertise, it can determine the cause of fat accumulation based on body shape distribution. Leveraging its fitness expertise, it can determine appropriate exercises based on fat distribution. Leveraging its nutritional expertise, it can provide reasonable and scientific dietary recommendations</p><h4>2.5 Summarization and Association</h4><p>Take reading a book as an example. gemma-3n can process texts up to 32k in length and summarize content at the paragraph, chapter, and even entire book levels, helping users quickly understand the book’s content. Furthermore, gemma-3n can engage with users about specific content, providing multi-faceted and multi-faceted understanding.<br>Another significant advantage is gemma-3n’s powerful comprehension capabilities and vast knowledge base, enabling it to generate countless connections between any knowledge point in any book, aiding user retention and understanding.<br>The two core aspects of book reading — comprehension and memory — can be easily accomplished with gemma-3n.</p><h3>3 Technical Architecture</h3><h4>3.1 overall Architecture</h4><p>Because gemma-3n lacks memory functionality, it needs to read and write different storage files as memory data when handling different target tasks. Furthermore, to present data in a manner consistent with human-computer interaction practices, each interaction data must be processed into a standard output format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dl8SU5Wer3hBTjyAeQ5u6w.png" /></figure><h4>3.2 Memory and Storage</h4><p>We predefine the key metric data required for current goal management and the data that will be updated during each conversation. We store these data in local files and memory using a standardized JSON format. Then, during each conversation with the gemma-3n model, we use the predefined metadata in the JSON as prompts, allowing gemma-3n to automatically detect which data metric changes are involved in the conversation and automatically update the data in the background.</p><h4>3.3 Data Definition</h4><p>For each goal management project, we analyze and develop clear and comprehensive data definitions. This allows gemma-3n to more accurately understand the requirements and precisely control the progress of the conversation and the goal. For example, for the weight management goal, we defined the following key data.</p><p><strong><em>Basic User Information</em></strong></p><ul><li><strong>Fixed Attributes:</strong></li><li>age: User&#39;s age.</li><li>gender: User&#39;s gender.</li><li>heightCm: User&#39;s height in centimeters.</li><li>initialWeightKg: User&#39;s weight at the start of the program in kilograms.</li><li>currentWeightKg: User&#39;s current weight in kilograms.</li><li>targetWeightKg: User&#39;s target weight in kilograms.</li><li>targetDate: The target date to achieve the weight goal.</li><li>weeklyWeightLossTargetKg: User&#39;s weekly target weight loss in kilograms.</li><li>progressPercentage: Calculated percentage of progress towards the target weight.</li><li>weightLossPhase: Current phase of the weight loss journey (e.g., &quot;Initial Phase&quot;).</li><li>occupation: User&#39;s occupation, which may influence activity levels and stress.</li><li>activityLevel: User&#39;s general activity level (e.g., &quot;Sedentary&quot;, &quot;Lightly Active&quot;).</li><li>healthConditions: List of known health conditions.</li><li>medicalAllergies: History of drug allergies.</li><li>dietaryPreferencesRestrictions: User&#39;s dietary preferences or restrictions (e.g., &quot;Vegetarian&quot;, &quot;Gluten-Free&quot;).</li><li>sleepPatternDescription: A description of the user&#39;s sleep habits.</li><li>stressLevelDescription: A description of the user&#39;s stress levels.</li><li>longTermGoalsDescription: A description of the user&#39;s long-term health and fitness goals.</li><li>startDate: The date the user started using the app.</li><li>bodyShape: User&#39;s body shape (e.g., &quot;Rectangle&quot;).</li><li><strong>Daily Data (via </strong><strong>WeightEntry):</strong></li><li>weightHistory: A list of daily weight entries.</li><li>date: The date of the weight recording.</li><li>weightKg: The recorded weight in kilograms.</li></ul><p><strong><em>Fitness Information</em></strong></p><ul><li><strong>Fixed Attributes:</strong></li><li>bodyMeasurements: Map of body circumference measurements (e.g., Waist, Hip, Chest).</li><li>likedExercises: List of exercises the user enjoys.</li><li>dislikedExercises: List of exercises the user dislikes.</li><li>preferredWorkoutStyle: User&#39;s preferred workout style.</li><li>physicalLimitations: List of any physical limitations or old injuries.</li><li>fitnessGoals: List of the user&#39;s fitness goals.</li><li><strong>Daily Data (via </strong><strong>FitnessDailyData):</strong></li><li>dailyDataHistory: A list of daily fitness data entries.</li><li>exerciseItem: Description of the exercise performed.</li><li>estimatedCalorieBurn: Estimated calories burned during the workout.</li><li>fatLossArea: Specific area targeted for fat loss (if any).</li><li>workoutDurationMinutes: Duration of the workout in minutes.</li><li>intensityLevel: Workout intensity (e.g., &quot;Low&quot;, &quot;Medium&quot;).</li><li>exerciseSummary: A summary of the exercise session.</li><li>averageHeartRate: Average heart rate during the workout.</li><li>peakHeartRate: Peak heart rate during the workout.</li><li>strengthTrainingDetails: Details of strength training (sets, reps, weight).</li><li>cardioDetails: Details of cardio training (e.g., distance, pace).</li><li>userBodyStatus: User&#39;s body status after the workout.</li><li>feelingAfterWorkout: How the user felt after the workout.</li><li>recoveryStatus: User&#39;s recovery status.</li></ul><p><em>Medical Information</em></p><p>…</p><p><em>Nutritional Information</em></p><p>…</p><p><em>Psychological Information</em></p><p>…</p><h3>4 Technical Issues and Solutions<br>4.1 limited of input length for gemma-3n model</h3><p>For the “reading book” goal, we may need to analyze a book containing hundreds of thousands of words at once. We have gemma-3n analyze approximately 1,000 words each time, summarize them, and save them to JSON. We continuously compress the data before creating a final summary. The entire book content only needs to be analyzed when loading it for the first time. Subsequent reads can be performed directly on the fragmented segments and summary information. In these cases, only the JSON file information needs to be read.</p><h4>4.2 Android Studio APK cannot compile APKs larger than 2GB</h4><p>We cannot simply place large files like gemma-3n-E4B-it-int4.task in the assets directory and compile them. We can place them in the ApplicationDocumentsDirectory directory. After compilation, manually navigate to that directory in Android Studio’s Device Explorer and upload the downloaded model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2CpmVTwyigH7AqwoJSgzA.png" /></figure><h4>4.3 Rapid Development</h4><p>Developing a working app in such a short time presented many technical challenges. However, with the help of Google Gemini AI, we created a basic prototype in Figma and sent the design to Gemini AI. It consistently completed the task quickly, correctly understood the requirements 95% of the time, and ran the app without modification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-6fOGhojTIWRhoWTzb_agQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07e3962c9d93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1 概览]]></title>
            <link>https://medium.com/@shartoo518/1-%E6%A6%82%E8%A7%88-5921fa471efb?source=rss-9561ec4f6d0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5921fa471efb</guid>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[sift]]></category>
            <dc:creator><![CDATA[Tao Shatoo]]></dc:creator>
            <pubDate>Thu, 14 Mar 2019 08:51:27 GMT</pubDate>
            <atom:updated>2019-03-14T08:51:53.435Z</atom:updated>
            <content:encoded><![CDATA[<h3>SIFT 特征详解</h3><p>SIFT特征即Scale-Invariant Feature Transform，是一种用于检测和描述数字图像中的局部特征的算法。它定位关键点并以量化信息呈现（所以称之为描述器），可以用来做目标检测。此特征可以被认为可以对抗不同变换（即同一个特征在不同变换下可能看起来不同）而保持不变。</p><p>可以通过这个<a href="http://weitz.de/sift/index.html?size=large">网站 SIFT特征在线计算</a>，直接查看一张图片中的SIFT特征，你需要准备一张小图片，然后上传到网站，就会自动计算出该图像的SITF特征。如果对SIFT特征计算步骤缺乏形象的认识，可以去这个网站互动下，它可以可视化每个步骤。</p><p>SIFT特征的提取步骤</p><ol><li>生成高斯差分金字塔（DOG金字塔），尺度空间构建</li><li>空间极值点检测（关键点的初步查探）</li><li>稳定关键点的精确定位</li><li>稳定关键点方向信息分配</li><li>关键点描述</li><li>特征点匹配</li></ol><h3>2 生成差分高斯金字塔</h3><p>参考 <a href="https://shartoo.github.io/image-pramid/">图像处理中各种金字塔</a> 得到一组如下图</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*XLf66ndb---vS8VviQOFTQ.png" /></figure><h3>3 空间极值点检测</h3><p>从第2步的差分高斯金字塔(DOG)中可以得到不同层级不同尺度的金字塔，<strong>所谓的特征就是一些强的、有区分力的点</strong>。DOG中这些有区分力的点就是极值点，即每个像素都要和相邻点(<strong>此处的相邻不仅仅是水平面的前后左右，还有上下尺度的前后左右</strong>)比较，看其是否比它的图像域(水平方向上)和尺度空间域(垂直方向上)的相邻点大或者小，下图是示意图：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*OCxOlR9AYYi1MdGla102Jg.png" /></figure><p>在二维图像空间，中心点与它3x<em>3邻域内的8个点做比较，在同一组内的尺度空间上，中心点和上下相邻的两层图像的2</em>9个点作比较，如此可以保证检测到的关键点在尺度空间和二维图像空间上都是局部极值点。所以确定极值点，需要当前像素点，上图中中间黑色个点3×3−1(当前像素点，上图中中间黑色X)+2×9=26个点。</p><p>从第2小节中，我们计算得到的极值点由如下黄色和红色标记（其中黄色圆圈的标记表明，它虽然是极值点，但是由于绝对值过小，在后续处理时会被丢弃）</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*JfFdbkvJC_sEcs6BHA-ZYQ.jpeg" /></figure><p>我们选取图中间用蓝色矩形框标记的红色点，查看其灰度值(下图正中间红色点)，可以看到它在当前差分金字塔取得了极小值。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*PXDsMltGrycd0lvHxMeh1A.jpeg" /></figure><h3>4 稳定关键点的精确定位</h3><p>上面步骤得到的极值点中存在大量不稳定地点，有些可能是噪音导致的，比如第3节中黄色圆圈标记的点。我们需要去除这些不稳定地像素点。即去除DOG局部曲率非常不对称的像素。此步骤，需要计算空间尺度函数的二次泰勒展开式的极值来完成。同时去除低对比度的关键点和不稳定的边缘响应点(因为DoG算子会产生较强的边缘响应)，以增强匹配稳定性、提高抗噪声能力。</p><p>具体步骤如下：</p><ol><li>空间尺度函数泰勒展开式如下：</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*NMdGmuqX3q1x4dwhlG8Mgw.png" /></figure><p>2. 在已经检测到的特征点中，要去掉低对比度的特征点和不稳定地边缘响应点。去除低对比度的点：把x^的值代回，即在Dog 空间的极值点D(x)处取值，<strong>只取前两项</strong>可得：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*0edmtrOs4LXO5o3uFaddwQ.png" /></figure><p>若 |D(x^)≥0.003，该特征点就保留下来，否则丢弃</p><p>3.边缘响应的去除。一个定义不好的高斯差分算子的极值在横跨边缘的地方有较大的曲率，而在垂直边缘的方向有较小的曲率。主曲率通过一个2×2的Hessian矩阵H去求出：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/1*KUwZkVcglEhh9FOK_MmiAg.png" /></figure><p>使用python计算hessian矩阵的代码可以参考</p><pre>import numpy as np</pre><pre>def hessian(x):</pre><pre>&quot;&quot;&quot;</pre><pre>Calculate the hessian matrix with finite differences</pre><pre>Parameters:</pre><pre>- x : ndarray<br>Returns:  an array of shape (x.dim, x.ndim) + x.shape<br>where the array[i, j, ...] corresponds to the second derivative x_ij</pre><pre>&quot;&quot;&quot;</pre><pre>x_grad = np.gradient(x)</pre><pre>hessian = np.empty((x.ndim, x.ndim) + x.shape, dtype=x.dtype)</pre><pre>for k, grad_k in enumerate(x_grad):</pre><pre># 遍历每个维度，在一阶导数的所有项再次使用梯度</pre><pre>tmp_grad = np.gradient(grad_k)</pre><pre>for l, grad_kl in enumerate(tmp_grad):</pre><pre>hessian[k, l, :, :] = grad_kl</pre><pre>return hessian</pre><pre>x = np.random.randn(100, 100, 100)</pre><pre>hessian(x)</pre><p>导数由采样点相邻差估计得到。D的主曲率和H的特征值成正比，令α为较大特征值，β为较小的特征值，则</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*dDpIm21tCUmrUV6YALe09w.png" /></figure><p>而(1+γ)2γ的值在两个特征值相等的时候最小，随着γ的增大而增大，因此，为了检测主曲率是否在某阈值γ下，只需检测</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*GgCEZaGwlQvFsQQbk6-sww.png" /></figure><p>在SIFT特征提取的原论文中，提到<strong>如果α+βαβ&gt;(γ+1)2γ，则丢弃此像素点</strong>，论文中γ=10</p><h3>5 给特征点赋值一个128维方向参数</h3><p>经过上面的步骤，我们已经确定了一些灰度值极值点。接下来，我们需要确定这些极值点的方向。为关键点分配方向信息所要解决的问题是使得关键点对图像角度和旋转具有不变性。方向的分配是通过求每个极值点的梯度来实现的。 <br> 对于任一关键点</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*W0U_MD-BFVb5Ab3pVKeXTg.png" /></figure><p><strong>分配给关键点的并不直接是关键点的梯度方向，而是按照一种梯度方向直方图方式给出的</strong> <br> 计算方法</p><ol><li>计算关键点为中心邻域内所有点的梯度方向。0–360度</li><li>每个方向10度，共36个方向。</li><li>统计累计落在每个方向点的关键点个数，依次生成梯度直方图</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*z314xE_FpEwmXiLj7XMAtA.png" /></figure><p>具体在图像实例中，某个极值点的梯度方向直方图如下：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*De19P3-VbJ3HJTcsExgFdg.jpeg" /></figure><p>上图中，左图矩形框内的红色小圆圈代表点击的极值点，中间图案代表最终得到的极值点的主方向，右图为对应的梯度方向直方图。</p><p>除此之外，原论文中还包含了<strong>辅方向</strong>，辅方向定义为：若在梯度直方图中存在一个相当于主峰值80%能量的峰值，则认为是关键点的辅方向。辅方向的设计可以增强匹配的鲁棒性，Lowe指出，大概有15%的关键点具有辅方向，而恰恰是这15%的关键点对稳定匹配起到关键作用。</p><h3>6 计算SIFT特征描述子</h3><p>此步骤与步骤5基本一样，也是计算每个关键点周围的梯度方向的直方图分布。不同之处在于，此时的邻居为一个圆，并且坐标体系被扭曲以匹配相关梯度方向。</p><p>具体思路是：对关键点周围像素区域分块，计算块内梯度直方图，生成具有独特性的向量，这个向量是该区域图像信息的一种抽象表述。 <br> 如下图，对于2x<em>2块，每块的所有像素点的梯度做高斯加权，每块最终取8个方向，即可以生成2x</em>2x<em>8维度的向量，以这2x</em>2x8维向量作为中心关键点的数学描述</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*sTtw4z7yF6jsDtJ7W_uHtQ.jpeg" /></figure><p>但是实际上，在原论文中证明，对每个关键点周围采用4×4块(每个块内依然是8个方向)的邻域描述子效果最佳</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*5vfXR0jkQv69Ymqrn2Q5Yg.jpeg" /></figure><p>所以，<strong>此时我们计算的不是一个梯度方向直方图，而是16个</strong>。每个梯度直方图对应的是新坐标系统的中心点附近的点以及圆形周围邻居梯度的分量。</p><p>下图是某个极值点用于生成的描述子的邻居以及坐标系统，即直方图（被归一化并以4×4×8=128个整型数字）。仔细看下图，会发现有16个直方图(16个块)，每个直方图有8个bins(代表每个块的8个主方向)。</p><p><a href="https://blog.csdn.net/dcrmg/article/details/52577555">CSDN SIFT特征</a> <br> <a href="https://blog.csdn.net/abcjennifer/article/details/7639681">Rachel-Zhang SIFT</a> <br> <a href="https://stackoverflow.com/questions/31206443/numpy-second-derivative-of-a-ndimensional-array">stackoverflow 计算hessian矩阵</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5921fa471efb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>