-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Add imagen editing cases to the Firebase AI quickstart #2702
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
base: master
Are you sure you want to change the base?
Changes from all commits
26d799f
3b4e977
55fa1ca
6fc14fe
5658225
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package com.google.firebase.quickstart.ai | ||
|
||
import android.graphics.Bitmap | ||
import android.graphics.BitmapFactory | ||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
|
@@ -22,6 +24,7 @@ import androidx.navigation.NavDestination | |
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.compose.rememberNavController | ||
import com.google.firebase.ai.type.toImagenInlineImage | ||
import com.google.firebase.quickstart.ai.feature.live.StreamRealtimeRoute | ||
import com.google.firebase.quickstart.ai.feature.live.StreamRealtimeScreen | ||
import com.google.firebase.quickstart.ai.feature.media.imagen.ImagenRoute | ||
|
@@ -36,6 +39,7 @@ class MainActivity : ComponentActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
enableEdgeToEdge() | ||
catImage = BitmapFactory.decodeResource(applicationContext.resources, R.drawable.cat) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move the Imagen editing features to a new screen+viewmodel ? |
||
setContent { | ||
val navController = rememberNavController() | ||
|
||
|
@@ -110,4 +114,7 @@ class MainActivity : ComponentActivity() { | |
}) | ||
} | ||
} | ||
companion object{ | ||
lateinit var catImage: Bitmap | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
package com.google.firebase.quickstart.ai.ui.navigation | ||
|
||
import android.content.Context | ||
import android.graphics.Bitmap | ||
import com.google.firebase.ai.ImagenModel | ||
import com.google.firebase.ai.type.Content | ||
import com.google.firebase.ai.type.GenerationConfig | ||
import com.google.firebase.ai.type.GenerativeBackend | ||
import com.google.firebase.ai.type.ImagenGenerationResponse | ||
import com.google.firebase.ai.type.ImagenInlineImage | ||
import com.google.firebase.ai.type.PublicPreviewAPI | ||
import com.google.firebase.ai.type.Tool | ||
import java.util.UUID | ||
|
||
|
@@ -17,6 +23,7 @@ enum class Category( | |
FUNCTION_CALLING("Function calling"), | ||
} | ||
|
||
@OptIn(PublicPreviewAPI::class) | ||
data class Sample( | ||
val id: String = UUID.randomUUID().toString(), // used for navigation | ||
val title: String, | ||
|
@@ -30,5 +37,8 @@ data class Sample( | |
val systemInstructions: Content? = null, | ||
val generationConfig: GenerationConfig? = null, | ||
val chatHistory: List<Content> = emptyList(), | ||
val tools: List<Tool>? = null | ||
val tools: List<Tool>? = null, | ||
val includeAttach: Boolean = false, | ||
val allowEmptyPrompt: Boolean = false, | ||
val generateImages: (suspend (ImagenModel, String, Bitmap?) -> ImagenGenerationResponse<ImagenInlineImage>)? = null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than passing a suspend function here, what if we pass the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That may not work as an abstraction, sometimes editing settings also need to be set, basically every parameter, depending on the use case. |
||
) |
Uh oh!
There was an error while loading. Please reload this page.