Spaces:
				
			
			
	
			
			
		Running
		
			on 
			
			Zero
	
	
	
			
			
	
	
	
	
		
		
		Running
		
			on 
			
			Zero
	feature suggestion (reselution settings)
#1
by
						
TheBigBlockPC
	
							
						- opened
							
					
Based on the code in this space, it seems like you tried to implement different resolutions but ended up removing them.
To enable custom resolutions, you need to do the following:
image = pipe(
    image=concatenated_image, 
    prompt=final_prompt,
    guidance_scale=guidance_scale,
    width=width,
    height=height,
    max_area=width * height,
    num_inference_steps=inference_steps,
    generator=torch.Generator().manual_seed(seed),
).images[0]
To fix the issue with the image not aligning correctly, the problem lies with the variable PREFERRED_KONTEXT_RESOLUTIONS.
To solve that, I did this:
preferred_kontext_res = [(width, height)]
# 3. Preprocess image
if not torch.is_tensor(image) or image.size(1) == self.latent_channels:
    image_width, image_height = self.image_processor.get_default_height_width(image)
    aspect_ratio = image_width / image_height
    # Kontext is trained on specific resolutions; using one of them is recommended
    _, image_width, image_height = min(
        (abs(aspect_ratio - w / h), w, h) for w, h in preferred_kontext_res
    )
    image_width = image_width // multiple_of * multiple_of
    image_height = image_height // multiple_of * multiple_of
    image = self.image_processor.resize(image, image_height, image_width)
    image = self.image_processor.preprocess(image, image_height, image_width)
This was done within the implementation of the FluxKontextPipeline class.