[Do not merge] Script to compare safety checkers#219
Closed
patrickvonplaten wants to merge 1 commit intomainfrom
Closed
[Do not merge] Script to compare safety checkers#219patrickvonplaten wants to merge 1 commit intomainfrom
patrickvonplaten wants to merge 1 commit intomainfrom
Conversation
| concept_name = concept_list[j] | ||
| concept_cos = cos_dist[i][j] | ||
| concept_threshold = self.concepts_dict[concept_name] | ||
| result_img["concept_scores"][concept_name] = round(concept_cos - concept_threshold + adjustment,3) |
Contributor
Author
There was a problem hiding this comment.
This means that if adjustment > concept_threshold -> the image will always be a bad image
There was a problem hiding this comment.
what's the theory behind this code? why you calculate the similarity between the embedding of the image and a full-ones tensor below:
self.concept_embeds = nn.Parameter(torch.ones(17, config.projection_dim), requires_grad=False)
self.special_care_embeds = nn.Parameter(torch.ones(3, config.projection_dim), requires_grad=False)
thanks very much
Contributor
Author
There was a problem hiding this comment.
I just means that if cosine similarity is above a certain threshold then images will be blocked
Contributor
Author
|
Safety Module is checked and works! |
PhaneeshB
pushed a commit
to nod-ai/diffusers
that referenced
this pull request
Mar 1, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Open clip is taken from here: https://github.com/mlfoundations/open_clip
Script to compare the two: