Hello all,
The Imagen docs say that I can upscale an image using a gcsUri [1]. However, repeated attempts at making this work have been met with failure. I am running the following node code (I experience the same error in python). The error I'm getting back from the API is `RecvAsync is cancelled`
Here is my node reproduction:
import { GoogleAuth } from 'google-auth-library';
const url = 'https://us-central1-aiplatform.googleapis.com/v1/projects/gemini-image-generation-454107/locations/us-central1/publishers/google/models/imagegeneration@002:predict';
async function getAccessToken() {
const auth = new GoogleAuth({
keyFile: 'gemini-image-generation-454107-6fb54a12791d.json',
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
const client = await auth.getClient();
const headers = await client.getRequestHeaders();
const token = headers['Authorization'].split(' ')[1];
return token;
}
async function upscaleImage(gsUri) {
const token = await getAccessToken();
const headers = {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
};
const payload = {
instances: [
{
image: {
gcsUri: gsUri
}
}
],
parameters: {
sampleCount: 1,
mode: "upscale",
upscaleConfig: {
upscaleFactor: "x2"
}
}
};
const response = await fetch(url, {
method: 'POST',
headers,
body: JSON.stringify(payload)
});
if (response.ok) {
console.log("Upscale success!");
return response.json();
} else {
const errorText = await response.text();
console.error(`Failed with status ${response.status}: ${errorText}`);
throw new Error(`Request failed with status ${response.status}: ${errorText}`);
}
}
const result = await upscaleImage('gs://upscaler-photo-upload/apple_2.png');
console.log('Upscale result:', result);
This results in the following failure:
Is this functionality not actually supported?
Thank you,
Lou
[1] See 'gcsUri' in the JSON body here: https://cloud.google.com/vertex-ai/generative-ai/docs/image/upscale-image
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |