Download tools/test_channel.py from voidljc/cherrydata: direct link, hf CLI and curl.
- Browser
- Download file 649 Bytes
-
https://huggingface.co/voidljc/cherrydata/resolve/main/tools/test_channel.py
- Command line
-
hf download hf://voidljc/cherrydata/tools/test_channel.py
-
curl -L -o test_channel.py https://huggingface.co/voidljc/cherrydata/resolve/main/tools/test_channel.py
649 Bytes
| # import cv2 | |
| # # 读取图片 | |
| # img = cv2.imread("/home/lab/LJ/wampee/Wampee_dataSets__Voc_Sec/JPEGImages/2024_07_10_09_47_IMG_9327_part1.png") | |
| # print("图片 shape:", img.shape) # 例如 (height, width, channels) | |
| from PIL import Image | |
| # 打开图片 | |
| img = Image.open("/home/lab/LJ/wampee/Wampee_dataSets__Voc_Sec/JPEGImages/2024_07_10_09_47_IMG_9327_part1.png") | |
| # 打印图片模式 | |
| print("图片模式:", img.mode) | |
| # 根据模式判断通道数 | |
| if img.mode == "RGB": | |
| channels = 3 | |
| elif img.mode == "RGBA": | |
| channels = 4 | |
| elif img.mode == "L": | |
| channels = 1 | |
| else: | |
| channels = "未知" | |
| print("图片通道数:", channels) | |