<?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[HKIT DOG - Medium]]></title>
        <description><![CDATA[We are developer from Hong Kong - Medium]]></description>
        <link>https://medium.com/hong-kong-tech?source=rss----4fa69ea370c1---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>HKIT DOG - Medium</title>
            <link>https://medium.com/hong-kong-tech?source=rss----4fa69ea370c1---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 11:10:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/hong-kong-tech" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[如何在本機 Offiline 免費無限運行 ChatGPT?]]></title>
            <link>https://medium.com/hong-kong-tech/%E5%A6%82%E4%BD%95%E5%9C%A8%E6%9C%AC%E6%A9%9F-offiline-%E5%85%8D%E8%B2%BB%E7%84%A1%E9%99%90%E9%81%8B%E8%A1%8C-chatgpt-e15966b4804f?source=rss----4fa69ea370c1---4</link>
            <guid isPermaLink="false">https://medium.com/p/e15966b4804f</guid>
            <category><![CDATA[open-webui]]></category>
            <category><![CDATA[deepseek-r1]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[gemma-3]]></category>
            <dc:creator><![CDATA[Edmond Y.]]></dc:creator>
            <pubDate>Fri, 11 Apr 2025 08:31:32 GMT</pubDate>
            <atom:updated>2025-04-11T08:31:32.710Z</atom:updated>
            <content:encoded><![CDATA[<h4>使用 Open WebUI 本機運行 Llama3/DeepSeekR1/Gemma3 等 LLM</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2iV8ZjAhVHz4JaOrYigHQ.png" /><figcaption>如何在本機 Offiline 免費無限運行 ChatGPT?</figcaption></figure><p>由於早前出 Trip 時遇上沒網路就沒 ChatGPT 用的困境，雖然有手機網路但酒店網路不穩定也不一定可以穩定連線。所以就再找 Ollama 找出來看看現在可以使用什麼新 Model 可以在本機不用網路的情況下使用 LLM 工作。</p><p>之前也有介紹跟 Stable Diffusion 一起使用 Ollama，作為在本機運行 LLM (Large Language Model) 的工具其實 Ollama 也可以個別運作。同時因為是 Open source 的原故，所以可以實現免費無限量使用！</p><p>今次的會教大家使用更簡單的方法本地安裝 LLM 同時有繁體中文的 WebUI 可以使用，此方法同時支援 Windows / Mac / Linux。</p><h3>首先要安裝 Docker Desktop</h3><p>最簡單又不需要用 Python 的軟件的方法就是用 Docker，安裝 Docker Desktop 是最簡單的 Docker 安裝方法，如果不太會用 Docker 就可以安裝 Docker Desktop。支援 Windows / Mac / Linux。</p><p><a href="https://docs.docker.com/get-started/get-docker">Get Docker</a></p><h3>安裝 Open WebUI</h3><p>安裝 Docker Desktop 後，按 Docker Desktop 右下角 Terminal 打開介面，copy 適用於你電腦的 command</p><p>如果你的電腦支援 Nvidia GPU，就是有在用先進的 Nvidia 顯示卡，就用這個指令：</p><pre>docker run -d -p 3000:8080 --gpus=all -v ollama:/root/.ollama -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:ollama</pre><p>如果你是用 Mac 或者沒有 Nvidia GPU 或者你都不知道，就用這個指令</p><pre>docker run -d -p 3000:8080 -v ollama:/root/.ollama -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:ollama</pre><p>分別在於是否使用 Nvidia GPU 加速，使用了會快一點就是。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CopTL_NVoNzeBS2u.png" /><figcaption>Docker Desktop 輸入指令</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UyoWOdiO3Hpjct6E.png" /><figcaption>open webui in docker</figcaption></figure><p>輸入指令後會自動下載安裝 Open WebUI 及 Ollama，成功後會自動啟動 container。</p><p>此時打開 <a href="http://localhost:3000/?ref=blog.256pages.com">http://localhost:3000</a> 就可以見到你的 Open Webui 畫面。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/0*IaUrQm_ANSvftTa0.png" /><figcaption>按 Get started</figcaption></figure><p>按 Get started 去到建立帳號畫面，這個帳號只會儲存在你本機 Docker 內，不是任何網站或服務的帳號，你也可以在家或公司自設 server，這樣就可以給不同的用家一起使用。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/0*4rDMqZKeJIZDq8Rn.png" /><figcaption>要記住自己的密碼哦</figcaption></figure><p>進入會見到一個很像 ChatGPT 的介面，就是 Open WebUI 了。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eMbX0XRIA-v11lDD.png" /><figcaption>Hello Open WebUI</figcaption></figure><h3>轉成中文介面</h3><p>為習慣中文用家，大家可以先到左下角按一按自己的名字打開 Setting 頁面 General 內見到 Language，改成繁體中文就可以轉成中文介面了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A5th-oZ2z5tT1CQB.png" /><figcaption>中文介面</figcaption></figure><h3>LLM 介紹</h3><p>然後你可以上 <a href="https://ollama.com/search?ref=blog.256pages.com">Ollama</a> 網站選一兩個合適的 LLM，推薦幾個熱門的 Model：</p><ul><li><a href="https://ollama.com/library/llama3.3?ref=blog.256pages.com">Llama 3.3</a> — Meta 開源的 LLM，晚點可能還會有 Llama 4 。</li><li><a href="https://ollama.com/library/deepseek-r1?ref=blog.256pages.com">Deepseek R1</a> — 中國團隊蒸餾 ChatGPT 而成的 LLM，聽說有著 ChatGPT 7成的效能，對中文的理解能力比 Llama 好。</li><li><a href="https://ollama.com/library/gemma3?ref=blog.256pages.com">Gemma 3</a> — 由 Google 開源，就是單核版的 Gemini，只需一粒 GPU 足以運行並同時有強勁的效能，對中文的支援也很好。</li></ul><p>以下是 Google 提供的分數比較圖：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6m_fj5QS5Yoh-OmV.png" /><figcaption>各大 LLM 比較圖 from <a href="https://blog.google/technology/developers/gemma-3/">Google</a></figcaption></figure><p>雖然 Gemma 3 跑分輸 DeepSeek R1，但相對所需的 GPU 就只需一粒，效能消耗更低，更適合本地部署做用。</p><h3>下載 LLM</h3><p>選好了想要的 LLM 後在 Open WebUI 也提供直接下載的方法，只要記住你想要的 Model 名。</p><p>如果想安裝指定版本的 model 也可以，部分 model 會有不同 B 的版本，好像 Gemma 3 就有 1B/4B/12B/27B，那個 B 是指有多少個 billion 的參數，參數越大，理解力及生成力就越強，當然所需的資源也會比較多，大家可以自己選擇合適的 Model 下載。</p><p>在設定 (Setting) 內打開管理員設定 (Admin Setting)，在模式 (Model) 分頁中什麼也沒有，因為我們還沒有下載任何 Model，按一下右上角的下載按鈕打開管理模式，就會見到以下介面。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/0*qTCAZjrciOo1kla3.png" /><figcaption>下載 LLM</figcaption></figure><p>在從 Ollama.com 下載模型輸入你想要的 Model 名，例如我要下載 Gemma 3 的 27B 版本，在 Ollama 找到了 gemma3:27b ，這個標籤再按右邊的下載按鈕就會開始下載，由於一般 LLM 容量都不少，要花一點時間來下載。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/0*J3Xn5s-m6D7suzXh.png" /><figcaption>正在下載 Gemma 3 27B</figcaption></figure><p>不想要的 Model 也可以在下面選擇刪除掉，以免花費太多空間。</p><p>如果想用一些非 Ollama 的模型也可以打開最下面實驗性功能自行上載到 Open WebUI 中使用。</p><p>下載完成後關掉管理頁面，在左上角選擇你的 Model 就可以開始對話!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V75eUtLdi17EXJUy.png" /><figcaption>跟 Gemma 3 say hi</figcaption></figure><h3>預設使用繁體中文回應</h3><p>有時你沒有提醒，或者你只說了英文字，Model 就會忘了用繁體中文回應，其實可以預設繁體中文回應的。</p><p>在設定可以見到 <strong>系統提示詞</strong>，這個系統提示詞會在每次對話時都讓 Model 記住，我就加上一句使用 繁體中文回應 再 Hi 一下看看會怎樣。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rk-hiq6ErDILOVbV.png" /><figcaption>設定系統提示詞</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jdydwMnz4262APl_.png" /><figcaption>只是 hi 也會用繁體中文回應</figcaption></figure><p>你也可以預設一些身份或語氣給 Model，以配合你的使用需要。</p><h3>為什麼會有 Error？</h3><p>相信有部份人在發送訊息後會見到紅色的 Error 框框，是設定錯誤了嗎？</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WWh3VQV5kCVcMcaW.png" /><figcaption>回應了 Error 500</figcaption></figure><p>如果你可以見到 Open WebUI 介面，應該沒有什麼設定錯誤了，但是這個情況多半是你電腦效能不足，畢竟 gemma3:27b 也是一個巨大的模型。你有兩個選擇可以做的：</p><ol><li>如果你電腦是用 Nvidia GPU 的話就安裝 Nvidia GPU 版本，效能會有顯著起升，也可以在 Docker Desktop 設定更多的記憶體，預設給 Docker 的記憶體應該有 8GB 左右，最少要改到比你的 Model 多，Swap 也可以增加一點。</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nKQmRkhXzR2Tg2zs.png" /><figcaption>我使用 Gemma3 27b 時最少要有 24GB 記憶體才夠用</figcaption></figure><p>2. 如果沒有 GPU 記憶體也不多，選用較少的 Model 是比較輕鬆的選擇，畢竟不是每人也有超級電腦可以用嘛。改成使用 Gemma 3 4b 的話，就算只分配 8GB 記憶體給 Docker 也可以順利運作！</p><p><em>Originally published at </em><a href="https://blog.256pages.com/free-chatgpt-gemma3/"><em>https://blog.256pages.com</em></a><em> on April 10, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e15966b4804f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hong-kong-tech/%E5%A6%82%E4%BD%95%E5%9C%A8%E6%9C%AC%E6%A9%9F-offiline-%E5%85%8D%E8%B2%BB%E7%84%A1%E9%99%90%E9%81%8B%E8%A1%8C-chatgpt-e15966b4804f">如何在本機 Offiline 免費無限運行 ChatGPT?</a> was originally published in <a href="https://medium.com/hong-kong-tech">HKIT DOG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Analytics 4 如何使用本地腳本?]]></title>
            <link>https://medium.com/hong-kong-tech/google-analytics-4-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E6%9C%AC%E5%9C%B0%E8%85%B3%E6%9C%AC-598179a2f496?source=rss----4fa69ea370c1---4</link>
            <guid isPermaLink="false">https://medium.com/p/598179a2f496</guid>
            <category><![CDATA[技術文章]]></category>
            <category><![CDATA[google-analytics-4]]></category>
            <category><![CDATA[csp]]></category>
            <category><![CDATA[gtag]]></category>
            <category><![CDATA[前端開發]]></category>
            <dc:creator><![CDATA[Edmond Y.]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 11:31:29 GMT</pubDate>
            <atom:updated>2024-04-19T11:31:29.472Z</atom:updated>
            <content:encoded><![CDATA[<h4>用 gtag.js 來避開 CSP 封鎖的問題</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BJny3OftkgDPJS3V.png" /><figcaption>Google Analytics 4 如何使用本地腳本?</figcaption></figure><p>雖然很久沒寫技術文章，但有讀者向我問能否用之前所教的方法應用在 GA4。以下是我之前講述在本地使用 Google 的 analytics.js 來避開 CSP 的封鎖。</p><p>其實在之後 Google 廣推 Google Tag Manager，多數情況下都己改用 gtag，而之前所教的 analytics.js 都已經換成 gtag.js 各位可以在 <a href="https://developers.google.com/analytics/devguides/collection/gtagjs?ref=blog.256pages.com">此頁</a> 下載</p><pre>&lt;!-- Google tag (gtag.js) --&gt; &lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID&quot;&gt;&lt;/script&gt; &lt;script&gt; window.dataLayer = window.dataLayer || []; function gtag(){window.dataLayer.push(arguments);} gtag(&#39;js&#39;, new Date()); gtag(&#39;config&#39;, &#39;GA_TRACKING_ID&#39;); &lt;/script&gt;</pre><p>將 GA_TRACKING_ID 換成 你的 GA 追蹤碼就可以。</p><p><em>Originally published at </em><a href="https://blog.256pages.com/google-analytics-4-localhost/"><em>https://blog.256pages.com</em></a><em> on April 10, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=598179a2f496" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hong-kong-tech/google-analytics-4-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E6%9C%AC%E5%9C%B0%E8%85%B3%E6%9C%AC-598179a2f496">Google Analytics 4 如何使用本地腳本?</a> was originally published in <a href="https://medium.com/hong-kong-tech">HKIT DOG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[在 StableDiffusionWebUI 輕鬆安裝及使用 LoRA / LyCORIS 及設定縮圖]]></title>
            <link>https://medium.com/hong-kong-tech/%E5%9C%A8-stablediffusionwebui-%E8%BC%95%E9%AC%86%E5%AE%89%E8%A3%9D%E5%8F%8A%E4%BD%BF%E7%94%A8-lora-lycoris-%E5%8F%8A%E8%A8%AD%E5%AE%9A%E7%B8%AE%E5%9C%96-c3ca159c4695?source=rss----4fa69ea370c1---4</link>
            <guid isPermaLink="false">https://medium.com/p/c3ca159c4695</guid>
            <category><![CDATA[stablediffusionwebui]]></category>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[技術文章]]></category>
            <category><![CDATA[生成式ai]]></category>
            <category><![CDATA[lora]]></category>
            <dc:creator><![CDATA[Edmond Y.]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 11:06:12 GMT</pubDate>
            <atom:updated>2024-04-19T11:06:12.859Z</atom:updated>
            <content:encoded><![CDATA[<h4>設定安裝一次學會</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ritm1wIPl4tGf9lW.jpg" /><figcaption>在 StableDiffusionWebUI 輕鬆安裝及使用 LoRA / LyCORIS 及設定縮圖</figcaption></figure><p>在 <a href="https://civitai.com/?ref=blog.256pages.com">Civital</a> 上經常見到有很多 LoRA / LyCORIS 可供下載，現在新版的 StableDiffusionWebUI 已經內置 LoRA / LyCORIS 可以直接使用。</p><h3>什麼是 LoRA / LyCORIS？</h3><p>LoRA (Low-Rank Adaptation)，LyCORIS 也叫做 LoHA/LoCON，兩者都是一種微調 Model ，用來控制人物或風格比較容易，LyCORIS 比 LoRA 更節省訓練資源，層數比一般 LoRA 更多更精準，出來的檔案更少。</p><p>而且兩者出來的效果相約，相信會越來越多開發者轉用 LyCORIS。</p><h3>安裝 LyCORIS</h3><p>從網址安裝 <a href="https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris">https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris.git</a></p><h3>怎樣使用 LoRA / LyCORIS？</h3><p>只需將下載的檔案放置在指定位置：</p><ul><li>LoRA — /stable-diffusion-webui/models/Lora</li><li>LyCORIS — /stable-diffusion-webui/models/LyCORIS</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*5OYISzbnhZjjwdSkKt9QbA.png" /><figcaption>Extra Networks</figcaption></figure><p>按一下 Generate 下面的紅色 Extra Networks 按鈕，會在下面打開 Extra Networks 的選擇 UI。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4qlxMuTt5yGbhgK8RdUmcA.png" /><figcaption>LyCORIS UI</figcaption></figure><p>然後會見到一張張 LoRA 卡，但不像我這個樣子，全部都是大張 No Preview 的灰色圖，以下會教大家改成我這個樣子。</p><h3>1. 為 Model 加設圖片</h3><p>有兩種方法：（適用於所有 Model）</p><ol><li>在 civital 下載一張 Model 的 demo 圖片，一定要 save as png，然後將圖片檔案名改成跟 model一樣放到相同資料夾，重新整理即可見到。</li><li>生成一張圖片後，按一下 Model Card 右上角的 replace。</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/184/1*EBr0zMohWSw5S5iNCvZhmA.png" /><figcaption>replace preview button</figcaption></figure><h3>2. 調所 Model Card 大小</h3><p>到 setting &gt; Extra Networks （額外網絡） 更改以下 三項設定</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/0*mvTaP_Bk8NCokFoA.png" /></figure><ul><li>Default view for Extra Networks 改成 thumbs</li><li>Card width 改成 80</li><li>Card height 改成 100</li></ul><p>save 後重新整理就會變成跟我的界面一樣了，當然你也可以按自己需要更改長闊，找適合自己的設定！</p><p><em>Originally published at </em><a href="https://blog.256pages.com/stablediffusion-lora-lycoris-setting/"><em>https://blog.256pages.com</em></a><em> on June 4, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3ca159c4695" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hong-kong-tech/%E5%9C%A8-stablediffusionwebui-%E8%BC%95%E9%AC%86%E5%AE%89%E8%A3%9D%E5%8F%8A%E4%BD%BF%E7%94%A8-lora-lycoris-%E5%8F%8A%E8%A8%AD%E5%AE%9A%E7%B8%AE%E5%9C%96-c3ca159c4695">在 StableDiffusionWebUI 輕鬆安裝及使用 LoRA / LyCORIS 及設定縮圖</a> was originally published in <a href="https://medium.com/hong-kong-tech">HKIT DOG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stable Diffusion Prompt (基本篇2)]]></title>
            <link>https://medium.com/hong-kong-tech/stable-diffusion-prompt-%E5%9F%BA%E6%9C%AC%E7%AF%872-7534ab50bd6b?source=rss----4fa69ea370c1---4</link>
            <guid isPermaLink="false">https://medium.com/p/7534ab50bd6b</guid>
            <category><![CDATA[negative-prompt]]></category>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[生成式ai]]></category>
            <category><![CDATA[技術文章]]></category>
            <category><![CDATA[stable-diffusion-教學]]></category>
            <dc:creator><![CDATA[Edmond Y.]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 11:00:49 GMT</pubDate>
            <atom:updated>2024-04-19T11:00:49.506Z</atom:updated>
            <content:encoded><![CDATA[<h4>加入反向 Prompt (Negative Prompt)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uI2Aium-FrW-mPTr.jpeg" /><figcaption>Stable Diffusion Prompt + Negative Prompt</figcaption></figure><p>由於有讀者反映 (基本篇) 最後出來的成果不是太理想，懷疑是教學不到位，我重看一遍也覺得好像不太對勁，因為 ChilloutMix 本身是以亞洲人為主的 Checkpoint，所以出來是一個外國人還是有點奇怪。</p><p><a href="https://blog.256pages.com/stable-diffusion-basic-prompt-tutorial/">Stable Diffusion Prompt (基本篇)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*m4v5sGcyIDFhY-XNXOAlig.png" /><figcaption>上次最終成果</figcaption></figure><p>就結論而言上次的 prompt 並不足夠！所以我追加這篇來強化上次的結果，讓真正的美少女出來！</p><h3>加上美麗的形容詞</h3><p>首先我上次忘了的是我們要是【美少女】！所以必須加一點美麗的形容詞：</p><p>將以上的 prompt 加上上次最終的 prompt： 1 girl, masterpiece, best quality, high resolution, 8K , HDR, bloom, sun light, raytracing , detailed shadows, intricate tree shadow, bokeh, depth of field, film photography, film grain, glare, (wind:0.8)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*q46WOA6s24uV8-puW3_ljQ.png" /><figcaption>加上 加上 detailed hair, beautiful face, beautiful girl, ultra detailed eyes</figcaption></figure><p>加上一些漂亮的 prompt 後有漂亮了，但還是欠缺些真實度！</p><h3>加入更多形容詞 Prompt</h3><p>我再加多幾個 prompt 來提升真實感：</p><ul><li>cinematic lighting - 上次發現漏了的電影級光源！</li><li>(hyperdetailed:1.15) - 權重 1.15 的超精細</li><li>outdoors - 加上一些戶外的元素</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*s41m8Dd0n9A8_qh7lM9ifw.png" /></figure><p>臉上的光影變得比較像樣，但是還是外國人的樣子，接下來要教的是加入一些反向 prompt。</p><h3>加入反向 Prompt</h3><p>反向 Prompt 是 Stable Diffusion 的一個重要功能，可以把你不想出現的原素寫在 prompt 中，其中最為大家推薦的就是使用 EasyNegative 。一個萬用的反向 prompt，基本上任何情況都可以使用，建議下載。</p><p><a href="https://huggingface.co/datasets/gsdf/EasyNegative/tree/main">gsdf/EasyNegative at main</a></p><ul><li>大家只需要下載 EasyNegative.safetensors</li><li>放到你的 StableDiffusionWebUI 目錄 Stable-Diffusion-WebUI/embeddings/ 這個資料夾</li><li>按 產生 下面的第三個按鈕打開 extra networks</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*2VrvVQhYKb3swfsZyKbHJA.png" /><figcaption>按紅色方框圈住的按鈕</figcaption></figure><ul><li>下面會有一個新的 Tab 彈出來</li><li>按一下重新整理後，在 文本反轉 (Textual Inversion) 中就會出現 easynegative</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vI-kRbAl3bzri_lSDuudtw.png" /><figcaption>Extra Networks 界面</figcaption></figure><ul><li>你點選 netgative prompt 的輸入框再按一下 easynegative 的方格，就會自動在 prompt 中加入 easynetgative</li><li>另外除了 easynetgative 外我們還可以自己加入一些</li></ul><p>思維跟一開始「選取最佳的樣本」一樣，我們不要最差的樣本</p><ul><li>(worst quality:2.00) - 最差的不要，權重 2.0 = 絕對不要</li><li>(low quality:2.00) - 低質的也絕對不要</li><li>(normal quality:2.00) - 連普通的也絕對不要，只要最好的</li><li>low-res - 低解像度的也不要</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*zwX51PUNugbkgWGhX5gHHA.png" /><figcaption>反向加入 (worst quality:2.00), (low quality:2.00), (normal quality:2.00), low-res, easynegative</figcaption></figure><p>一加入反向 prompt，出來的畫質有飛躍的提升！</p><p>這才是我們想要的結果吧！</p><p>重溫一下這次追加及原本的 prompt — 1 girl, masterpiece, best quality, high resolution, 8K , HDR, bloom, sun light, raytracing , detailed shadows, intricate tree shadow, bokeh, depth of field, film photography, film grain, glare, (wind:0.8), detailed hair, beautiful face, beautiful girl, ultra detailed eyes, cinematic lighting, (hyperdetailed:1.15), outdoors</p><p>追加反向的 prompt — (worst quality:2.00), (low quality:2.00), (normal quality:2.00), low-res, easynegative</p><h3>總結</h3><p>反向 prompt 看起來不重要，但是對出來的結果有決定性的影響，所以大家絕對不能忽視這個部份！</p><p><em>Originally published at </em><a href="https://blog.256pages.com/stable-diffusion-basic-prompt-2/"><em>https://blog.256pages.com</em></a><em> on May 13, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7534ab50bd6b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hong-kong-tech/stable-diffusion-prompt-%E5%9F%BA%E6%9C%AC%E7%AF%872-7534ab50bd6b">Stable Diffusion Prompt (基本篇2)</a> was originally published in <a href="https://medium.com/hong-kong-tech">HKIT DOG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stable Diffusion Prompt (基本篇)]]></title>
            <link>https://medium.com/hong-kong-tech/stable-diffusion-prompt-%E5%9F%BA%E6%9C%AC%E7%AF%87-f79806b54525?source=rss----4fa69ea370c1---4</link>
            <guid isPermaLink="false">https://medium.com/p/f79806b54525</guid>
            <category><![CDATA[prompt-教學]]></category>
            <category><![CDATA[生成式藝術]]></category>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[技術文章]]></category>
            <category><![CDATA[生成式ai]]></category>
            <dc:creator><![CDATA[Edmond Y.]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 10:57:33 GMT</pubDate>
            <atom:updated>2024-04-19T10:57:33.827Z</atom:updated>
            <content:encoded><![CDATA[<h4>一步步教你提升圖片質感</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L6fPUrkuXOkUU_pI.jpeg" /><figcaption>Stable Diffusion Prompt 基本教學</figcaption></figure><p>Stable Diffusion 有很多常用的 prompt (提示詞) ，基本上一定會使用，使出來的成像有一定質素保證，以下就是教大家一些基本的 prompt 及設定，節省大家初步摸索的時間。</p><blockquote><em>目標是生成一張漂亮的女孩子照片</em></blockquote><p>首先用 1 girl 來做一個簡單的 prompt，Checkpoint 使用 ChilloutMix ，能生成出精美的真人圖 ，其餘都是預設設定 Size 是 512 x 512，開啟面部修復， Sampler Euler a，Steps 20， CFG scale 7，Clip skip 2，Seed 固定為 2995626718 降底隨機性。</p><ul><li>以 1girl 出來的圖像是這個樣子</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*mIrQfp4a2vevokBmX1ugfg.png" /><figcaption>Prompt: 1girl</figcaption></figure><p>嗯….談不上精美，看起來也怪怪的。</p><h3>選對 Sampler</h3><p>Sampler Euler a 不太適合真人，我會另外開一篇教用 Sampler，所以先轉成光影比較精細的 DPM++ SDE Karras 試試看。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*4RQB91Oo5OTSgEOeCMDF8w.png" /><figcaption>Sampler 轉成 DPM++ SDE Karras</figcaption></figure><p>光影部份有明顯提升，立體感好了很多，但樣子看起來還是怪怪的！</p><h3>最佳的樣本</h3><p>現在我們新增一些基本 prompt，以下會說明這些 prompt</p><ul><li>masterpiece 大師級作品</li><li>best quality 最佳畫質</li><li>high resolution高解像度</li><li>8K 比4K還要高一級的解像度</li><li>HDR高動態範圍</li></ul><p>這些都是一些提升畫質的提示，讓 Stable Diffusion 取樣時使用最好的樣本，也沒必要逐個試，基本上全都貼上就可以有一定程度的畫質提升。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*MihkMQ9CKCE6PSUaQrvDpw.png" /><figcaption>1 girl, masterpiece, best quality, high resoultion, 8K, HDR</figcaption></figure><p>現在看起來有點像 3D CG，整體上還好像暗暗的。沒錯，是光源！現在我們新增一些光源的 prompt。</p><h3>加入光源</h3><p>首先放一個 cinematic lighting 來展示電影級的光影效果，然後可以用不同 prompt 去實現不同的光源。</p><p>由於沒有太多 prompt 去形容 1girl 所以出來有點變化，但看起來還是差不多的樣子，分別看一下每一種光源的效果：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uCoN3IQ58IoOXjFRa0EUzw.jpeg" /><figcaption>使用不同的光源 Prompt</figcaption></figure><ul><li>bloom 令原本的光源更亮了，看頭頂及肩膊有變亮的效果</li><li>soft lighting 比較柔和的光源，面部有光，背部也有一點</li><li>hard lighting 直接打在人物上的光，見到面部輪廓會比較突出</li><li>backlight 就是背光，樣子明顯變暗了，肩膊及頭髮有背後來的光源</li><li>god rays 另一種背光，由較高的位置射燈式射下來，見到頭頂部份特別亮</li><li>volumetic lighting 就像柔光版的背光，整體較暗，有點生化危機的感覺</li><li>sun light 比較自然的陽光，連背景的樹都會見到陽光照射</li><li>studio light 左右都有光源打在面上，立體感很強，就像廣告照</li><li>bioluminescent light 本體在發光，就像螢火蟲一樣的夜光</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*S5u86aEbOGiynDwTl_FpGg.png" /><figcaption>1 girl, masterpiece, best quality, high resolution, 8K, HDR, bloom, sun light</figcaption></figure><p>光線看起來不錯了，但是還不夠真實感，有點電影劇照的樣子。有光就一定有影，所以我們就加點影子及相關的 prompt 提升真實感。</p><h3>加入影子及光追</h3><ul><li>detailed shadows 就是加多點精細的影子，鼻子及衣服也有些光影出現</li><li>intricate tree shadow 因為是樹林所以就加點錯綜複雜的樹影，看起來更真實</li><li>raytracing 見到下巴位置有些衣服反射的光線</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*QOfiv4ooiWtxg2xR5D49Og.png" /><figcaption>1 girl, masterpiece, best quality, high resolution, 8K, HDR, bloom, sun light, detailed shadows, intricate tree shadow, raytracing</figcaption></figure><p>整體的真實感提升了不少，已經是一個漂亮的女孩子，接下把圖片看起來像照片。</p><h3>加入照片效果</h3><ul><li>bokeh depth of field 散景及景深，看起來像大光圈的鏡頭拍出來的照片</li><li>film photography film grain 相片的顆粒感，不過圖太少看不出來</li><li>glare 鏡頭炫光，有一點點但不明顯</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*BIQy6C1BsxFf5JYt29WjDw.png" /><figcaption>1 girl, masterpiece, best quality, high resolution, 8K, HDR, bloom, sun light, detailed shadows, intricate tree shadow, raytracing, bokeh, depth of field, film photography, film grain, glare</figcaption></figure><p>由於本身已經有樹林做背景，所以不用額外設定背景，不過加點風去增加動態感吧！</p><h3>做用權重控制風力</h3><ul><li>wind 直接使用 prompt 權重 = 1 預設值</li><li>(wind:0.5) 你可以括起來設定 0 - 2 的小數，數字越小效果越弱</li><li>(wind:1.5) 數字越大效果越強</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oSkpJKy5B6q6W4S_mrsQ0Q.jpeg" /><figcaption>(wind:0) 至 (wind:2) 的效果</figcaption></figure><ul><li>一般會設定 0.6–1.4 左右的數值，太少就沒效果，太高就會影響構圖 (被風吹跑了)，我不想太大風，設定了 (wind:0.8)。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*m4v5sGcyIDFhY-XNXOAlig.png" /><figcaption>1 girl, masterpiece, best quality, high resolution, 8K, HDR, bloom, sun light, detailed shadows, intricate tree shadow, raytracing, bokeh, depth of field, film photography, film grain, glare, (wind:0.8)</figcaption></figure><p>現在看起來 (應該) 像一張照片了吧！可以進行圖片放大了！</p><h3>放大圖片</h3><p>因為直接生成 1024 x 1024 會出現問題，所以我們都是先生成小圖再放大。</p><ul><li>點選 高解析度修正（Hires. fix），此功能會保留細節放大</li><li>選擇 R-ESRGAN 4x+ 的放大器，放大兩倍到 1024 x 1024</li><li>由於不想有大幅度改變，重繪幅度 (Denoising) 設定為 0.2</li></ul><blockquote><em>Loading 到 50%後會開始有點慢，請耐心等待</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OENXG124hcVdEfCpVS2dfA.jpeg" /><figcaption>完成！看起來有點像 Scarlett Johansson (笑)</figcaption></figure><p>今次教學最終用到的 prompt 是 1 girl, masterpiece, best quality, high resolution, 8K , HDR, bloom, sun light, raytracing , detailed shadows, intricate tree shadow, bokeh, depth of field, film photography, film grain, glare, (wind:0.8) ，快點試試看！</p><h3>總結</h3><p>整個生成圖片的流程就是這樣利用 prompt 去控制出來的圖片，知道一些基本 prompt 可以免去很多實驗時間，更易成功出到理想的圖片。</p><p>我之後還會深入寫不同的 Stable Diffusion 教學，敬請留意！</p><p><em>Originally published at </em><a href="https://blog.256pages.com/stable-diffusion-basic-prompt-tutorial/"><em>https://blog.256pages.com</em></a><em> on May 10, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f79806b54525" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hong-kong-tech/stable-diffusion-prompt-%E5%9F%BA%E6%9C%AC%E7%AF%87-f79806b54525">Stable Diffusion Prompt (基本篇)</a> was originally published in <a href="https://medium.com/hong-kong-tech">HKIT DOG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MacOS 安裝 StableDiffusionWebUI]]></title>
            <link>https://medium.com/hong-kong-tech/macos-%E5%AE%89%E8%A3%9D-stablediffusionwebui-e5c2eced8224?source=rss----4fa69ea370c1---4</link>
            <guid isPermaLink="false">https://medium.com/p/e5c2eced8224</guid>
            <category><![CDATA[生成式ai]]></category>
            <category><![CDATA[stablediffusionwebui]]></category>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[生成式藝術]]></category>
            <dc:creator><![CDATA[Edmond Y.]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 10:54:57 GMT</pubDate>
            <atom:updated>2024-04-19T10:54:57.255Z</atom:updated>
            <content:encoded><![CDATA[<h4>並有一些有用的 Extension 及 Model 下載處</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wr_LBxeaZV2h_VAf.jpeg" /><figcaption>MacOS 安裝 StableDiffusionWebUI</figcaption></figure><p>雖然網上有不少 Cloud 的 圖像生成 AI service，但是如果要大量/長期免費地使用，在本地安裝及依靠本機運算能力的 Stable Diffusion 是一個不錯的選擇。</p><p>雖然網上有不少 Cloud 的 圖像生成 AI service，但是如果要大量/長期免費地使用，在本地安裝及依靠本機運算能力的 Stable Diffusion 是一個不錯的選擇。</p><blockquote><em>由於我只有 M1 的 MacbookPro，所以只能寫 MacOS 版本的教學，不過上網也有不少 Windows 版本的教學可以參考。</em></blockquote><p>首先看一下現時 MacOS 可以使用什麼軟件來安裝 Stable Diffusion。Stable Diffusion 不是一個軟件，是一個以潛在擴散方式生成圖像的模型，本身是以 Python 寫成，所以最直接的方法是安裝 Python 版本，並以 command 方式操作，但是為方便不會用 Python 的用家，有不少有 UI 的可操作版本出來了。</p><h3>StableDiffusionWebUI 簡介</h3><p>使用了 gradio 作為 Stable Diffusion 的 WebUI，並在 localhost 用 Web 顯示 UI，可以配合不同的 Model 及 Extension，更新速度極快，最新的功能一出來也馬上支援，但需要一點點操作一點點 Python。</p><p>由於更新速度快，功能最齊全，也是最廣為用家使用的 Stable Diffusion 界面，個人也是極度推薦使用 StableDiffusionWebUI ，因為有些 extension 也只有 WebUI 能用。</p><h3>安裝方法</h3><p>首先要安裝 Python 3.10，MacOS 通常本身有 Python 2.x 版本，為了方便版本控制最好先安裝 pyenv。安裝 pyenv 需要使用 Homebrew，所以我們的安裝次序如下（如已安裝可跳過）。</p><p>由於時間關係可以先下載 Stable Diffusion 1.5 的 Model<br>下載 <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt?ref=blog.256pages.com">v1–5-pruned-emaonly.ckpt</a> — 4.27GB,</p><ol><li>安裝 <a href="https://brew.sh/?ref=blog.256pages.com">Homebrew</a></li><li>安裝 Python 3.10</li><li>安裝 StableDiffusionWebUI</li><li>安裝 StableDiffusionWebUI Extension</li><li>介紹下載 Model 的好地方</li></ol><h3>1. 安裝 Hombrew</h3><ul><li>Homebrew 是一個 MacOS 必用的安裝程式，使用官網的指令可以一鍵安裝。</li><li>/bin/bash -c &quot;$(curl -fsSL <a href="https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh?ref=blog.256pages.com">https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh</a>)&quot;</li><li>如缺少 Xcode 請先安裝 xcode-select --install</li><li>安裝完成後可以用 brew update 更新一下 Homebrew 的目錄 (第一次會比較長時間)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*h8i7Scgh_kyKqZKLgIXnMA.png" /><figcaption>brew update</figcaption></figure><ul><li>如 brew update 後有軟件需要更新可用 brew upgrade 進行更新</li></ul><h3>2. 安裝 pyenv</h3><p>pyenv 是用來控制 Python 版本的工具。首先用 python --version 指令看看現時的版本。只要不是 Python 3.10 就需要安裝，方法如下：</p><ul><li>brew update 先更新一下 Homebrew</li><li>brew install openssl readline sqlite3 xz zlib 安裝 pyenv 須要的程式</li><li>brew install pyenv 可以安裝 pyenv</li><li>echo -e &#39;if command -v pyenv 1&gt;/dev/null 2&gt;&amp;1; then\n eval &quot;$(pyenv init -)&quot;\nfi&#39; &gt;&gt; ~/.bash_profile exec &quot;$SHELL&quot; 然後確保 pyenv 會自動更新</li></ul><p>然後可以安裝 Python 3.10.6</p><ul><li>pyenv install 3.10.6 安裝</li><li>pyenv global 3.10.6 設定</li><li>python --verison 查看一下版本是否真的是 3.10.6</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/0*9iMqIUEavvTSCFt3.png" /></figure><h3>3. 安裝 StableDiffusionWebUI</h3><ul><li>成功安裝 Python 後</li><li>首先安裝 StableDiffusionWebUI 所需的其他軟件</li><li>brew install cmake protobuf rust git wget</li><li>建立 StableDiffusionWebUI 的資料夾 e.g. mkdir /Users/YourName/Documents/StableDiffusion/</li><li>在 Terminal 在這個資料夾下用 git 下載 source code</li><li>git clone <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui">https://github.com/AUTOMATIC1111/stable-diffusion-webui</a></li><li>在 /Users/YourName/Documents/StableDiffusion/ 執行 ./webui.sh</li><li>如果沒有任何 Model 在的話會自動下載 Stable Diffusion 1.5</li><li>如事前已下載就可以將檔案放到 /Users/YourName/Documents/StableDiffusion/models/Stable-diffusion 內</li><li>在 /Users/YourName/Documents/StableDiffusion/ 執行 ./webui.sh</li><li>第一次打開會自動下載一些檔案</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uiQoLpak10n-SUl8.png" /></figure><ul><li>完成後在瀏覽器打開 http://localhost:7860 就可以見到 WebUI</li><li>在 txt2img 的 prompt 輸入框中輸入一些 prompt 然後接右邊的 Generate / command + Enter 即時會開始 AI 生成圖片。</li></ul><h3>4. 安裝 StableDiffusionWebUI Extension</h3><ul><li><a href="https://blog.256pages.com/stablediffusionwebui-traditionalchinese/">StableDiffusionWebUI 正體中文化安裝教學</a></li><li><a href="https://blog.256pages.com/stablediffusionwebui-state/">StableDiffusionWebUI State 狀態儲存</a></li></ul><h3>5. 下載 Model 的好地方</h3><ol><li>Civitai — 極多 Stable Diffusion Model 下載的網站，注意有兒童不宜的內容</li></ol><p><a href="https://civitai.com/">Civitai: The Home of Open-Source Generative AI</a></p><p>2. Hugging Face — AI Model 的 Github，可以找到一些沒有放上 Civitai 的 Model 或是一些 Extension 的原檔</p><p><a href="https://huggingface.co/models?sort=downloads&amp;search=stable+diffusion">Models - Hugging Face</a></p><p><em>Originally published at </em><a href="https://blog.256pages.com/macos-install-stablediffusionwebui/"><em>https://blog.256pages.com</em></a><em> on May 4, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5c2eced8224" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hong-kong-tech/macos-%E5%AE%89%E8%A3%9D-stablediffusionwebui-e5c2eced8224">MacOS 安裝 StableDiffusionWebUI</a> was originally published in <a href="https://medium.com/hong-kong-tech">HKIT DOG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[在 VueJS 中建立 Three.js 場景]]></title>
            <link>https://medium.com/hong-kong-tech/%E5%9C%A8-vuejs-%E4%B8%AD%E5%BB%BA%E7%AB%8B-three-js-%E5%A0%B4%E6%99%AF-31add5661e0f?source=rss----4fa69ea370c1---4</link>
            <guid isPermaLink="false">https://medium.com/p/31add5661e0f</guid>
            <category><![CDATA[技術文章]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[threejs-教學]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Edmond Y.]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 10:49:50 GMT</pubDate>
            <atom:updated>2024-04-19T10:49:50.544Z</atom:updated>
            <content:encoded><![CDATA[<h4>如何建立場景，燈光，物件</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PqfObkxRYisKzV1o.png" /><figcaption>在 VueJS 中建立 Three.js 場景</figcaption></figure><p>上回說明如何載入 Three.js，接下來就會建立一個簡單的場景，Three.js 建立 3D 場景的概念跟 3D 軟件中繪圖的概念相當接近，只是換成用程式來建立，如果有使用 3D 繪圖軟件的經驗會更好了解。在 Vue 中建立 Three.js 場景就先要了建 Vue 的流程。</p><p>我當是使用的 Vue 版本是 2.x，Three.js 版本是 R97。Vue 的設定不多說，大家必需先學會 Vue。</p><p>首先在 mounted() 中載入 this.init()，在 init() 中會預先定義一些共用的數據，以便在不同的 methods 中共用。</p><p>簡單說明一下我會建立以下 methods 有什麼作用</p><ul><li>init() 定義共用數據及運行 runTime()</li><li>runTime() 建立主要流程，我個人喜歡分開成不同 methods 比較易處理</li><li>createScene() 建立場景，我把 Scene, Camera, Renderer 都放這兒</li><li>createLights() 建立燈光</li><li>createObject() 建立物件，Geometry 及 Material 都在這處理</li><li>windowResize() 網站的話就必需處理 responsive 的問題</li><li>renderScene() 就是會重覆 render 時，處理動畫格的位置</li></ul><p>整段 Code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53c5d16028dd8506a6623a5ad905e5ad/href">https://medium.com/media/53c5d16028dd8506a6623a5ad905e5ad/href</a></iframe><p>出來的效果就跟我在 <a href="https://lab.256pages.com/wireframe">Lab</a> 中展視的一樣，大家可以去看看。</p><p>當中各部份還可以作更深入的設定，詳細可以到 Three.js <a href="https://threejs.org/">官網的文件</a> 看看。</p><p><em>Originally published at </em><a href="https://blog.256pages.com/build-3d-scene-in-vue/"><em>https://blog.256pages.com</em></a><em> on October 30, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31add5661e0f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hong-kong-tech/%E5%9C%A8-vuejs-%E4%B8%AD%E5%BB%BA%E7%AB%8B-three-js-%E5%A0%B4%E6%99%AF-31add5661e0f">在 VueJS 中建立 Three.js 場景</a> was originally published in <a href="https://medium.com/hong-kong-tech">HKIT DOG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[在 VueJS 中使用 WebGL]]></title>
            <link>https://medium.com/hong-kong-tech/%E5%9C%A8-vuejs-%E4%B8%AD%E4%BD%BF%E7%94%A8-webgl-701ecbc5171a?source=rss----4fa69ea370c1---4</link>
            <guid isPermaLink="false">https://medium.com/p/701ecbc5171a</guid>
            <category><![CDATA[webgl]]></category>
            <category><![CDATA[技術文章]]></category>
            <category><![CDATA[個人網站]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[threejs]]></category>
            <dc:creator><![CDATA[Edmond Y.]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 10:44:55 GMT</pubDate>
            <atom:updated>2024-04-19T10:44:55.305Z</atom:updated>
            <content:encoded><![CDATA[<h4>在 VueJS 中使用 ThreeJS 顯示炫眼的 3D 效果</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sK8ikfG_ZaKKhTdN.png" /><figcaption>在 VueJS 中使用 WebGL</figcaption></figure><p>身為一個設計師，除了<a href="https://blog.256pages.com/svg-animation-background-vue/"> SVG動態背景</a> 及 <a href="https://blog.256pages.com/chinese-web-fonts/">中文 Web Fonts</a> 外也沒有什麼視覺上的效果，令我的作品在設計上有所缺失！</p><p>以前都是用 Flash 來開發一些超炫目的網站，但現在都轉成用 Javascript 了，當然要踏入 WebGL 的領域，開發炫眼的 3D 網站了！</p><h3>Three.js</h3><p>應該是最多人用也是最易用的 WebGL Javascript Library，在 Three.js 的 <a href="https://threejs.org/">官網</a> 有不少 examples 也有中文的文件，基本上依官網來做就可以完成不少效果。</p><p>不過 Three.js 對 ES6 及 Nodejs 的支援不是太理想，說明文件也不太足夠，引致當中要依靠很多額外的 plugins / library 才能完成在 Vue 中的工作。所以我寫這篇文章就是把我測試不同方法後，最為理想的解決方法。</p><p>首先用 <a href="https://blog.256pages.com/vue-cli-3/">VueCli 3</a> 建立一個基本的 Vue 網站，接下來我會建立兩個頁面，兩頁都有不同的 WebGL 效果在切換。</p><p>大家可能都會想，只是單純把 threejs 放到 vue 頁面罷了？但開發中途我才發現其實有很多隱藏的問題需要處理。</p><h3>如何載入 Three.js?</h3><p>首先看看有沒有人弄成 Vue Plugin，確實有 <a href="https://github.com/fritx/vue-threejs">vue-threejs</a> 這個項目。但我用這個source架不起來，不知是什麼問題… 官方的 example 也不是太清楚如何導入，如果有人用到不妨告訴我…</p><p>我們還是使用官方建議做法<br>$npm install three，千萬不要用錯 threejs ，這個是舊版本，不要弄錯!</p><p>然後就是載入 Three.js，我使用了 Plugins 的方式載入，方便以後使用。</p><p>然後在任何 Vue 檔案中 &lt;script&gt; 的範圍都可以用 this.$THREE 即可使用 Three.js 的功能而不用每頁也 import。</p><p>但這不是很簡單嗎？的確只用基本功能這樣子就夠，但其實還有很多功能未被載入，到而要做用時再說解決方法。</p><p><em>Originally published at </em><a href="https://blog.256pages.com/webgl-in-vuejs/"><em>https://blog.256pages.com</em></a><em> on May 30, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=701ecbc5171a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hong-kong-tech/%E5%9C%A8-vuejs-%E4%B8%AD%E4%BD%BF%E7%94%A8-webgl-701ecbc5171a">在 VueJS 中使用 WebGL</a> was originally published in <a href="https://medium.com/hong-kong-tech">HKIT DOG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Headless CMS — strapi]]></title>
            <link>https://medium.com/hong-kong-tech/headless-cms-strapi-b7177b7e6b43?source=rss----4fa69ea370c1---4</link>
            <guid isPermaLink="false">https://medium.com/p/b7177b7e6b43</guid>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[無頭-cms]]></category>
            <category><![CDATA[headless-cms]]></category>
            <category><![CDATA[技術文章]]></category>
            <dc:creator><![CDATA[Edmond Y.]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 10:41:55 GMT</pubDate>
            <atom:updated>2024-04-19T10:41:55.795Z</atom:updated>
            <content:encoded><![CDATA[<h3>Headless CMS — strapi</h3><h4>最近在外國正盛行的無頭 CMS (Headless CMS)，到底有什麼好處呢？跟我們常用的 CMS 又有什麼分別呢？</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q-5RDPG1U5Mzhqmi.png" /><figcaption>strapi</figcaption></figure><h3>什麼是 Headless CMS?</h3><p>傳統 CMS 好像著名的 Wordpress，Drupal，Ghost 等等都包括Front-end UI，也有 Theme 的部份，形成前後台合一的情況。而 Headless 的無頭就是不包括 Front-end，做一個純粹的 Backend CMS，輸出 API 給 Front-end 去讀取資料，不用再找 CMS 專用的 Theme 了，因為前後己經分離，所有 Front-end 只需看 API 就可以。</p><h3>Headless CMS 的好處</h3><p>因為後台變成獨立運作，所以對 Front-end 有什麼改動，只要 data 沒有變動就不在改 Backend，只需一個 Front-end Developer 就成。Front-end 也不用受 CMS 的 Theme所限制，即使整個 Front-end 砍掉重寫的成本也大減，資料也不用重入。</p><h3>Headless CMS 的壞處</h3><p>對不熟悉開發的用家來說需要自己動手去寫 Front-end 也許會更麻煩，沒有限制但也沒有一手按即用的插件，也不能作實時 Front-end 編輯，所以對低階用家可能更難使用。</p><h3>Headless CMS 的選擇</h3><p>現時 Headless CMS 有不少 Open Source 開源供下載，在試用過數隻 Open Source 的 CMS 後，決定了就做用 [strapi] ( <a href="https://strapi.io/">https://strapi.io/</a>) 做我的最終選擇，但是為什麼呢？</p><p>簡單來說就是付合了我的要求</p><p>雖然曾經用 Express ＋ MongoDB 來寫成 API，但要寫成可以隨時更改結構的 API 太大 workload，會把我原本想做的東西都忘了，所以就用一個可以輸出成 API 的 CMS，就可以集中精神來寫 Frontend 了。</p><p>strapi 我由測試版開始試用，剛開始時 bug 真的很多，動不動就會 crash，但是正式版上線後，官方快速地修正了大量 bug，並持續增加新功能及改善 backend 的設計。有多個本來令我困惑的位置也在正式版修正了，令我這篇文章終於可以 post 出來（因為之前一直沒下決定使用哪家）。</p><p>雖然 strapi 很簡單，但我也會寫一篇用 docker 來設定 strapi 的新手使用教學，敬請期待。</p><p><em>Originally published at </em><a href="https://blog.256pages.com/headless-cms-2018/"><em>https://blog.256pages.com</em></a><em> on February 25, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7177b7e6b43" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hong-kong-tech/headless-cms-strapi-b7177b7e6b43">Headless CMS — strapi</a> was originally published in <a href="https://medium.com/hong-kong-tech">HKIT DOG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[使用 Docker Compose 快速建立 Ghost]]></title>
            <link>https://medium.com/hong-kong-tech/%E4%BD%BF%E7%94%A8-docker-compose-%E5%BF%AB%E9%80%9F%E5%BB%BA%E7%AB%8B-ghost-d00380c24d4e?source=rss----4fa69ea370c1---4</link>
            <guid isPermaLink="false">https://medium.com/p/d00380c24d4e</guid>
            <category><![CDATA[docker-教學]]></category>
            <category><![CDATA[coreos]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[ghosts]]></category>
            <category><![CDATA[博客]]></category>
            <dc:creator><![CDATA[Edmond Y.]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 10:38:56 GMT</pubDate>
            <atom:updated>2024-04-19T10:38:56.226Z</atom:updated>
            <content:encoded><![CDATA[<h4>在上次<a href="https://blog.256pages.com/coreos-docker/">安裝 CoreOS</a> 後，首先搬家就是 Blog 了！</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2C523JbyBB0vkcYzUwGKfw.jpeg" /></figure><p><a href="https://medium.com/hong-kong-open-source/coreos-%E5%8F%8A-docker-7ace49b3cf28">CoreOS 及 Docker</a></p><p>先到 <a href="https://hub.docker.com/_/ghost/">Ghost 的 Docker Hub</a> 看看，看似相當地簡單。</p><h3>Docker Compose</h3><p>雖然可以直接使用 docker run 指令來完成，但我採用了可重用的方式，docker compose 是 Docker 官方的應用，可以把 docker run 的指令都記錄在 YAML 檔中，只要用 docker-compose up 指令就可以隨時運行內裡的一連串指令，不用每次都全部記住。</p><h3>安裝 Docker Compose</h3><pre>$ sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /opt/bin/docker-compose</pre><p>使用官方的連結下載最新的 docker-compose 來安裝</p><pre>$ sudo chmod +x /opt/bin/docker-compose</pre><p>然後更改一下權限就完成了</p><pre>$ sudo docker-compose --version docker-compose version 1.22.0, build f46880fe</pre><h3>設定 docker-compose.yml</h3><p>先建立一個 docker-compose.yml 檔來存放設定</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b63b5aca55cd9aba725b1f63c42ef37/href">https://medium.com/media/0b63b5aca55cd9aba725b1f63c42ef37/href</a></iframe><p>另外因為 container 使用的是 image，要更改設定或檔案只要幾個方法</p><ol><li>使用 image 本身設定好的 environment 去設定，通常最常見的設定也可以修改，也是最建議使用的方法。</li><li>把 image 內的原本的檔案 mount 到外面，那麼 docker run 的時候會把檔案複製到外面，然後你直接改外面的檔案就可以，這個例子就 mount 了 content 出來。</li><li>把更改了設定的 image 重新打包，但我覺得這樣會污染了原 image，也不利版本更新，盡量不會這樣做。</li></ol><h3>有幾點設定時需要注意</h3><ul><li>因為 YAML檔 是根據 tab 去分辦層數，必需注意</li><li>不同 docker-compose version 格式會不同</li><li><a href="https://blog.256pages.com/docker-image-version-2018/">Image 盡量做用 Apline 版本</a></li></ul><p><a href="https://medium.com/hong-kong-open-source/docker-image-%E7%94%A8%E9%82%A3%E5%80%8B%E7%89%88%E6%9C%AC-496fb9dd97e4">Docker Image 用那個版本？</a></p><h3>正式運作</h3><p>東西都設定好了就可以運作了，只要用指令 sudo docker-compose up 就可以開始運作</p><pre>Creating 256pages-blog ... done Attaching to 256pages-blog ... 256pages-blog | [2018-07-27 09:20:03] INFO Ctrl+C to shut down 256pages-blog | [2018-07-27 09:20:03] INFO Ghost boot 4.801s</pre><p>測試過沒有問題按 Ctrl + C 退出<br> 然後就可以正式運作，在最後加上 -d 就可以保持一直運作！<br> sudo docker-compose up -d</p><blockquote><em>那麼網址怎麼辦？</em></blockquote><p>網址要靠 nginx proxy 去解決<br> 下回再教用 docker-compose 部署 nginx proxy 同時自動申請免費 SSL 證書！</p><p><em>Originally published at </em><a href="https://blog.256pages.com/docker-compose-ghost/"><em>blog.256pages.com</em></a><em> on July 27, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d00380c24d4e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hong-kong-tech/%E4%BD%BF%E7%94%A8-docker-compose-%E5%BF%AB%E9%80%9F%E5%BB%BA%E7%AB%8B-ghost-d00380c24d4e">使用 Docker Compose 快速建立 Ghost</a> was originally published in <a href="https://medium.com/hong-kong-tech">HKIT DOG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>