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

Localai v2 Image2Image not working #1392

Closed
mforell opened this issue Dec 6, 2023 · 1 comment
Closed

Localai v2 Image2Image not working #1392

mforell opened this issue Dec 6, 2023 · 1 comment
Assignees
Labels
bug Something isn't working high prio needs help

Comments

@mforell
Copy link

mforell commented Dec 6, 2023

LocalAI version:

Dockerimage quay.io/go-skynet/local-ai:v2.0.0-cublas-cuda11-ffmpeg
Describe the bug

I'm trying to implement an Image2Image transformation using the Stable Diffusion model with Diffusers, as described in the guide https://localai.io/model-compatibility/diffusers/. I am using the latest Docker image v2.0.0. Normal Text-to-Image generation is working. However, I keep encountering an error, and I'm not sure what I'm doing wrong. Here's the error message I receive:

{
   "error":{
      "code":500,
      "message":"rpc error: code = Unknown desc = Exception calling application: 'image'",
      "type":""
   }
}

I have set up my YAML configuration as follows:

backend: diffusers
diffusers:
  cuda: true
  enable_parameters: negative_prompt,num_inference_steps,image 
  pipeline_type: StableDiffusionImg2ImgPipeline
f16: true
name: stablediffusion-edit
parameters:
  model: nitrosocke/Ghibli-Diffusion
step: 25

And here's the Python script I'm using to encode the image in Base64 and create the JSON request:

import base64
import json

# Convert image to Base64
with open("test.jpg", "rb") as image_file:
    encoded_string = base64.b64encode(image_file.read()).decode()

# Create JSON body
data = {
    "image": encoded_string,
    "prompt": "a sky background",
    "size": "512x512",
    "model": "stablediffusion-edit"
}

# Save JSON to file
with open('request.json', 'w') as outfile:
    json.dump(data, outfile)

# Execute cURL command
!curl -H "Content-Type: application/json" -d @request.json http://localhost:8080/v1/images/generations

Also tried it with Openai:

from openai import OpenAI

client = OpenAI(base_url="http://localhost:8080/v1", api_key="sk-xxx")

client.images.edit(
  image=open("original.png", "rb"),
  mask=open("mask.png", "rb"),
  prompt="A cute baby sea otter wearing a beret",
  n=2,
  size="256x256"
)

Here I am getting the error:

NotFoundError: Error code: 404 - 
{
   "error":{
      "code":404,
      "message":"Cannot POST /v1/images/edits",
      "type":""
   }
}
@mforell mforell added the bug Something isn't working label Dec 6, 2023
@localai-bot
Copy link
Contributor

⚠️⚠️⚠️⚠️⚠️

Hi! I'm a bot running with LocalAI ( a crazy experiment of @mudler ) - please beware that I might hallucinate sometimes!

but.... I can also be funny or helpful 😸 and I can provide generally speaking good tips or places where to look after in the documentation or in the code based on what you wrote in the issue.

Don't engage in conversation with me,
I don't support (yet) replying!

⚠️⚠️⚠️⚠️⚠️

ERROR: The prompt size exceeds the context window size and cannot be processed.

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high prio needs help
Projects
None yet
Development

No branches or pull requests

4 participants