-
Notifications
You must be signed in to change notification settings - Fork 161
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
Imagen #276
Conversation
@@ -46,6 +46,7 @@ | |||
"devDependencies": { | |||
"@changesets/cli": "^2.27.1", | |||
"@esm-bundle/chai": "^4.3.4-fix.0", | |||
"@google-cloud/asset": "^5.7.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this used?
@@ -0,0 +1,48 @@ | |||
export type PredictServiceBasicValueType = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed none of the new types that are added seem to be exported from types/index.ts
which means the user won't have access to them. I assume you want the developer to have access to some of them, can you make sure they're exported from types/index.ts
?
types/requests.ts
Outdated
*/ | ||
negativePrompt?: string; | ||
/** | ||
* Number of images to generate. Range: 1..8. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I tried passing numberOfImages: 8
, I got an error saying 4 is the max.
GoogleGenerativeAIFetchError: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/imagen-3.0-generate-001:predict: [400 Bad Request] Image generation failed with the following error: Invalid sample count 8 in request. Max number of samples prebuilt model can return is 4. Min number is 1
types/requests.ts
Outdated
/** | ||
* Width of the image. One of the Width/Height sizes must be 256 or 1024. | ||
*/ | ||
width?: number; | ||
/** | ||
* Height of the image. One of the Width/Height sizes must be 256 or 1024. | ||
*/ | ||
height?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I specify width
and height
to 256
, I get back an image that is 1024x1024
. I'm not sure whether this is a backend issue or not.
import {
GoogleGenerativeAI,
} from "@google/generative-ai";
import { writeFileSync } from 'fs';
async function imageGeneration() {
const genAI = new GoogleGenerativeAI(process.env.API_KEY);
const model = genAI.getImageGenerationModel({
model: "imagen-3.0-generate-001",
});
const result = await model.generateImages(
{
prompt: "A fluffy cat",
numberOfImages: 1,
width: 256,
height: 256,
});
writeFileSync('image.png', new Buffer(result.images[0].imageBytes, 'base64'));
}
async function runAll() {
await imageGeneration();
}
runAll();
src/requests/request-helpers.ts
Outdated
request: ImageGenerationRequest, | ||
): PredictRequest { | ||
const instances = [{ prompt: request.prompt }]; | ||
const sampleImageSize = Math.max(request.width || 0, request.height || 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use the max of width
and height
as the image size and only pass that one dimension, why not just have one imageSize
option?
Sorry guys, I messes up the git after doing a merge. I open up a new branch for us to review. |
Doc change not applied yet. Please focus on the main logic.