asdff
Adetailer Stable Diffusion diFFusers pipeline
예시
from pip install
pip install asdff
import torch
from asdff import AdPipeline
pipe = AdPipeline.from_pretrained("stablediffusionapi/counterfeit-v30", torch_dtype=torch.float16)
pipe.safety_checker = None
pipe.to("cuda")
common = {"prompt": "masterpiece, best quality, 1girl", "num_inference_steps": 28}
result = pipe(common=common)
images = result[0]
from custom pipeline
ultralytics 설치 필요
pip install ultralytics
import torch
from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained(
"stablediffusionapi/counterfeit-v30",
torch_dtype=torch.float16,
custom_pipeline="Bingsu/adsd_pipeline"
)
pipe.safety_checker = None
pipe.to("cuda")
common = {"prompt": "masterpiece, best quality, 1girl", "num_inference_steps": 28}
result = pipe(common=common)
images = result[0]
그 외
스케줄러를 변경하고, 입력 이미지를 제공하는 예시
import torch
from asdff import AdPipeline
from diffusers import DPMSolverMultistepScheduler
from diffusers.utils import load_image
pipe = AdPipeline.from_pretrained("stablediffusionapi/counterfeit-v30", torch_dtype=torch.float16)
pipe.safety_checker = None
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cuda")
common = {"prompt": "masterpiece, best quality, 1girl", "num_inference_steps": 20}
images = load_image("https://i.imgur.com/8TX2AX6.png")
result = pipe(common=common, images=[images])
arguments
common: Mapping[str, Any] | None
txt2img와 inpaint에서 공통적으로 사용할 인자들
txt2img_only: Mapping[str, Any] | None
txt2img에서만 사용할 인자. common과 겹치는 인자는 덮어씁니다.
inpaint_only: Mapping[str, Any] | None
inpaint에서만 사용할 인자. common과 겹치는 인자는 덮어씁니다.
strength: 0.4가 기본값으로 적용됩니다.
StableDiffusionInpaintPipeline.call
images: Image | Iterable[Image] | None
inpaint를 수행할 이미지들. 주어지면 txt2img의 결과를 대체하기 때문에 txt2img_only는 무시됩니다.
detectors: DetectorType | Iterable[DetectorType] | None
DetectorType: Callable[[Image.Image], Optional[List[Image.Image]]]
pil Image를 입력으로 받아 마스크 이미지의 리스트(마스크), 또는 None을 반환하는 Callable.
그런 Callable 하나, Callable의 리스트 또는 None
None일경우, default_detector가 사용됩니다.
from asdff import AdPipeline
pipe = AdPipeline.from_pretrained(...)
pipe.default_detector
>>> <function asdff.yolo.yolo_detector(image: 'Image.Image', model_path: 'str | None' = None, confidence: 'float' = 0.3) -> 'list[Image.Image] | None'>
사용 예시
from functools import partial
import torch
from asdff import AdPipeline, yolo_detector
from huggingface_hub import hf_hub_download
pipe = AdPipeline.from_pretrained("stablediffusionapi/counterfeit-v30", torch_dtype=torch.float16)
pipe.safety_checker = None
pipe.to("cuda")
person_model_path = hf_hub_download("Bingsu/adetailer", "person_yolov8s-seg.pt")
person_detector = partial(yolo_detector, model_path=person_model_path)
common = {"prompt": "masterpiece, best quality, 1girl", "num_inference_steps": 28}
result = pipe(common=common, detectors=[person_detector, pipe.default_detector])
result
mask_dilation: int, default = 4
마스크 감지 후, cv2.dilate 함수를 적용해 마스크 영역을 키우는 데, 이 때 적용할 커널의 크기.
mask_blur: int, default = 4
dilation 후 적용할 가우시안 블러의 커널 크기.
mask_padding: int, default = 32
dilation 적용 후 이 값만큼 bbox의 가로세로 영역을 더해서 이미지를 자른 뒤, inpaint를 시도하게 됩니다.
Metadata
Release files for asdff 0.2.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 |
|---|---|---|---|---|
| asdff-0.2.1.tar.gz | 19.3 kB | Without provenance | Details for asdff-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asdff-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for asdff-0.2.1-py3-none-any.whl |
Total release size: 38.3 kB
Release files / asdff-0.2.1.tar.gz
| Download URL | asdff-0.2.1.tar.gz |
|---|---|
| Size | 19.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
311b09b52d904b89c341fbea12657b53de497768fa49d07bc185ff6c1b18cc4d
|
|
BLAKE2b-256 checksum How to use checksums |
95f92f013ec57e9385b4102d6a8164fd3262c26afe530117d5ceeebc39d15435
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.9.3 CPython/3.11.6
|
Release files / asdff-0.2.1-py3-none-any.whl
| Download URL | asdff-0.2.1-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
766e682b531ba4fb83c008a0924c94074e8702ef3afa907dbd82919471e74cc8
|
|
BLAKE2b-256 checksum How to use checksums |
2d7a3469c5883e831344fac9c3ffc530ec30f66688845277fc459d73f27de849
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.9.3 CPython/3.11.6
|
Security for asdff 0.2.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.