满屏文字水印(watermark_node.py): - 文案/字体/字号/旋转角度/密度/字间距/透明度/颜色 八项可调 - 交错网格平铺后整体旋转再从中心裁切,任意角度下四角均无空白 FeyNobg 抠图(feynobg_node.py + feynobg/): - 内嵌 nobg 推理子集(Apache-2.0),全自动去背景,输出 alpha 与去背景图 - 重写预处理去掉对 transformers>=5.4 的依赖,4.x 环境可直接使用 - 修复权重键名与 transformers 4.x 的 SwinBackbone 命名不兼容: 不处理时 958 个参数仅 405 个对得上,backbone 形同随机初始化, 模型不报错但 alpha 几乎全黑;现按环境自动重映射并严格校验, 除确定性 buffer 外任何失配都直接中止 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
65 lines
1.4 KiB
Python
65 lines
1.4 KiB
Python
from functools import wraps
|
|
|
|
|
|
# update docs for specific functions
|
|
def set_doc(doc):
|
|
def decorator(func):
|
|
@wraps(func)
|
|
def wrapper(*args, **kwargs):
|
|
return func(*args, **kwargs)
|
|
|
|
wrapper.__doc__ = doc
|
|
return wrapper
|
|
|
|
return decorator
|
|
|
|
|
|
# general template for models
|
|
def model_card_template(
|
|
*, class_name: str, default_repo: str, citation: str | None = None
|
|
) -> str:
|
|
citation_section = (
|
|
f"""
|
|
## Citation
|
|
If you use this model, please cite:
|
|
```bibtex
|
|
{citation}
|
|
```
|
|
"""
|
|
if citation
|
|
else ""
|
|
)
|
|
return f"""---
|
|
{{{{ card_data }}}}
|
|
---
|
|
|
|
<p align="center">
|
|
<img src="https://usefeyn.com/feyn/feyn_mark.svg"/>
|
|
</p>
|
|
|
|
This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration.
|
|
|
|
Library: [nobg]({{{{repo_url}}}})
|
|
|
|
## how to load
|
|
```
|
|
pip install nobg
|
|
```
|
|
|
|
use the AutoModel class
|
|
```python
|
|
from nobg import AutoModel
|
|
model = AutoModel.from_pretrained("{{{{ repo_id | default("{default_repo}", true) }}}}")
|
|
```
|
|
or you can use the model class directly
|
|
```python
|
|
from nobg import {class_name}
|
|
model = {class_name}.from_pretrained("{{{{ repo_id | default("{default_repo}", true) }}}}")
|
|
```
|
|
|
|
{citation_section}
|
|
## Contributions
|
|
Any contributions are welcome at https://github.com/feyninc/nobg
|
|
|
|
"""
|