Negative prompts for the inference api
Hello, for the free inference api, Is there a way to add negative prompts? I heard that huggingface recently added this feature, and was wondering how to include it in my request…Thanks in advance!
2023-02-27T19:10:19Z
EDIT: this would be for the Stable Diffusion inference api…Any updates?
2023-02-27T21:10:20Z
hi@jetpackjules,Yes we’ve recently add the negative prompt to the APIHere is a request example in Javascriptfetch(
  "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2",
  {
    method: "POST",
    headers: {
      "content-type": "application/json",
    },
    body: JSON.stringify({
      inputs:
        "award winning high resolution photo of a giant tortoise/((ladybird)) hybrid, [trending on artstation]",
      negative_prompt: "blurry",
    }),
  }
)
  .then((res) => res.blob())
  .then((blob) => {
    const tab = window.open((target = "_blank"));
    tab.location.href = window.URL.createObjectURL(blob);
  });github.comhuggingface/api-inference-community/blob/6f39af264188099a8929cd2a0148b85c7690b0c4/docker_images/diffusers/app/pipelines/text_to_image.py#L57self.ldm.unet.load_attn_procs(model_id, use_auth_token=os.getenv("HF_API_TOKEN"))if isinstance(self.ldm, (StableDiffusionPipeline, AltDiffusionPipeline)):self.ldm.scheduler = DPMSolverMultistepScheduler.from_config(self.ldm.scheduler.config)def __call__(self, inputs: str, inference_steps=25, negative_prompt=None, **kwargs) -> "Image.Image":"""Args:inputs (:obj:`str`):a string containing some textReturn:A :obj:`PIL.Image` with the raw image representation as PIL."""if kwargs:Blockquote
2023-02-27T21:53:02Z
Awesome, Thankyou very much!
2023-02-27T22:19:03Z
Does this also work for Stable Diffusion 1-5, or just 2?
2023-02-27T22:37:57Z
Hi@jetpackjulesatm the pipeline is very basic and only supports 512px inference, however we could change that, you can send your opinion needs hereDocument usage of text-to-image · Issue #152 · huggingface/api-inference-community · GitHub
2023-02-27T22:45:11Z
@jetpackjulessorry, it’s automatic, you have to set the sample size on the vae config fileComparehuggingface.covae/config.json · stabilityai/stable-diffusion-2 at mainWe’re on a journey to advance and democratize artificial intelligence through open source and open science.huggingface.covae/config.json · TheLastBen/froggy-style at mainWe’re on a journey to advance and democratize artificial intelligence through open source and open science.
2023-02-27T23:06:45Z
For the negative prompt?
2023-08-22T07:17:09Z
Hey, how to download an image from this data and display it in nodejs?
2023-08-22T07:18:02Z
Screenshot_20230822-141721_Chrome1440×591 152 KBI use your code
2024-01-10T11:42:10Z
Hi , I want to know about Inference Endpoint. Does it allow all parameters? size,…