-
Notifications
You must be signed in to change notification settings - Fork 642
Imagen Editing #7075
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
Merged
Merged
Imagen Editing #7075
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
dec0990
Add imagen editing options like inpainting and outpainting
9795fc3
add java implementation and minor naming adjustments
60baab6
update api.txt and format
806d4fb
remove nullability from includeRaiReason
66cff7b
remove unneeded and gcsUri
e710498
rename constructGenerateImageRequest
f632e94
rewrite to fit the referenceType style transfer, subject references, …
0327b0a
added support for outpainting properly
c0f6161
add copyright headers
778f176
javadocs1
1131d22
Add refdocs, and address a few review comments
eb3ac0a
bump version
7ed0bd7
fixes for comments
a48f7ac
fixing refdocs for comments, and adding error for incorrect call to o…
21262c3
add tests, and JvmStatic and JvmField annotations
2f85544
Merge branch 'main' into davidmotson.imagen_editing
adf4957
add copyright and update api.txt
c4a626d
format
41427fa
removed references to ControlNet and added an integration test
b172b22
format
c4d4034
remove extra square brackets
9647fd7
add changelog
0980505
make config optional for editing images
83df056
Merge branch 'main' into davidmotson.imagen_editing
davidmotson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
10 changes: 10 additions & 0 deletions
10
firebase-ai/src/main/kotlin/com/google/firebase/ai/type/ImagenEditMode.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.google.firebase.ai.type | ||
rlazo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public class ImagenEditMode private constructor(internal val value: String) { | ||
|
||
public companion object { | ||
davidmotson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public val INPAINT_INSERTION: ImagenEditMode = ImagenEditMode("EDIT_MODE_INPAINT_INSERTION") | ||
public val INPAINT_REMOVAL: ImagenEditMode = ImagenEditMode("EDIT_MODE_INPAINT_REMOVAL") | ||
public val OUTPAINT: ImagenEditMode = ImagenEditMode("EDIT_MODE_OUTPAINT") | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
firebase-ai/src/main/kotlin/com/google/firebase/ai/type/ImagenEditingConfig.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.google.firebase.ai.type | ||
rlazo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@PublicPreviewAPI | ||
public class ImagenEditingConfig( | ||
public val image: ImagenInlineImage, | ||
public val editMode: ImagenEditMode, | ||
public val mask: ImagenInlineImage? = null, | ||
public val maskDilation: Double? = null, | ||
public val editSteps: Int? = null, | ||
) { | ||
public companion object { | ||
public fun builder(): Builder = Builder() | ||
} | ||
|
||
public class Builder { | ||
@JvmField public var image: ImagenInlineImage? = null | ||
@JvmField public var editMode: ImagenEditMode? = null | ||
@JvmField public var mask: ImagenInlineImage? = null | ||
@JvmField public var maskDilation: Double? = null | ||
@JvmField public var editSteps: Int? = null | ||
|
||
public fun setImage(image: ImagenInlineImage): Builder = apply { this.image = image } | ||
|
||
public fun setEditMode(editMode: ImagenEditMode): Builder = apply { this.editMode = editMode } | ||
|
||
public fun setMask(mask: ImagenInlineImage): Builder = apply { this.mask = mask } | ||
|
||
public fun setMaskDilation(maskDilation: Double): Builder = apply { | ||
this.maskDilation = maskDilation | ||
} | ||
|
||
public fun setEditSteps(editSteps: Int): Builder = apply { this.editSteps = editSteps } | ||
|
||
public fun build(): ImagenEditingConfig { | ||
davidmotson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if (image == null) { | ||
throw IllegalStateException("ImagenEditingConfig must contain an image") | ||
} | ||
if (editMode == null) { | ||
throw IllegalStateException("ImagenEditingConfig must contain an editMode") | ||
} | ||
return ImagenEditingConfig( | ||
image = image!!, | ||
editMode = editMode!!, | ||
mask = mask, | ||
maskDilation = maskDilation, | ||
editSteps = editSteps, | ||
) | ||
} | ||
} | ||
|
||
internal fun toInternal(): Internal { | ||
return Internal(baseSteps = editSteps) | ||
davidmotson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
@Serializable | ||
internal data class Internal( | ||
val baseSteps: Int?, | ||
davidmotson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
} | ||
|
||
@PublicPreviewAPI | ||
public fun imagenEditingConfig(init: ImagenEditingConfig.Builder.() -> Unit): ImagenEditingConfig { | ||
val builder = ImagenEditingConfig.builder() | ||
builder.init() | ||
return builder.build() | ||
davidmotson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.