<?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 Big N on Medium]]></title>
        <description><![CDATA[Stories by Big N on Medium]]></description>
        <link>https://medium.com/@Nine9DevTW?source=rss-442a4874a03b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5JBcFrX-HdYSEfailtVwJQ.jpeg</url>
            <title>Stories by Big N on Medium</title>
            <link>https://medium.com/@Nine9DevTW?source=rss-442a4874a03b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 16:25:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Nine9DevTW/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[SpeakingAI — ios app support]]></title>
            <link>https://medium.com/@Nine9DevTW/speakingai-ios-app-support-f849647227b7?source=rss-442a4874a03b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f849647227b7</guid>
            <dc:creator><![CDATA[Big N]]></dc:creator>
            <pubDate>Sun, 19 Mar 2023 23:18:36 GMT</pubDate>
            <atom:updated>2023-03-19T23:18:36.279Z</atom:updated>
            <content:encoded><![CDATA[<h3>SpeakingAI — ios app support</h3><p>目前功能:</p><ol><li>chatGPT串接</li><li>使用語音辨識</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wc9oK_6FUgqWJQOChnBczg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*pdLXAn0FFXgtKlfVdjruwg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f849647227b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraphQL in playground]]></title>
            <link>https://medium.com/nine9devtw/graphql-in-playground-efe6bc49b630?source=rss-442a4874a03b------2</link>
            <guid isPermaLink="false">https://medium.com/p/efe6bc49b630</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[playground]]></category>
            <category><![CDATA[notes]]></category>
            <dc:creator><![CDATA[Big N]]></dc:creator>
            <pubDate>Thu, 08 Jul 2021 08:58:51 GMT</pubDate>
            <atom:updated>2021-07-08T16:29:47.026Z</atom:updated>
            <content:encoded><![CDATA[<h4>記錄一下怎麼操作playground，以及語法格式</h4><p>只記錄client怎麼撈資料，所以想找server端怎麼寫的朋友可以速速離去XD。</p><h4>大概記錄</h4><p>1 query / mutation 的格式</p><p>2 如果要輸入input的格式</p><p>3如果output的類型是interface，我要怎麼接</p><h4>測試用平臺</h4><p>playGround：架的人比較麻煩，但是使用者就無痛使用囉，通常就是一段網址，也不用額外再安裝任何套件了，例如下網址</p><p><a href="https://7sgx4.sse.codesandbox.io/">GraphQL Playground</a></p><p>(來源自：<a href="https://blog.logrocket.com/complete-guide-to-graphql-playground/">https://blog.logrocket.com/complete-guide-to-graphql-playground/</a>)</p><p>postman：一樣也可以用，截圖來自官方，可點圖示下方網址進postman官方文件說明</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D_yHB1DI_vgmWsGPVRpDfg.png" /><figcaption><a href="https://learning.postman.com/docs/sending-requests/supported-api-frameworks/graphql/">https://learning.postman.com/docs/sending-requests/supported-api-frameworks/graphql/</a></figcaption></figure><h4>GraphQL格式(In playground)</h4><p>大概記錄一下使用playground，graphQL格式如何輸入，避免失憶括號怎麼括 XD</p><h4>1 query / mutation 格式</h4><blockquote>基本都一樣</blockquote><pre>query {<br>    SOME_SCRIPT<br>}</pre><pre>mutation {<br>    SOME_SCRIPT<br>}</pre><h4>2 如果要輸入input的格式</h4><blockquote>input怎麼輸入 / 怎麼知道我要輸入什麼</blockquote><p>附上圖例，點選畫面右方的DOC，依數字順序可看到我應該要輸入什麼格式。</p><p>例：我想拿到user的資訊(2)，我發現要拿user資訊，要先打input，而且格式還是UserInput(3)，這時候我可以把往下滑到底(4)，看到我的UserInput(5)實際其實就是要打一個userName，而且格式是String(6)。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*NudOHBykYsPVVT6EnuhM0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*FmtiJA1PTHwLW0wvVLxv-g.png" /></figure><p>好，學會看input是什麼了，所以我要怎麼打給server？</p><pre>query {</pre><pre>user(input: { userName: &quot;USER_NAME&quot; }) {<br>    id<br>    uuid<br>  }</pre><pre>}</pre><p>可以看到如果有input的話，格式就變成</p><pre>query {</pre><pre>  SOME_API_NAME (para: { key1: value1 }) {<br>    some value you need <br>  }</pre><pre>}</pre><p>我要打的api是user，第一個參數是input(見圖，數字3 or 5)，這個input要吃的類型是UserInput，參數key是userName，並且要給一個字串(見圖6)</p><p>那麼some value you need，就是打這支api，我想要拿到的內容，並沒有要全拿，可以自己選要拿哪個，在圖4，滑鼠滾動的過程中，中間那一大截都是這支user API可以拿到的值</p><h4>3 如果output的類型是interface，我要怎麼接</h4><blockquote>格式是interface，第一次遇到「…」，他是格式內容沒錯哦!!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*vM9axtFNVZYCmQmvhCvrVw.png" /></figure><p>可以看到我的node拿到的是個Interface (1)，這時候格式就變成</p><pre>query {<br>  <br>  user (input: {userName: &quot;USER_NAME&quot;}) {<br>    <br>     edges {<br>        node {<br>          id<br>          unread<br>          ... on ArticleNotice {<br>            type<br>          }<br>          ... on UserNotice {<br>            id<br>          }<br>        }<br>      }<br>  }<br>  <br>  <br>}</pre><p>也就是要拿interface的話，格式寫法是</p><pre>SOME_API_NAME {<br>  some value you need<br>  ... on SOME_IMPLEMENTATIONS_NAME_1 {<br>    some value you need<br>  }<br>  ... on SOME_IMPLEMENTATIONS_NAME_2 {<br>    some value you need<br>  }<br>}</pre><h4>要注意</h4><p>「…」是格式之一</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fbutton.like.co%2Fin%2Fembed%2Fnigel4nine9%2Fbutton&amp;display_name=LikeCoin&amp;url=https%3A%2F%2Fbutton.like.co%2Fnigel4nine9&amp;image=https%3A%2F%2Fstatic.like.co%2Flikecoin_de-portrait.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=like" width="485" height="212" frameborder="0" scrolling="no"><a href="https://medium.com/media/a15b08e6c759b00704f1756bc3e31328/href">https://medium.com/media/a15b08e6c759b00704f1756bc3e31328/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efe6bc49b630" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nine9devtw/graphql-in-playground-efe6bc49b630">GraphQL in playground</a> was originally published in <a href="https://medium.com/nine9devtw">碼農勤耕田</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[如何把手機當作ipCam]]></title>
            <link>https://medium.com/nine9devtw/%E5%A6%82%E4%BD%95%E6%8A%8A%E6%89%8B%E6%A9%9F%E7%95%B6%E4%BD%9Cipcam-234586a220d4?source=rss-442a4874a03b------2</link>
            <guid isPermaLink="false">https://medium.com/p/234586a220d4</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[ip-camera]]></category>
            <dc:creator><![CDATA[Big N]]></dc:creator>
            <pubDate>Wed, 23 Jun 2021 16:21:48 GMT</pubDate>
            <atom:updated>2021-06-26T12:45:16.311Z</atom:updated>
            <content:encoded><![CDATA[<h4>mobile as IP CAM + Python + RaspberryPI</h4><h4>使用情境：</h4><p>如果想要一臺ip-cam，可是只是玩票或是實驗性質，不想額外花錢怎麼辦？不如試試看把手機當成一臺ip-cam吧。</p><p>…啊所以怎麼會有這種情境啦XDD</p><p>情況大概就是有了一塊樹莓派或是Jetson Nano，想來做一個簡單的邊緣運算當作小玩具，看看效果如何，結果發現，啊可是我沒有cam可以接RRRRRRRRRR，啊可是我也不想多花錢RRRRRRR</p><p>這個時候!!!直接把手機掏出來，搖身一變就是IP-CAM了哦哦哦哦，當然缺點就是少了一支手機能用，很不方便（XD？）</p><h3>簡易步驟</h3><p>Step1. 手機下載 「IP攝像頭 Lite」，並取得手機的ip位址</p><p>Step2. 確認你的手機與你的樹莓派(或是任何板子)，連接相同的WIFI，接下來就直接使用openCV，並且格式為</p><pre>http://YOUR_ACCOUNT:YOUR_PASSWORD@YOUR_IP_CAM_ADDRESS:YOUR_PORT/video</pre><p>app預設的帳密都是admin，port預設是8081，所以最後ip大概會是</p><pre>http://admin:admin@YOUR_IP_CAM_ADDRESS:8081/video</pre><p>然後就，結束了。</p><h3>詳細步驟</h3><h4>Step1. 下載app</h4><p>手機先下載app，「IP攝像頭 Lite」，app iOS/android都有，並且是免費的，可以先載來試用一下， 免費版有廣告，但是完全不會影響使用，如果覺得不錯可以支持作者一下!</p><p>ios載點-&gt; <a href="https://apps.apple.com/tw/app/ip%E6%94%9D%E5%83%8F%E9%A0%AD-lite/id1013455241">https://apps.apple.com/tw/app/ip%E6%94%9D%E5%83%8F%E9%A0%AD-lite/id1013455241</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*ikqtRJLKl_TK5pz9mLk1ZA.png" /></figure><p>android就…自己搜「IP攝像頭 Lite」了XD</p><p>APP的使用上算是簡潔，基本上就是每個按鈕都按看看就可以上手（XDD）</p><p>(1) 首先點開app後，點選最下方的「打開IP攝像頭服務器」</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*O0-HA24svGJnVjAXeVHNZg.png" /></figure><p>(2) 點選右下角的「連接？」</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*BBOJ7GyAkub9nJEJAJrdLg.png" /></figure><p>(3) 因為我是玩票性質，我並沒有去研究有什麼差別，如果只是要簡單上手，可以直接照抄MJPGEG那一段網址</p><pre>http://COPY_FROM_APP:8081/video</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*nNwwB9vqJwtCM5iNYLabIQ.png" /></figure><p>這個時候，如果只是缺一個ip cam的話，其實已經完成了，直接把那一段網址貼到你的瀏覽器，我剛好少打了/video，所以會出現一般可以調整的狀態列，如果補上/video，就是單純的影像straming了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*QHg12Nh5U3P8ixUXCvC0cg.png" /></figure><p>接下來會出現要你打帳號，密碼，這個app預設都是admin。</p><p>如果你想改掉的話，可以在app一進來的畫面，右上角選單，點選「設置」，在裡頭去改動你的帳密</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*FtCOMHQ7V4ShOeMQTVTRUg.png" /></figure><pre>上下兩行，預設都是<br>admin<br>admin</pre><p>完成後，你的瀏覽器應該就是長這樣了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZFQ-P2y24e7tE9hLxLiXyg.png" /></figure><p>到這裡，Step1已經結束。</p><p>如果目標只是要把手機當IP-CAM，到這邊已經OKOK~</p><h4>Step2</h4><p>如果你是想拿來給其它板子(樹莓派之類的)，假定你使用的是python，那程式碼如下（如果用c++也差不多，反正重點就是那條網址而已)</p><pre>import cv2<br></pre><pre># 就是這條網址而已，後面都是一般的openCV的frame顯示而已<br>cap = cv2.VideoCapture(&quot;http://COPY_FROM_APP:8081/video&quot;)<br><br>while cap.isOpened():<br>    ret, frame = cap.read()</pre><pre>    if not ret:<br>        print(&quot;Can&#39;t receive frame (stream end?). Exiting ...&quot;)<br>        break</pre><pre>    cv2.imshow(&#39;frame&#39;, frame)<br></pre><p>完成!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fbutton.like.co%2Fin%2Fembed%2Fnigel4nine9%2Fbutton&amp;display_name=LikeCoin&amp;url=https%3A%2F%2Fbutton.like.co%2Fnigel4nine9&amp;image=https%3A%2F%2Fstatic.like.co%2Flikecoin_de-portrait.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=like" width="485" height="212" frameborder="0" scrolling="no"><a href="https://medium.com/media/a15b08e6c759b00704f1756bc3e31328/href">https://medium.com/media/a15b08e6c759b00704f1756bc3e31328/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=234586a220d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nine9devtw/%E5%A6%82%E4%BD%95%E6%8A%8A%E6%89%8B%E6%A9%9F%E7%95%B6%E4%BD%9Cipcam-234586a220d4">如何把手機當作ipCam</a> was originally published in <a href="https://medium.com/nine9devtw">碼農勤耕田</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS 使用coreML — yolo model]]></title>
            <link>https://medium.com/nine9devtw/ios-%E4%BD%BF%E7%94%A8coreml-yolo-model-ba250f595cf1?source=rss-442a4874a03b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba250f595cf1</guid>
            <category><![CDATA[keras]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coreml]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[yolo]]></category>
            <dc:creator><![CDATA[Big N]]></dc:creator>
            <pubDate>Thu, 02 Apr 2020 12:23:50 GMT</pubDate>
            <atom:updated>2021-01-24T16:14:57.734Z</atom:updated>
            <content:encoded><![CDATA[<h3>iOS 使用coreML — yolo model</h3><h4>convert pretrained-yoloModel.h5 to coreML</h4><p>最近有人問怎麼在iOS上使用訓練好的模型，雖然網路上已經有sampleCode了，不過可能coreMlTools更新過的關係，有點小小的不同，所以記錄一下踩坑的過程QQ。</p><p>大致上分為三步：</p><h4>step1: 訓練模型(yolov3, keras)，取得h5</h4><p>這個我就不記錄怎麼train了，google滿多詳細的教學，可以照著做</p><p>這裡使用的是keras，如果是用pytorch或其它工具的話，本篇不適用。</p><h4>step2: convert h5 file -&gt; coreML</h4><p>這邊的重點是用apple的coremltools去轉，網路上的sampleCode轉出來，跟實際結果有小小的不同，所以這邊是小小的重點。</p><p>還有一個就是trained好的模型，有些小地方還要改QQ，不能直接貼Code QQ，否則會遇到yolo_head is not defined</p><p>那為什麼要把h5轉成coreMl呢？因為iOS吃coreML，不會吃h5，而蘋果也寫了一個工具，讓我們可以把h5轉成coreML。</p><h4>step3: XCode — load coreML</h4><p>這裡就不多加介紹，直接放別人的網誌了XD</p><h4>step1: 訓練模型(yolov3, keras)，取得h5</h4><p>基本上模型不會由手機端訓練，一般應該是用電腦先跑個一段時間，訓練出來的模型是一個h5的檔案。</p><p>如果只是想要練習怎麼把h5轉coreML的話，可以看下面這篇，參照quickStart取得h5檔案</p><p><a href="https://github.com/qqwweee/keras-yolo3">qqwweee/keras-yolo3</a></p><p>基本上就是整包clone下來後，依序複製貼上下面兩程程式碼就可以取得h5了，轉出來的h5就在model_data這個資料夾裡頭。</p><pre>wget <a href="https://pjreddie.com/media/files/yolov3.weights">https://pjreddie.com/media/files/yolov3.weights</a><br>python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5</pre><p>這樣就有已經trained好的h5了</p><p>如果要自己訓練資料的話，再google看看，滿多詳細的教學可以依序完成。</p><h4>step2: convert h5 file -&gt; coreML</h4><p>本文重點記錄，大概再分成2小部份：</p><blockquote>1: how to convert h5-&gt;coreML</blockquote><p><a href="https://github.com/apple/coremltools">GitHub - apple/coremltools: Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.</a></p><p>用的是蘋果官方的小工具，可以看到github下方有寫如何使用，基本上也是直接照著做，用virtualenv去建置環境，我一開始偷懶，不管什麼虛擬環境，直接inistall，結果各種錯誤，（像是 <a href="https://stackoverflow.com/questions/54166644/keras-mlmodel-coreml-object-has-no-attribute-convert">coreml object has no attribute ‘convert’</a> ），踩一堆奇怪的坑，所以建議直接依照蘋果的作法，打開終端機，依序貼指令上去。</p><pre># 安裝virtualenv<br>pip install virtualenv</pre><pre># 會建一個&quot;mlvirtualenv&quot;名稱的資料夾<br>mkdir mlvirtualenv</pre><pre># 路徑進入至資料夾&quot;mlvirtualenv&quot;<br>cd mlvirtualenv</pre><pre># 建一個虛擬環境，名稱叫作&quot;pythonenv&quot;<br>virtualenv pythonenv</pre><pre># 啟動叫作&quot;pythonenv&quot;的虛擬環境<br>source pythonenv/bin/activate</pre><pre><br># 這時候你的終端機前方應該就變成(pythonenv)了<br># 再貼上下指令去安裝coreMlTools<br>pip install -U coremltools</pre><p>好了，這樣coreMlTools就裝好了</p><p>之後因為是虛擬環境，所以要再裝一次tensorflow, keras</p><pre>pip install keras==2.2.4<br>pip install tensorflow==1.14.0</pre><blockquote>2: how to implement h5 -&gt; coreML by coremltools</blockquote><p>這裡分兩段記錄，一個是已經上述qqwwee已經訓練好的model；另一個則是自己訓練的要怎麼做。</p><p>字面上看起來可能有點奇怪，明明都是h5，為什麼要分成「qqwwee的」跟「自己訓練的」，不都一樣嗎？</p><p>呃，其實我也不知道…..囧&gt;||||||</p><p>如果是自己train的，轉coreML的時候會遇到一些怪事，要額外再多寫一點code</p><p>這是qqwwee的h5，用以下python程式碼，看是要貼到記錄本，存成py檔，還是直接在終端機輸入python，再依序貼上程式碼。</p><pre># import 蘋果的小工具<br>import coremltools</pre><pre># 利用coremltools，把同層資料中，名稱為為&quot;yolo.h5&quot;的檔案轉型為mlModel<br># 可以看到這裡用的是keras，如果你是用別的架構訓練的話，這裡不會work<br>model = coremltools.converters.keras.convert(&quot;./yolo.h5&quot;,<br>    input_names=&#39;image&#39;,<br>    image_input_names=&#39;image&#39;,<br>    input_name_shape_dict={&#39;image&#39;: <br>                             [None, 416, 416, 3]<br>                          },<br>    image_scale=1/255.)</pre><pre># 把剛剛的model存到同層資料夾，名稱命名為&quot;yolo.mlmodel&quot;<br>model.save(&quot;./yolo.mlmodel&quot;)</pre><p>如果是自己trained的模型，依照上述的作法，可能會噴出’yolo_head’ is not defined這個錯誤，所以要稍作修改，我猜應該是因為qqwwee裡頭train完是寫save_weight，而不是save_model吧（？）</p><p><a href="https://github.com/qqwweee/keras-yolo3/issues/48">NameError: name &#39;yolo_head&#39; is not defined · Issue #48 · qqwweee/keras-yolo3</a></p><pre># 這裡的yolo3，是qqwwee內的yolo，所以要特別注意這時候你的路徑在哪裡<br>from yolo3.model import yolo_eval, yolo_body, tiny_yolo_body<br>from keras.layers import Input<br>import coremltools</pre><pre># 最後一個參數YOUR_CLASS_NUM，是你辨識幾類，如果有80類，就是打80<br>model = yolo_body(Input(shape=(None, None, 3)), 3, YOUR_CLASS_NUM)</pre><pre># 去讀你同層資料夾中，名為&quot;customData.h5&quot;的檔案<br>model.load_weights(&quot;./customData.h5&quot;)</pre><pre># 這裡基本上就同剛剛的寫法了, 只是變成讀model，而不是讀路徑<br>mlModel = coremltools.converters.keras.convert(model,<br>    input_names=&#39;image&#39;,<br>    image_input_names=&#39;image&#39;,<br>    input_name_shape_dict={&#39;image&#39;: [None, 416, 416, 3]},<br>    image_scale=1/255.)</pre><pre># 把剛剛的mlModel存到同層資料夾，名稱命名為&quot;customData.mlmodel&quot;<br>mlModel.save(&quot;./customData.mlmodel&quot;)</pre><p>好了，走到這裡就完成h5 -&gt; mlModel了</p><h4>step3: XCode — load coreML</h4><p>這時候把模型直接拉到Xcode裡頭，應該就會發現「蛤蛤蛤？？？我的output的size根本不一樣啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊（大崩潰）」</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*n3SxdOMCPXXLtLCcWipLEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*_mQ6VNonu8Eisa4-y5ATDg.png" /></figure><p>左圖輸出有3維(255x13x13)，是網上sampleCode的model；</p><p>而右圖輸出有1維(255)，則是用上述方法轉出來的model。</p><p>所以用網上sampleCode直接執行就會GG</p><p><a href="https://github.com/hollance/YOLO-CoreML-MPSNNGraph/issues/63">Shape of the converted model is wrong · Issue #63 · hollance/YOLO-CoreML-MPSNNGraph</a></p><p>還好，原sampleCode的作者，也有針對這個issue回答，只要在Yolo.swift中</p><pre>原本的<br>let channelStride = features.strides[0].intValue<br>let yStride = features.strides[1].intValue<br>let xStride = features.strides[2].intValue</pre><pre>改為<br>let channelStride = features.strides[2].intValue<br>let yStride = features.strides[3].intValue<br>let xStride = features.strides[4].intValue</pre><p>也就是改index而已，因為原本的模型是拿到3維，但我們現在會拿到5維，前兩維都是1，所以往後取資料而已。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*Hfc26pcabF4vmwDt0rUHVA.png" /><figcaption>原sampleCode model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*qYyIVwjdEYsZ3F3Hwv3J-Q.png" /><figcaption>我們現在轉出來的model</figcaption></figure><p>走到這裡，如果一開始用的是qqwwee的模型，現在就已經結束了，只要替換model就可以順利執行了。</p><p>那如果是自己trained的模型，還要改什麼呢？</p><p>1- 模型的分類數量</p><pre>在yolo.swift中<br><strong>let</strong> numClasses = 80 // 這裡改成你自己分幾類</pre><p>2-對應的label</p><pre>在Helpers.swift中<br><strong>let</strong> labels = [&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, ......]<br>labels的元素改為你要顯示的名稱</pre><p>至於他整篇sampleCode是怎麼做的呢</p><p>可以參考原文</p><p><a href="http://machinethink.net/blog/yolo-coreml-versus-mps-graph/">YOLO: Core ML versus MPSNNGraph</a></p><p>或是這位網友有介紹原本的sampleCode大概是怎樣的作法</p><p><a href="https://medium.com/cubo-ai/yolo-with-coreml-819799789c11">YOLO with CoreML</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fbutton.like.co%2Fin%2Fembed%2Fnigel4nine9%2Fbutton&amp;display_name=LikeCoin&amp;url=https%3A%2F%2Fbutton.like.co%2Fnigel4nine9&amp;image=https%3A%2F%2Fstatic.like.co%2Flikecoin_de-portrait.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=like" width="485" height="212" frameborder="0" scrolling="no"><a href="https://medium.com/media/a15b08e6c759b00704f1756bc3e31328/href">https://medium.com/media/a15b08e6c759b00704f1756bc3e31328/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba250f595cf1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nine9devtw/ios-%E4%BD%BF%E7%94%A8coreml-yolo-model-ba250f595cf1">iOS 使用coreML — yolo model</a> was originally published in <a href="https://medium.com/nine9devtw">碼農勤耕田</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LeetCode-搶救演算法大作戰#74]]></title>
            <link>https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-74-26017ce9870f?source=rss-442a4874a03b------2</link>
            <guid isPermaLink="false">https://medium.com/p/26017ce9870f</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Big N]]></dc:creator>
            <pubDate>Tue, 03 Mar 2020 07:02:38 GMT</pubDate>
            <atom:updated>2020-03-03T07:02:38.015Z</atom:updated>
            <content:encoded><![CDATA[<h4>328. Odd Even Linked List [Medium] [Python]</h4><p><strong>題目傳送門</strong></p><p><a href="https://leetcode.com/problems/odd-even-linked-list/">Odd Even Linked List - LeetCode</a></p><p><strong>題意</strong></p><p>給你一個ListNode，把輸入的listNode分成奇、偶Node，再重組，第一個值為奇數Node，第二個值為偶數Node</p><pre>Input: 1-&gt;2-&gt;3-&gt;4-&gt;5-&gt;NULL <br>Output: 1-&gt;3-&gt;5-&gt;2-&gt;4-&gt;NULL</pre><p><strong>想法</strong></p><p>奇數先接起來，偶數接起來，最後奇數再接偶數</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0ce62819e34f37eb3993bc7a0742702/href">https://medium.com/media/b0ce62819e34f37eb3993bc7a0742702/href</a></iframe><p><strong>開獎l</strong></p><p><strong>Runtime: 44 ms, faster than 52.21%</strong></p><p><strong>Memory Usage: 15.5 MB, less than 8.33%</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26017ce9870f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-74-26017ce9870f">LeetCode-搶救演算法大作戰#74</a> was originally published in <a href="https://medium.com/nine9devtw">碼農勤耕田</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LeetCode-搶救演算法大作戰#73]]></title>
            <link>https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-73-350a6df35f5?source=rss-442a4874a03b------2</link>
            <guid isPermaLink="false">https://medium.com/p/350a6df35f5</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[leetcode]]></category>
            <dc:creator><![CDATA[Big N]]></dc:creator>
            <pubDate>Mon, 02 Mar 2020 08:24:19 GMT</pubDate>
            <atom:updated>2020-03-03T07:17:08.460Z</atom:updated>
            <content:encoded><![CDATA[<h4>1249. Minimum Remove to Make Valid Parentheses [Medium][Py]</h4><p><strong>題目傳送門</strong></p><p><a href="https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/">Minimum Remove to Make Valid Parentheses - LeetCode</a></p><p><strong>題意</strong></p><p>給你一個字串，左、右刮號算一個有效刮號</p><p>請你移除無效刮號</p><p><strong>想法</strong></p><p>先算有效的刮號有幾個，然後再來決定這些刮號可不可以留</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c0661c5e6912f9a4cc1121a1a8e4eaa/href">https://medium.com/media/0c0661c5e6912f9a4cc1121a1a8e4eaa/href</a></iframe><p><strong>開獎</strong></p><p><strong>Runtime: 132 ms, faster than 60.85%</strong></p><p><strong>Memory Usage: 14.3 MB, less than 100.00%</strong></p><p>要花O(2n)，但應該可以左、右兩邊走，這樣只要O(n)，偷懶，下次補XD</p><p>啊，試了一下，這樣想法會有問題</p><pre>&quot;())()(((&quot;</pre><p>這樣的測資，依照我的想法，從最左、最右開始走的話，輸出應該是&quot;()&quot;，但其實正解是&quot;()()&quot;</p><p>QQ…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=350a6df35f5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-73-350a6df35f5">LeetCode-搶救演算法大作戰#73</a> was originally published in <a href="https://medium.com/nine9devtw">碼農勤耕田</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LeetCode-搶救演算法大作戰#72]]></title>
            <link>https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-72-afc3ca2df39d?source=rss-442a4874a03b------2</link>
            <guid isPermaLink="false">https://medium.com/p/afc3ca2df39d</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Big N]]></dc:creator>
            <pubDate>Fri, 21 Feb 2020 04:11:20 GMT</pubDate>
            <atom:updated>2020-02-21T04:11:20.284Z</atom:updated>
            <content:encoded><![CDATA[<h4>21. Merge Two Sorted Lists[Easy] [Python]</h4><p><strong>題目傳送門</strong></p><p><a href="https://leetcode.com/problems/merge-two-sorted-lists/">LeetCode - The World&#39;s Leading Online Programming Learning Platform</a></p><p><strong>題意</strong></p><p>給你兩個已經由小至大排序好的listNode，請你將兩個listNode合併起來，合併完成後的node也要有由小到大的排序特性</p><p><strong>想法</strong></p><p>一開始看錯，以為他是要交替穿叉3口3…&lt;&lt;只看例子就寫的人</p><p>呃，好</p><p>既然只是要考合併</p><p>那就是來個迴圈，比較兩個node誰比較小，小的就加進新的node中。</p><p>那如果其中一個node已經沒辦法再找到下個點了，就可以直接回傳新node</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3770b7f57bf4853835af232fc0aa5b4/href">https://medium.com/media/b3770b7f57bf4853835af232fc0aa5b4/href</a></iframe><p><strong>開獎</strong></p><p><strong>Runtime: 36 ms, faster than 62.45%</strong></p><p><strong>Memory Usage: 12.7 MB, less than 100.00%</strong></p><p>啊，好慢囧….偷看別人的解答</p><p>好像也差不多是這個想法…</p><p>不過一個無聊（XD？）的發現，大家的第一個判斷是 ≤ ，而不是 &lt;，嗯…考慮到leetCode的測資的確不多，的確會因為多一個判斷就下去了，好!亂猜，多加一個等號l</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92189c825c8b77838755c7b0033fb005/href">https://medium.com/media/92189c825c8b77838755c7b0033fb005/href</a></iframe><p><strong>Runtime: 32 ms, faster than 85.29%</strong></p><p><strong>Memory Usage: 12.7 MB, less than 100.00%</strong></p><p>….好哦…囧&gt;|||</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afc3ca2df39d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-72-afc3ca2df39d">LeetCode-搶救演算法大作戰#72</a> was originally published in <a href="https://medium.com/nine9devtw">碼農勤耕田</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LeetCode-搶救演算法大作戰#71]]></title>
            <link>https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-71-b99eb7576968?source=rss-442a4874a03b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b99eb7576968</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[leetcode]]></category>
            <dc:creator><![CDATA[Big N]]></dc:creator>
            <pubDate>Thu, 20 Feb 2020 07:39:29 GMT</pubDate>
            <atom:updated>2020-02-20T07:40:58.627Z</atom:updated>
            <content:encoded><![CDATA[<h4>1029. Two City Scheduling [Easy] [Python]</h4><p><strong>題目傳送門</strong></p><p><a href="https://leetcode.com/problems/two-city-scheduling/">Two City Scheduling - LeetCode</a></p><pre>Tag: <strong>Greedy</strong></pre><p><strong>題意</strong></p><p>給你一個2維數字陣列<strong>costs</strong></p><p><strong>costs</strong>[i][<strong>0</strong>]表示i員工去<strong>A</strong>城市要花的時間</p><p><strong>costs</strong>[i][<strong>1</strong>]表示i員工去<strong>B</strong>城市要花的時間</p><p>全部i個員工，限制去A, B兩城市的員工數要相同。(一半去A, 另一半去B)</p><p>請問要花的最小時間數是多少</p><p><strong>想法</strong></p><p>嗯，這題不是程式不會寫，是連自己手算都不會算QQ</p><p>看tag是greedy，想了一些時間，沒想出為什麼是greey…又不是都選a最小就好了囧</p><p>那我猜是dynamicProgram，想了一些時間，也不覺得是dynamicProgram啊…我又不能保證當下最佳解就會是未來最佳解囧，因為去A, B兩個city的人數要一樣啊囧</p><p><strong>偷看</strong></p><p>主要是偷看別人的想法，這題是卡在題目雖然有看懂，但完全不會解QQ</p><p>大概想法是，去算A, B兩城市的差值，這樣就知道去A比較省時，還是B比較省時。</p><p>如果差值為正(B-A &gt; 0)，代表去A比較省時間；</p><p>如果差值為負(B-A &lt;0 )，代表去B比較省時間。</p><p>接下來我再算「全部去B的時間」，再去扣掉A比較省的差值就好了</p><pre><strong>Input</strong>: [[10,20],[30,200],[400,50],[30,20]] <br><strong>Output</strong>: 110</pre><p>化為表格後的結果，C欄代表B扣A的時間</p><p>數字為正，代表去A比較省時，且省了__的時間</p><p>以C[2]為例，代表去A比較好，A比B省了10個時間</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*85l6SP97bMgL9Mjeh0Ri2w.png" /></figure><p>D[6]代表的是如果員工全都去B，所需要的時間</p><p>題目限制A, B兩者的人數需各半，所以有一半的人要改去A</p><p>全部有4個人，兩個人需要改去A公司，由C欄可知，C[2]跟C[3]表明去A是比較省的，分別省10與170個時間。</p><p>所以再290 - 10 - 170即為答案110。</p><p>好了哦，學會手算了3口3，接下來就是寫程式了。</p><p>大意就是sum[B]、算b-a的差值、排序差值，取前半段相減就是了。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8996fa0ce11698a379cae4226a676293/href">https://medium.com/media/8996fa0ce11698a379cae4226a676293/href</a></iframe><p>第9行，sort結果是由小到大。</p><p>所以第11行是從中間開始走完，而不是從頭走一半。</p><p>嗯嗯，這樣的確是greedy，取差值最大。</p><p><strong>開獎</strong></p><p><strong>Runtime: 36 ms, faster than 82.52%</strong></p><p><strong>Memory Usage: 12.9 MB, less than 100.00%</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b99eb7576968" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-71-b99eb7576968">LeetCode-搶救演算法大作戰#71</a> was originally published in <a href="https://medium.com/nine9devtw">碼農勤耕田</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LeetCode-搶救演算法大作戰#70]]></title>
            <link>https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-70-79c9317a5644?source=rss-442a4874a03b------2</link>
            <guid isPermaLink="false">https://medium.com/p/79c9317a5644</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Big N]]></dc:creator>
            <pubDate>Wed, 19 Feb 2020 09:46:14 GMT</pubDate>
            <atom:updated>2020-02-19T09:46:14.971Z</atom:updated>
            <content:encoded><![CDATA[<h4>1189. Maximum Number of Balloons [Easy] [Python]</h4><p><strong>題目傳送門</strong></p><p><a href="https://leetcode.com/problems/maximum-number-of-balloons/">Maximum Number of Balloons - LeetCode</a></p><p><strong>題意</strong></p><p>給你一個字串，問你這個字串內的文字，可以組成幾個「balloon」</p><p><strong>想法</strong></p><p>想法就是…去算個數啊</p><p>l跟o比較特別 要再除以2</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b2bf14064feede7bff14927d661948c/href">https://medium.com/media/5b2bf14064feede7bff14927d661948c/href</a></iframe><p><strong>開獎</strong></p><p><strong>Runtime: 32 ms, faster than 58.78%</strong></p><p><strong>Memory Usage: 12.8 MB, less than 100.00%</strong></p><p>囧…意外的有點慢，不管怎樣都要走一個迴圈啊….</p><p>到底能省哪裡哦</p><p><strong>偷看</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1cd4ccf6d12e030f4c4f321396100ba/href">https://medium.com/media/c1cd4ccf6d12e030f4c4f321396100ba/href</a></iframe><p>這個我覺得水滿神奇的，不知道py的count怎麼寫的，一個count應該就是要一個O(n)啊3囗3…</p><p>Runtime: 28 ms, faster than 82.36%</p><p>Memory Usage: 12.6 MB, less than 100.00%</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79c9317a5644" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-70-79c9317a5644">LeetCode-搶救演算法大作戰#70</a> was originally published in <a href="https://medium.com/nine9devtw">碼農勤耕田</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LeetCode-搶救演算法大作戰#69]]></title>
            <link>https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-69-e4fdb5289a69?source=rss-442a4874a03b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4fdb5289a69</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Big N]]></dc:creator>
            <pubDate>Wed, 19 Feb 2020 09:36:51 GMT</pubDate>
            <atom:updated>2020-02-19T09:36:51.280Z</atom:updated>
            <content:encoded><![CDATA[<h4>242. Valid Anagram [Easy] [Python]</h4><p><strong>題目傳送門</strong></p><p><a href="https://leetcode.com/problems/valid-anagram/">LeetCode - The World&#39;s Leading Online Programming Learning Platform</a></p><p><strong>題意</strong></p><p>給你兩個字串，問你這兩個字串是不是anagram</p><p><strong>想法</strong></p><p>這題覺得題目不太好，因為沒給解釋囧</p><p>不知道「anagram」就GG了</p><p>anagram就是指內容都一樣，只是順序不同而已</p><p>好了，那既然知道題意是要找兩個字串的內容是不是相同</p><p>那就…一個迴圈，然後算裡頭的字數有沒有相同就好了啊</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09793c95a777ee095524264096760690/href">https://medium.com/media/09793c95a777ee095524264096760690/href</a></iframe><p><strong>開獎</strong></p><p>Runtime: 3632 ms, faster than 5.34%</p><p>Memory Usage: 13 MB, less than 100.00%</p><p>哦哦哦哦哦，世界慢XDDDD</p><p>也是，如果字長到爆炸，類似長這樣</p><pre>&quot;aaaaabaaaaaa...(下略999個a)&quot;<br>&quot;baaaaaaaaaaa...(下略999個a)&quot;</pre><p>兩個字串就是一個b跟一堆的a組成，結果我還要全部走完3口3…</p><p>所以想到用set，先去除重複，再走一個迴圈</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11322e59f89c560316aa321ed7efb3d9/href">https://medium.com/media/11322e59f89c560316aa321ed7efb3d9/href</a></iframe><p>Runtime: 36 ms, faster than 92.61%</p><p>Memory Usage: 13.4 MB, less than 43.75</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4fdb5289a69" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nine9devtw/leetcode-%E6%90%B6%E6%95%91%E6%BC%94%E7%AE%97%E6%B3%95%E5%A4%A7%E4%BD%9C%E6%88%B0-69-e4fdb5289a69">LeetCode-搶救演算法大作戰#69</a> was originally published in <a href="https://medium.com/nine9devtw">碼農勤耕田</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>