How to Successfully Call the UForm-Gen2-QWEN-500M Model API

Hello everyone, has anyone successfully implemented the UForm-Gen2-QWEN-500m model?
I understand that this model is supposed to provide textual information in response to an uploaded image. However, I’m facing some confusion with preparing the input JSON Schema, particularly unsure about how to upload the image. If anyone could share a specific example of successfully calling this API, I would be incredibly grateful. Looking forward to some guidance to proceed smoothly. Thank you!

API DOC

1 Like

Hi, I managed to do it this way:

app.post("/uform", async (c) => {
  const body = await c.req.arrayBuffer();
  const bytes = new Uint8Array(body);

  const input = {
    image: [...bytes],
    prompt: "",
    max_tokens: 256,
  };

  const ai = new Ai(c.env.AI);

  try {
    const response = await ai.run<"@cf/unum/uform-gen2-qwen-500m">(
      "@cf/unum/uform-gen2-qwen-500m",
      input,
    );
    return c.json({ response });
  } catch (error) {
    console.error(error);
    return c.json({ error }, 500);
  }
});
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.