2025/5/3

亂記一些

這邊是有關 deepwiki-open:

從Dockerfil 看到 python 是 3.11
python 啟動的是 backend server,用 npm run 啟動的是 fron-end.
fron end 原來 listen on localhost,用 npm run 的 command:
npm run dev -- -H 0.0.0.0
就可以改到 public ip
使用 docker compose up 的話,使用 ollam 時,要修改:
diff --git a/docker-compose.yml b/docker-compose.yml
index a7d42c3..b1d85d3 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,6 +3,7 @@ version: '3.8'
 services:
   deepwiki:
     build: .
+    network_mode: host
     ports:
       - "${PORT:-8001}:${PORT:-8001}"  # API port
       - "3000:3000"  # Next.js port
把 contrainer 的 localhost:11434 使用 host 的,才能跟 ollama 連接。

原來他的 front-end, ts code,連到 localhost,所以是連到 browser 所在主機的 localhost,不是 server ...
所以要 修改 client side 的 SERVER_BASE_URL,用 server 的 ip:
diff --git a/docker-compose.yml b/docker-compose.yml
index a7d42c3..210e476 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,6 +3,7 @@ version: '3.8'
 services:
   deepwiki:
     build: .
     ports:
       - "${PORT:-8001}:${PORT:-8001}"  # API port
       - "3000:3000"  # Next.js port
@@ -11,6 +12,6 @@ services:
     environment:
       - PORT=${PORT:-8001}
       - NODE_ENV=production
-      - NEXT_PUBLIC_SERVER_BASE_URL=http://localhost:${PORT:-8001}
+      - NEXT_PUBLIC_SERVER_BASE_URL=http://192.168.145.77:${PORT:-8001}
     volumes:
       - ~/.adalflow:/root/.adalflow  # Persist repository and embedding data
發現沒辦法support gitlab 的 subgroup,因為會和產生的 page 的 path 混在一起,而 source code 的result http server 頁面是依照source path 安排的。
更新後發現支援 local path,所以就 clone 到 local disk 後再給 path 就可以。
這邊的 local 又變成 server 的 local,不是 browser 的 local。
所以都要在 run 的那台 server 上clone source 之後,給 full path.


  • DeepWiki opensource implement
  • huggingface agent : smolagents, E2B Desktop, Qwen2-VL-72B-Instruct
  • LTX-Video : ComfyUI
  • uv




還有今天apt update/upgrade 後,lcd backlight 又失效了。
然後進入additional driver 設定想換 driver 出現 Error。
要反悔又不行。
一直出現 要 apt --fix-broken install
但是又會出現 overwrite error /var/.../*.deb,
所以只好 follow stackoverflow 說明,用 apt -i --force-overwrite /var/..../*.deb 來強制 install
sudo dpkg --force-overwrite /var/cache/apt/archives/libnvidia-common-570-server_570.133.20-0ubuntu0.24.04.1_all.deb
最後還是 fail 因為unpack 某個 deb 出現 /usr/share/nvidia/files.d/sandboxutils-filelist.json 無法overwrite,
去看這個是 folder ,所以無法 overwrite,rename 後就可以了,然後那個 deb 就 create 了一個同名 file。
繼續 apt fix,出現 error,照次說 sandboxutils-filelist.json 無法 rmdif,--- 因為他是 file 呀!
所以就去把 file 刪掉,把剛剛rename 的 folder rename 回來。
才完成 fix
查 sandboxutils-filelist.json 目錄下有一個同名檔案,他的內容跟 file 的內容是一致的。
髓以我猜某一個 deb 稿錯了。

然後剛剛又 apt update, apt list --upgradable 看到 cuda-driver 有更新 575....
所以是更新成 575 造成 ? 還是要更新 575 才會 fix ?



要用 transformer run phi4-multimodal 要 install flash-attention:
pip install flash-attn --no-build-isolation
然後會用 cicc build 很久...

另外還要:
soundfile peft backoff 
結果phi4-multimodal 太大... 超過 24G..



enable conda in powershell,要 run
PS C:\Users\charles.chang> conda init powershell
no change     D:\miniconda\Scripts\conda.exe
no change     D:\miniconda\Scripts\conda-env.exe
no change     D:\miniconda\Scripts\conda-script.py
no change     D:\miniconda\Scripts\conda-env-script.py
no change     D:\miniconda\condabin\conda.bat
no change     D:\miniconda\Library\bin\conda.bat
no change     D:\miniconda\condabin\_conda_activate.bat
no change     D:\miniconda\condabin\rename_tmp.bat
no change     D:\miniconda\condabin\conda_auto_activate.bat
no change     D:\miniconda\condabin\conda_hook.bat
no change     D:\miniconda\Scripts\activate.bat
no change     D:\miniconda\condabin\activate.bat
no change     D:\miniconda\condabin\deactivate.bat
modified      D:\miniconda\Scripts\activate
modified      D:\miniconda\Scripts\deactivate
modified      D:\miniconda\etc\profile.d\conda.sh
modified      D:\miniconda\etc\fish\conf.d\conda.fish
no change     D:\miniconda\shell\condabin\Conda.psm1
modified      D:\miniconda\shell\condabin\conda-hook.ps1
no change     D:\miniconda\Lib\site-packages\xontrib\conda.xsh
modified      D:\miniconda\etc\profile.d\conda.csh
modified      D:\OneDrive\OneDrive - Royaltek\文件\WindowsPowerShell\profile.ps1

==> For changes to take effect, close and re-open your current shell. <==

2025/4/15

RK3588 MP520

black 在 pchome 買的 rk3588 板子。
打開蓋子有 maskrom button,所以一樣可以 boot to maskrom
然後 rkdevtool 看得到。

但是官方沒有提供 image file,所以不敢亂燒。
看論壇說 kernel source 是用 apt-get source 的方式提供的,但是我只有找到 dtb 和 header. 沒有source (GPL...疑慮)
只好用預燒的 image 開機,是 debian.
UI 還好算流暢,不會像 pi 用 gui 那樣很頓。
可以用 chromium 看 youtub, hd OK, 4k 會卡,然後 cpu 超熱 (沒有使用 hardware codec ?)
用 top 看有一個 pipewire process 一直吃掉一個核...

因為不能動image,也沒有 uboot, kernel source,所以只好試試看 npu。
follow : ArmSoM Wiki: rknn-sdk
one@MB127:~$ dmesg | grep -i rknpu
...
[    4.532693] [drm] Initialized rknpu 0.9.6 20240322 for fdab0000.npu on minor 1
所以 kernel 有 enable rknpu
照著做,啟動 rknn_server 之後,把 *.rknn 轉好 scp 過去。
然後run:
(toolkit2) one@MB127:~/projects/rknn_model_zoo/examples/yolov5/python$ python yolov5.py --model_path ~/yolov5s_relu.onnx --img_show
use anchors from '../model/anchors_yolov5.txt', which is [[[10.0, 13.0], [16.0, 30.0], [33.0, 23.0]], [[30.0, 61.0], [62.0, 45.0], 
[59.0, 119.0]], [[116.0, 90.0], [156.0, 198.0], [373.0, 326.0]]]
/home/one/projects/rknn_model_zoo/py_utils/onnx_executor.py:12: FutureWarning: In the future `np.bool` will be defined as the 
corresponding NumPy scalar.
  if getattr(np, 'bool', False):
Model-/home/one/yolov5s_relu.onnx is onnx model, starting val
infer 1/1

IMG: bus.jpg
person @ (208 242 286 508) 0.881
person @ (478 238 560 525) 0.859
person @ (109 237 232 534) 0.842
person @ (79 355 121 515) 0.318
bus  @ (91 129 555 465) 0.702

發生 ssh 連線中斷問題,好像進入 suspend 了...
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: Link is Down
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: FPE workqueue stop
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: Register MEM_TYPE_PAGE_POOL RxQ-0
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: PHY [stmmac-1:01] driver [YT8531 Gigabit Ethernet] (irq=POLL)
[  4? 15 16:59:14 2025] dwmac4: Master AXI performs any burst length
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: No Safety Features support found
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: IEEE 1588-2008 Advanced Timestamp supported
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: registered PTP clock
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: FPE workqueue start
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: configuring for phy/rgmii-rxid link mode
[  4? 15 16:59:14 2025] rk_gmac-dwmac fe1c0000.ethernet end1: FPE workqueue stop
[  4? 15 16:59:15 2025] PM: suspend entry (deep)
[  4? 15 16:59:15 2025] Filesystems sync: 0.015 seconds
大概是no activity suspend,雖然有去 settings 確認關掉,但是還是沒用。
所以只好把所有 systemd 的 suspend service 關掉。
--- 關掉一堆,所以不知道真正有效是哪個。所以沒記。
about source code
ref: MP-520更新發生錯誤
關於MP520 Linux kernel版本的說明:
目前MP520採用的Linux kernel為SoC RK3588S原廠提供的版本加以修改成適合MP520主機板。RK3588S原廠推出新版的速度很慢。
我們會將原廠版本經過修改,並在每一滾動發行版中徹底測試再發佈出來。
另外開源界主流的Mainline linux kernel已有RK3588S版本,但是還只限於終端機文字模式,還很陽春,無法支援圖形視窗介面。
等到Mainline linux kernel的RK3588S版本可以支援圖形視窗時,MP520的Kernel,計劃從Mainline Kernel版本修改而成。
這樣就可以隨時保持最新版本了。不過估計至少還需要一、兩年以上的時間。

about system image
ref: MP520-20 請問有官方 image 的下載點嗎?
沒有,但是提供刷機服務
沒有 sourcecode,也沒有 image,所以只能買一個 nvme ssd 來換了,以免郵寄麻煩..
或是把 nvme ssd 接到 pc 來 DD 備份。
...不曉得有甚麼難處,不然找個 googledrive, mega 之類的放也可以,買的人沒很多,要 download 的人也不會很多吧。
可能 image 不是他們自己 build,他們沒有軟體工程師...

2025/4/12

隨便的 memo ...

沒 train 完的 yolo3,用 coco dataset 來試試看。
-- convert coco to pascal_voc format:
pascal_voc/
├── VOC2012/
│   ├── Annotations/         # XML annotation files
│   ├── ImageSets/
│   │   └── Main/
│   │       └── train.txt    # Training image names
│   └── JPEGImages/         # Image files (.jpg)
│
└── VOC2007/
    ├── Annotations/         # XML annotation files
    ├── ImageSets/
    │   └── Main/
    │       └── test.txt     # Testing image names
    └── JPEGImages/         # Image files (.jpg)
train.txt 是 filename list.
所以 自己去 annotations 找 filename.txt,
到 JPEGImages 找 filename.jpg
要分 train 和 validate。

coco dataset 的format:
一個 imagefolder 配一個 json,裡面有 folder 所有的 image 和 labels

datasets 的format 現在大概有三種
  • pascal_voc
  • coco
  • ultralytic yolo


dataloader( ) 中,參數是 filename list. txt 檔的 path,image folder path,label folder path
所以不用依照pascal_voc 的方式,只要 image,label 分開 folder放就可以。



這個: 說的 "YOLODataset" 就是哪個用空白格開的文字檔 (csv with space)
然後 folder 要依照
.
├── images
│   ├── train
│   └── val
└── labels
    ├── train
    └── val
好像有一個 filelist ..

還是專業的厲害,叫 gemma3:27b 從 dataset.py 找出 train.csv 的格式是什麼,一直鬼打牆說 train.csv 找不到。
換成 github copilot + sonnect 3.5,同樣的 prompt 就回答了(只是不知道鄭不正確):
Based on the code in dataset.py, I can explain how the train.csv file should be structured. The file is used to map image names to their corresponding label files.

The train.csv should contain two columns:
1. Image filename
2. Label filename

Here's an example of how train.csv should look:

```csv
image_name,label_name
image1.jpg,image1.txt
image2.jpg,image2.txt
dog_picture.jpg,dog_picture.txt
car_street.jpg,car_street.txt
```

Key points about the CSV structure:
- The image filenames should correspond to files in the `COCO/images/images/` directory
- The label filenames should correspond to files in the `COCO/labels/labels_new/` directory
- Each label file (.txt) contains the bounding box information in the format: <class_label> <x> <y> <width> <height&ht;`

You can create this CSV file using a simple Python script like this:

````python
import os
import pandas as pd

def create_train_csv(image_dir, label_dir, output_csv):
    image_files = [f for f in os.listdir(image_dir) if f.endswith(('.jpg', '.jpeg', '.png'))]
    data = []
    
    for img_file in image_files:
        # Assume label file has same name but .txt extension
        label_file = os.path.splitext(img_file)[0] + '.txt'
        if os.path.exists(os.path.join(label_dir, label_file)):
            data.append([img_file, label_file])
    
    df = pd.DataFrame(data, columns=['image_name', 'label_name'])
    df.to_csv(output_csv, index=False)

# Example usage
create_train_csv(
    'COCO/images/images/',
    'COCO/labels/labels_new/',
    'COCO/train.csv'
)
````

This script will:
1. Scan the images directory
2. Match image files with their corresponding label files
3. Create a CSV file with the correct format expected by the YOLODataset class

The dataset class then uses this CSV file to load the corresponding image and label pairs during training.
然後 COCO dataset 的 annotation 中 class (category 會到 90),但是只有列出 80 個。
據原始論文說是因為 2014 公佈時,object detection 只有這 80個,另外 10 個是 segmentation 的。
我照著說明,修改在這裡


他自己做好的 5k.part 是 ascii file,裡面是 image file 的 list
...
/images/val2014/COCO_val2014_000000581827.jpg
/images/val2014/COCO_val2014_000000581829.jpg
...
剛好有 5000 個 file

哪個 labels.tgz 其實是 tar,沒有gz
解開就是 YOLO 的 label 格式 txt,每個 image 都有一個。

2025/3/30

Disable Touchpad while Typing

很奇怪,gigabyte 的 AORUS 15X 在 ubuntu 24.04 下,dconf 的 "disable touchpad while typing" 功能竟然沒有用。
所以只好自己(請 gemini) 寫。 用 python 寫的。
停止 typing 到 re-enable touch 的時間有點太長。
但是改短threading.Timer( ) 的時間好像沒用 (resolution 好像不夠)。
叫 gemnini 用 c 寫,他說很複雜,用 kernel driver 他說最好不要。
所以只好將就用這個。

內容很簡單,就是 keyboard listener, on key press, disable touch and enable a timer.
timer timeout 的時候 re-enable touch

2025/3/26

Implement yolov3 from scratch and training

根據 yolov3 from scratch using pytorch 的 code section 整理整合的 code: 使用pascal VOC2012 train 做 training, val 做 validating。
training 500 次:


可以看到大約 56 epochs 的時候就 overfitting 了..

2025/3/14

Zed Editor

聽說可以免費用 Claude sonnet 3.7,所以來用用看。目前 Windows 版安裝檔還沒好,只能 build from source...
所以用 Linux 版。

都是用 keyboard Command.

第一個就是 Ctrl-I 叫出 AI Assistant.
然後問他 Zed 怎麼用..

就這樣,完了。

2025/3/13

miniconda in Windows -- change install, env and pkgs location

在 windows 就是麻煩,C: 沒空間,不能把新 HD mount 進來,不能建link到新 HD.然後一堆app 又一定要用 User/
像 conda 就是。
所以要改 path 很麻煩。

參考 這一篇,在自己的 user 目錄找到 .condarc,修改:
ssl_verify: true
channels:
  - defaults
envs_dirs:
  - D:/minicondaenvs
pkgs_dirs:
  - D:/minicondapkgs
這樣download 下來的 package file 和 create 的 environment 就會在 D:/mini....

修改玩參考 這一篇,可以看conda 有沒有正確依照.condarc:
>conda config --get
--add channels 'defaults'   # lowest priority
--add envs_dirs 'D:/minicondaenvs'
--add pkgs_dirs 'D:/minicondapkgs'
--set ssl_verify True

另外,因為windows 很麻煩,例如D:\Default 就是其他 user 不能寫入修改,所以記得要去 D:/miniconda (安裝目錄),和.condarc 的一堆目錄按右鍵,開啟一般user 的 write 權限。