add dev_type select
Browse files- README.md +45 -2
- pyclip/gradio_example.py +6 -3
README.md
CHANGED
|
@@ -87,7 +87,50 @@ pip install -r pyclip/requirements.txt
|
|
| 87 |
|
| 88 |
#### Inference with AX650 Host, such as M4N-Dock(็ฑ่ฏๆดพPro)
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
#### Inference with M.2 Accelerator card
|
| 93 |
[What is M.2 Accelerator card?](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_guide_hardware.html), Show this DEMO based on Raspberry PI 5.
|
|
@@ -96,7 +139,7 @@ TODO
|
|
| 96 |
(py312) axera@raspberrypi:~/samples/AXERA-TECH/libclip.axera $ export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libstdc++.so.6
|
| 97 |
(py312) axera@raspberrypi:~/samples/AXERA-TECH/libclip.axera $ cp install/lib/aarch64/libclip.so pyclip/
|
| 98 |
(py312) axera@raspberrypi:~/samples/AXERA-TECH/libclip.axera $ tar xf coco_1000.tar
|
| 99 |
-
(py312) axera@raspberrypi:~/samples/AXERA-TECH/libclip.axera $ python pyclip/gradio_example.py --ienc cnclip/cnclip_vit_l14_336px_vision_u16u8.axmodel --tenc cnclip/cnclip_vit_l14_336px_text_u16.axmodel --vocab cnclip/cn_vocab.txt --isCN 1 --db_path clip_feat_db_coco --image_folder coco_1000/
|
| 100 |
Trying to load: /home/axera/samples/AXERA-TECH/libclip.axera/pyclip/aarch64/libclip.so
|
| 101 |
|
| 102 |
โ Failed to load: /home/axera/samples/AXERA-TECH/libclip.axera/pyclip/aarch64/libclip.so
|
|
|
|
| 87 |
|
| 88 |
#### Inference with AX650 Host, such as M4N-Dock(็ฑ่ฏๆดพPro)
|
| 89 |
|
| 90 |
+
```
|
| 91 |
+
root@ax650:~/sample/LibClip# cp ./install/lib/host_650/libclip.so ./pyclip/
|
| 92 |
+
root@ax650:~/sample/LibClip# tar -xf coco_1000.tar
|
| 93 |
+
root@ax650:~/sample/LibClip# python3 pyclip/gradio_example.py --ienc cnclip/cnclip_vit_l14_336px_vision_u16u8.axmodel --tenc cnclip/cnclip_vit_l14_336px_text_u16.axmodel --vocab cnclip/cn_vocab.txt --isCN 1 --db_path clip_feat_db_coco --image_folder coco_1000/ --dev_type host
|
| 94 |
+
Trying to load: /root/sample/LibClip/pyclip/aarch64/libclip.so
|
| 95 |
+
|
| 96 |
+
โ Failed to load: /root/sample/LibClip/pyclip/aarch64/libclip.so
|
| 97 |
+
/root/sample/LibClip/pyclip/aarch64/libclip.so: cannot open shared object file: No such file or directory
|
| 98 |
+
๐ File not found. Please verify that libclip.so exists and the path is correct.
|
| 99 |
+
|
| 100 |
+
Trying to load: /root/sample/LibClip/pyclip/libclip.so
|
| 101 |
+
open libaxcl_rt.so failed
|
| 102 |
+
unsupport axcl
|
| 103 |
+
โ
Successfully loaded: /root/sample/LibClip/pyclip/libclip.so
|
| 104 |
+
sh: line 1: axcl-smi: command not found
|
| 105 |
+
ๅฏ็จ่ฎพๅค: {'host': {'available': True, 'version': 'V3.6.2_20250731140456', 'mem_info': {'remain': 9963, 'total': 10240}}, 'devices': {'host_version': '', 'dev_version': '', 'count': 0, 'devices_info': []}}
|
| 106 |
+
|
| 107 |
+
input size: 1
|
| 108 |
+
name: image [unknown] [unknown]
|
| 109 |
+
1 x 3 x 336 x 336
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
output size: 1
|
| 113 |
+
name: unnorm_image_features
|
| 114 |
+
1 x 768
|
| 115 |
+
|
| 116 |
+
[I][ load_image_encoder][ 50]: nchw 336 336
|
| 117 |
+
[I][ load_image_encoder][ 60]: image feature len 768
|
| 118 |
+
|
| 119 |
+
input size: 1
|
| 120 |
+
name: text [unknown] [unknown]
|
| 121 |
+
1 x 52
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
output size: 1
|
| 125 |
+
name: unnorm_text_features
|
| 126 |
+
1 x 768
|
| 127 |
+
|
| 128 |
+
[I][ load_text_encoder][ 44]: text feature len 768
|
| 129 |
+
[I][ load_tokenizer][ 60]: text token len 52
|
| 130 |
+
100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 1000/1000 [01:43<00:00, 9.70it/s]
|
| 131 |
+
* Running on local URL: http://0.0.0.0:7860
|
| 132 |
+
```
|
| 133 |
+
If your M4N-Dock(็ฑ่ฏๆดพPro) IP Address is 192.168.1.100, so using this URL `http://192.168.1.100:7860` with your WebApp
|
| 134 |
|
| 135 |
#### Inference with M.2 Accelerator card
|
| 136 |
[What is M.2 Accelerator card?](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_guide_hardware.html), Show this DEMO based on Raspberry PI 5.
|
|
|
|
| 139 |
(py312) axera@raspberrypi:~/samples/AXERA-TECH/libclip.axera $ export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libstdc++.so.6
|
| 140 |
(py312) axera@raspberrypi:~/samples/AXERA-TECH/libclip.axera $ cp install/lib/aarch64/libclip.so pyclip/
|
| 141 |
(py312) axera@raspberrypi:~/samples/AXERA-TECH/libclip.axera $ tar xf coco_1000.tar
|
| 142 |
+
(py312) axera@raspberrypi:~/samples/AXERA-TECH/libclip.axera $ python pyclip/gradio_example.py --ienc cnclip/cnclip_vit_l14_336px_vision_u16u8.axmodel --tenc cnclip/cnclip_vit_l14_336px_text_u16.axmodel --vocab cnclip/cn_vocab.txt --isCN 1 --db_path clip_feat_db_coco --image_folder coco_1000/ --dev_type axcl
|
| 143 |
Trying to load: /home/axera/samples/AXERA-TECH/libclip.axera/pyclip/aarch64/libclip.so
|
| 144 |
|
| 145 |
โ Failed to load: /home/axera/samples/AXERA-TECH/libclip.axera/pyclip/aarch64/libclip.so
|
pyclip/gradio_example.py
CHANGED
|
@@ -15,20 +15,23 @@ if __name__ == '__main__':
|
|
| 15 |
parser.add_argument('--isCN', type=int, default=1)
|
| 16 |
parser.add_argument('--db_path', type=str, default='clip_feat_db_coco')
|
| 17 |
parser.add_argument('--image_folder', type=str, default='coco_1000')
|
|
|
|
| 18 |
args = parser.parse_args()
|
| 19 |
|
| 20 |
image_folder = args.image_folder
|
|
|
|
| 21 |
|
| 22 |
# ๅๅงๅ
|
| 23 |
print("ๅฏ็จ่ฎพๅค:", enum_devices())
|
| 24 |
-
sys_init(
|
| 25 |
|
| 26 |
clip = Clip({
|
| 27 |
'text_encoder_path': args.tenc,
|
| 28 |
'image_encoder_path': args.ienc,
|
| 29 |
'tokenizer_path': args.vocab,
|
| 30 |
'db_path': args.db_path,
|
| 31 |
-
'isCN': args.isCN
|
|
|
|
| 32 |
})
|
| 33 |
|
| 34 |
|
|
@@ -77,4 +80,4 @@ if __name__ == '__main__':
|
|
| 77 |
|
| 78 |
# ๅ
ณ้ญ็ณป็ป๏ผไฝ ๅฏๅ ไฟกๅทๅค็ๆฅ่ชๅจๅ
ณ้ญ๏ผ
|
| 79 |
import atexit
|
| 80 |
-
atexit.register(lambda: sys_deinit(ClipDeviceType.
|
|
|
|
| 15 |
parser.add_argument('--isCN', type=int, default=1)
|
| 16 |
parser.add_argument('--db_path', type=str, default='clip_feat_db_coco')
|
| 17 |
parser.add_argument('--image_folder', type=str, default='coco_1000')
|
| 18 |
+
parser.add_argument('--dev_type', type=str, default='host', help='host or axcl')
|
| 19 |
args = parser.parse_args()
|
| 20 |
|
| 21 |
image_folder = args.image_folder
|
| 22 |
+
device = ClipDeviceType.host_device if args.dev_type == 'host' else ClipDeviceType.axcl_device
|
| 23 |
|
| 24 |
# ๅๅงๅ
|
| 25 |
print("ๅฏ็จ่ฎพๅค:", enum_devices())
|
| 26 |
+
sys_init(device, 0)
|
| 27 |
|
| 28 |
clip = Clip({
|
| 29 |
'text_encoder_path': args.tenc,
|
| 30 |
'image_encoder_path': args.ienc,
|
| 31 |
'tokenizer_path': args.vocab,
|
| 32 |
'db_path': args.db_path,
|
| 33 |
+
'isCN': args.isCN,
|
| 34 |
+
'dev_type': device,
|
| 35 |
})
|
| 36 |
|
| 37 |
|
|
|
|
| 80 |
|
| 81 |
# ๅ
ณ้ญ็ณป็ป๏ผไฝ ๅฏๅ ไฟกๅทๅค็ๆฅ่ชๅจๅ
ณ้ญ๏ผ
|
| 82 |
import atexit
|
| 83 |
+
atexit.register(lambda: sys_deinit(ClipDeviceType.host_device, 0))
|