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

UCPreset TYPE0 and TYPE3 returns "lowres" when using NAIv4 #91

Closed
TimmekHW opened this issue Jan 1, 2025 · 0 comments · Fixed by #94
Closed

UCPreset TYPE0 and TYPE3 returns "lowres" when using NAIv4 #91

TimmekHW opened this issue Jan 1, 2025 · 0 comments · Fixed by #94

Comments

@TimmekHW
Copy link

TimmekHW commented Jan 1, 2025

NAIv4 negative prompt from web-site:
heavy:
blurry, lowres, error, film grain, scan artifacts, worst quality, bad quality, jpeg artifacts, very displeasing, chromatic aberration, logo, dated, signature, multiple views, gigantic breasts
ucPreset: 0
light:
blurry, lowres, error, worst quality, bad quality, jpeg artifacts, very displeasing, logo, dated, signature
ucPreset: 1
None:
`` (rlly none)
ucPreset: 2

model = MODELS[await get_user_model_id(message.from_user.id)][1]
image = await NAIGenerator.generate_image(prompt, preset, type, model)

def build_preset(negative, chars, flags, strength, seed, is_best=False, image=None):
    preset = Params(
        width=832,
        height=1216,
        characterPrompts=chars,
        seed=seed or random.randint(0, 4294967295 - 7),
        scale=5,
        negative_prompt=negative,
        strength=strength,
        qualityToggle=True,
        noise_schedule="karras",
        sampler=Sampler.K_EULER_ANCESTRAL,
        ucPreset=UCPreset.TYPE0,

        steps=23,
        n_samples=1,
        dynamic_thresholding=False,
        skip_cfg_above_sigma=None,
        sm=False,
        sm_dyn=False,
        add_original_image=True,

        reference_image_multiple=[],
        reference_information_extracted_multiple=[],
        reference_strength_multiple=[],

        use_coords=any([c.center != PositionMap.AUTO for c in chars])
    )
   ...
    
@classmethod
    async def _generate_image(
        cls, 
        credentials,
        prompt: str, 
        preset: Params, 
        gen_type: GenAction,
        model = ImageModel.NAI_DIFFUSION_3
    ) -> bytes:
        generated_image = None
        retry_count = 0
        max_retries = 5

        while generated_image is None:
            try:
                agent = GenerateImageInfer(
                    input=prompt,
                    model=model,
                    action=gen_type,
                    parameters=preset
                )

                result = await agent.request(session=credentials)
                generated_image = result.files[0][1]
                break
            except APIError as e:
                if e.code in (429, 500, 501, 502, 520, 522, 524):
                    logging.error(f"{e.code} {e.message}")
                    await asyncio.sleep(7.5)
                    retry_count += 1

                    if retry_count < max_retries:
                        continue

                #logging.error("".join(format_exception(type(e), value=e, tb=e.__traceback__)))
                return None
            except Exception as e:
                await asyncio.sleep(7.5)
                #logging.error("".join(format_exception(type(e), value=e, tb=e.__traceback__)))
                return None

        return generated_image

True JSON NAIv4 schema:

{
   "input":"1girl, rating:general, best quality, very aesthetic, absurdres",
   "model":"nai-diffusion-4-curated-preview",
   "action":"generate",
   "parameters":{
      "params_version":3,
      "width":832,
      "height":1216,
      "scale":6,
      "sampler":"k_euler_ancestral",
      "steps":23,
      "seed":3725628346,
      "n_samples":1,
      "ucPreset":0,
      "qualityToggle":true,
      "dynamic_thresholding":false,
      "controlnet_strength":1,
      "legacy":false,
      "add_original_image":true,
      "cfg_rescale":0,
      "noise_schedule":"karras",
      "legacy_v3_extend":false,
      "skip_cfg_above_sigma":null,
      "use_coords":false,
      "characterPrompts":[
         
      ],
      "v4_prompt":{
         "caption":{
            "base_caption":"1girl, rating:general, best quality, very aesthetic, absurdres",
            "char_captions":[
               
            ]
         },
         "use_coords":false,
         "use_order":true
      },
      "v4_negative_prompt":{
         "caption":{
            "base_caption":"blurry, lowres, error, film grain, scan artifacts, worst quality, bad quality, jpeg artifacts, very displeasing, chromatic aberration, logo, dated, signature, multiple views, gigantic breasts",
            "char_captions":[
               
            ]
         }
      },
      "negative_prompt":"blurry, lowres, error, film grain, scan artifacts, worst quality, bad quality, jpeg artifacts, very displeasing, chromatic aberration, logo, dated, signature, multiple views, gigantic breasts",
      "reference_image_multiple":[
         
      ],
      "reference_information_extracted_multiple":[
         
      ],
      "reference_strength_multiple":[
         
      ],
      "deliberate_euler_ancestral_bug":false,
      "prefer_brownian":true
   }
}
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 a pull request may close this issue.

1 participant