Skip to content
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

Pull Imagen feature #285

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Pull Imagen feature #285

wants to merge 4 commits into from

Conversation

junyanxu
Copy link
Collaborator

@junyanxu junyanxu commented Oct 18, 2024

I messed up the old branch after doing a merge. Create this new branch for us to keep reviewing.

I have resolved all comments except one from @hsubox76

The ...request will cause testing error like this, because original request has more parameters than parameters could accept. And in new predict api the parameters are not typed.

      AssertionError: expected { model: 'test_model', …(2) } to deeply equal { …(3) }
      + expected - actual

         "parameters": {
           "aspectRatio": "1:1"
           "compressionQuality": 12
           "guidanceScale": 5
      -    "height": 1024
           "language": "ko"
           "negativePrompt": "Not a dog"
      -    "numberOfImages": 1
           "outputMimeType": "image/png"
      -    "prompt": "Create a cat"
           "safetyFilterLevel": "block_medium_and_above"
           "sampleCount": 1
           "sampleImageSize": 1024
      -    "width": 512
         }
       }
      

Related to #276

@@ -448,6 +448,13 @@ export interface GenerateContentStreamResult {
stream: AsyncGenerator<EnhancedGenerateContentResponse>;
}

// @public
export interface GeneratedImage {
// Warning: (ae-forgotten-export) The symbol "PredictServiceValueType" needs to be exported by the entry point index.d.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check this file for comments telling you what's still missing in the exported types.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out. I removed the field from GeneratedImage.

@jony89
Copy link

jony89 commented Oct 24, 2024

btw while this works for me :

    const genAI = new GoogleGenerativeAI("AIza****2bE");
    const model = genAI.getGenerativeModel({
        model: "gemini-1.5-flash"
    });
    const result = await model.generateContent("what is a cat");

While using this branch and following the sample:

    const genAI = new GoogleGenerativeAI("AIza****2bE");
    const model = genAI.getImageGenerationModel({
        model: "imagen-3.0-generate-001",
    });

    const result = await model.generateImages(prompt);

I am getting :

Error fetching from https://generativelanguage.googleapis.com/v1beta/models/imagen-3.0-generate-001:predict: [404 Not Found] models/imagen-3.0-generate-001 is not found for API version v1beta, or is not supported for predict. Call ListModels to see the list of available models and their supported methods.

And with:

    const genAI = new GoogleGenerativeAI("AIza****2bE");
    const model = genAI.getImageGenerationModel({
        model: "imagen-3.0-generate-001",
    }, { apiVersion: "v1" });

    const result = await model.generateImages(prompt);

I just get 404. any idea @junyanxu ?

@junyanxu
Copy link
Collaborator Author

@jony89 Are you in the tester list? Your project need to be in trusted project list. Otherwise the you cannot use the API. Target GA date should be in mid Nov. After that this branch will be merged.

@jony89
Copy link

jony89 commented Oct 31, 2024

Yes @junyanxu I do have access. I also was able to use OAuth to access that API and generate images. but with the code here I got that error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants