fry-bisenetv2
fry-bisenetv2 是一个 BiSeNetV2 语义分割推理包。安装后可以在 Python 中调用 FryBisenetV2Predictor,也可以用命令行 fry-bisenetv2 对单张图片或图片目录做推理。
模型权重 .pth 不会随 pip 包发布,需要使用者自己提供训练好的权重文件。
安装
本地开发安装:
pip install -e .[dev]
普通安装:
pip install fry-bisenetv2
如果还没有发布到 PyPI,可以先从当前项目目录安装:
pip install .
快速使用
from fry_bisenetv2 import FryBisenetV2Predictor
predictor = FryBisenetV2Predictor(
pth_path="path/to/segmentation_bisenetv2.pth",
real_seg_class_dict={
1: "dinosaur",
2: "obstacle",
3: "bird",
},
imgSize_train_dict={"width": 1024, "height": 1024},
confidence=0.5,
input_channels=3,
)
result = predictor.predict_single_image(
img_path="path/to/input.jpg",
save_visualization=True,
save_json=True,
answer_json_dir="outputs",
input_channels=3,
)
print(result)
旧导入方式仍然兼容:
from bisenetv2_predict import FryBisenetV2Predictor
命令行使用
先准备类别文件,例如 examples/classes.json:
{
"1": "dinosaur",
"2": "obstacle",
"3": "bird"
}
单张图片推理:
fry-bisenetv2 ^
--weights path/to/segmentation_bisenetv2.pth ^
--input path/to/input.jpg ^
--classes examples/classes.json ^
--img-width 1024 ^
--img-height 1024 ^
--output-dir outputs
图片目录批量推理:
fry-bisenetv2 ^
--weights path/to/segmentation_bisenetv2.pth ^
--input path/to/images ^
--classes examples/classes.json ^
--img-width 1024 ^
--img-height 1024 ^
--output-dir outputs
输出结果
predict_single_image() 返回类似下面的字典:
{
"num": 1,
"cls": [1],
"names": ["dinosaur"],
"conf": 0.93,
"shapes": [
{
"class_num": 1,
"label": "dinosaur",
"probability": 0.93,
"points": [[10, 20], [11, 20], [12, 21]]
}
]
}
其中 points 是映射回原图坐标系的轮廓点。
示例
核心说明
类的关键参数、推理流程、输出结构和注意事项见:
测试
pytest
当前测试覆盖:
- 公共导入入口;
- CLI 类别解析和图片路径收集;
- letterbox resize/补边逻辑;
- 分割结果轮廓生成;
- 可视化绘制。
打包
构建 wheel 和 sdist:
python -m build
构建结果会出现在 dist/ 目录。
发布到 PyPI 前建议检查:
python -m twine check dist/*
发布到 TestPyPI:
python -m twine upload --repository testpypi dist/*
发布到正式 PyPI:
python -m twine upload dist/*
Metadata
Release files for fry-bisenetv2 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fry_bisenetv2-0.1.1.tar.gz | 24.1 kB | Without provenance | Details for fry_bisenetv2-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fry_bisenetv2-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for fry_bisenetv2-0.1.1-py3-none-any.whl |
Total release size: 46.1 kB
Release files / fry_bisenetv2-0.1.1.tar.gz
| Download URL | fry_bisenetv2-0.1.1.tar.gz |
|---|---|
| Size | 24.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e72f7bde723192581536107f4c1005a58c2d78fddb285ad4414dbc87e978288
|
|
BLAKE2b-256 checksum How to use checksums |
bb45462c4d66a18632ade2625319d8b4203ea737a892903f7f7251728cbbe3c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / fry_bisenetv2-0.1.1-py3-none-any.whl
| Download URL | fry_bisenetv2-0.1.1-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30959aebbb73741030f2b324c4142fa6195fbaede03faba25096fcdbf55d1779
|
|
BLAKE2b-256 checksum How to use checksums |
cc43cf1aae6cd047fe54c3396ec1af9b949e06021ad634e8607ad0f906e0e830
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for fry-bisenetv2 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.