-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(text-to-image): integrate NSFW safety checker #76
Conversation
cbb01b7
to
5f379e3
Compare
@dob, @yondonfu, @eliteprox, @ad-astra-video, this feature was introduced following a request from CJ on Discord, addressing concerns about NSFW images being generated via their apps. I’d appreciate your insights on integrating this safety check into our pipelines. Additionally, I'm considering whether to include an input check in the |
Without reviewing the code, my instinct would be that it would be an option at the pipeline (job type) level, so that users can decide whether they want the filter on or off. My first thought is that the filter would be on by default unless an app decides to override that by passing in the argument to disable the check.
…________________________________
From: Rick Staa ***@***.***>
Sent: Monday, May 6, 2024 8:18:39 AM
To: livepeer/ai-worker ***@***.***>
Cc: Doug Petkanics ***@***.***>; Mention ***@***.***>
Subject: Re: [livepeer/ai-worker] feat(text-to-image): integrate NSFW safety checker (PR #76)
@dob<https://github.com/dob>, @yondonfu<https://github.com/yondonfu>, @eliteprox<https://github.com/eliteprox>, @ad-astra-video<https://github.com/ad-astra-video>, this feature was introduced following a request from CJ on Discord, addressing concerns about NSFW images being generated via their apps. I’d appreciate your insights on integrating this safety check into our pipelines. Additionally, I'm considering whether to include an input check in the text-to-video pipeline or if it should remain the responsibility of the dApp. What are your thoughts on this matter?
—
Reply to this email directly, view it on GitHub<#76 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAACRFJDVGCUL3UY3DC5QODZA5YJ7AVCNFSM6AAAAABHH5K6ISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJVG42DSMRTGI>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
5f379e3
to
47e1eb8
Compare
This commit incorporates the CompVis/stable-diffusion-safety-checker into the text-to-image and image-to-image pipelines. By enabling the `safety_check` input variable, users get notified of the generation of NSFW images.
47e1eb8
to
8357c60
Compare
This commit enables the safety checker by default. For more information about this decision see #76 (comment).
This commit enables the safety checker by default. For more information about this decision see #76 (comment).
7eb69f6
to
6e860a5
Compare
This commit enables the NSFW filter on the AI Subnet that has been implement at the runner side in livepeer/ai-worker#76. BREAKING CHANGE: Depending on how dApps interact with the subnet this could be a breaking change given that we return an extra `nsfw` property.
This commit enables the NSFW filter on the AI Subnet that has been implement at the runner side in livepeer/ai-worker#76. BREAKING CHANGE: Depending on how dApps interact with the subnet this could be a breaking change given that we return an extra `nsfw` property.
This commit enables the NSFW filter on the AI Subnet that has been implement at the runner side in livepeer/ai-worker#76. BREAKING CHANGE: Depending on how dApps interact with the subnet this could be a breaking change given that we return an extra `nsfw` property.
This commit enables the NSFW filter on the AI Subnet that has been implement at the runner side in livepeer/ai-worker#76. BREAKING CHANGE: Depending on how dApps interact with the subnet this could be a breaking change given that we return an extra `nsfw` property.
This pull request integrates the CompVis/stable-diffusion-safety-checker into the
text-to-image
andimage-to-image
pipelines. By enabling thesafety_check
input variable, users can detect the generation of NSFW images. The feature is enabled by default on Orchestrators, but they can opt to perform the safety check on the CPU using theSAFETY_CHECKER_DEVICE
environment variable to conserve VRAM, though this may slow down operations.I have decided against implementing this feature in the
image-to-video
pipeline as checking each frame would introduce significant latency, and I believe responsibility for checking the input image should lie with the dApp. However, I can readily add a check on the input image if desired.Performance Results
T2I pipeline
Benchmarking was conducted to assess how the new feature impacts inference speed and VRAM usage:
Commands:
and
Original Metrics:
pipeline load time: 1.664s pipeline load max GPU memory allocated: 4.824GiB pipeline load max GPU memory reserved: 4.904GiB avg inference time: 0.635s avg inference time per output: 0.212s avg inference max GPU memory allocated: 7.651GiB avg inference max GPU memory reserved: 9.521GiB
With Safety Checker (GPU, safety_check not set):
pipeline load time: 2.586s pipeline load max GPU memory allocated: 5.966GiB pipeline load max GPU memory reserved: 6.025GiB avg inference time: 0.632s avg inference time per output: 0.211s avg inference max GPU memory allocated: 8.793GiB avg inference max GPU memory reserved: 10.623GiB
With Safety Checker (GPU, safety_check set):
pipeline load time: 2.279s pipeline load max GPU memory allocated: 5.966GiB pipeline load max GPU memory reserved: 6.025GiB avg inference time: 0.695s avg inference time per output: 0.232s avg inference max GPU memory allocated: 8.793GiB avg inference max GPU memory reserved: 10.623GiB
With Safety Checker (CPU, safety_check not set):
pipeline load time: 2.245s pipeline load max GPU memory allocated: 4.824GiB pipeline load max GPU memory reserved: 4.904GiB avg inference time: 0.640s avg inference time per output: 0.213s avg inference max GPU memory allocated: 7.651GiB avg inference max GPU memory reserved: 9.521GiB
With Safety Checker (CPU, safety_check set):
pipeline load time: 2.203s pipeline load max GPU memory allocated: 4.832GiB pipeline load max GPU memory reserved: 4.895GiB avg inference time: 1.233s avg inference time per output: 0.411s avg inference max GPU memory allocated: 7.659GiB avg inference max GPU memory reserved: 9.512GiB
I2I pipeline
Benchmarking was conducted to assess how the new feature impacts inference speed and VRAM usage:
Commands:
and
Original Metrics:
pipeline load time: 1.672s pipeline load max GPU memory allocated: 4.825GiB pipeline load max GPU memory reserved: 4.900GiB avg inference time: 4.179s avg inference time per output: 1.393s avg inference max GPU memory allocated: 16.092GiB avg inference max GPU memory reserved: 20.023GiB
With Safety Checker (GPU, safety_check not set):
pipeline load time: 2.347s pipeline load max GPU memory allocated: 5.966GiB pipeline load max GPU memory reserved: 6.025GiB avg inference time: 4.115s avg inference time per output: 1.372s avg inference max GPU memory allocated: 17.233GiB avg inference max GPU memory reserved: 21.129GiB
With Safety Checker (GPU, safety_check set):
pipeline load time: 2.404s pipeline load max GPU memory allocated: 5.959GiB pipeline load max GPU memory reserved: 6.045GiB avg inference time: 4.220s avg inference time per output: 1.407s avg inference max GPU memory allocated: 17.225GiB avg inference max GPU memory reserved: 21.148GiB
With Safety Checker (CPU, safety_check not set):
pipeline load time: 2.297s pipeline load max GPU memory allocated: 4.833GiB pipeline load max GPU memory reserved: 4.900GiB avg inference time: 4.200s avg inference time per output: 1.400s avg inference max GPU memory allocated: 16.100GiB avg inference max GPU memory reserved: 20.004GiB
With Safety Checker (CPU, safety_check set):
pipeline load time: 2.259s pipeline load max GPU memory allocated: 4.833GiB pipeline load max GPU memory reserved: 4.900GiB avg inference time: 4.860s avg inference time per output: 1.620s avg inference max GPU memory allocated: 16.100GiB avg inference max GPU memory reserved: 20.004GiB
Conclusion
From the results, we can conclude that the new feature:
safety_check
increases inference time by about 20ms on the GPU.safety_check
on the CPU increases inference time significantly, by about 200ms.