Skip to content

Conversation

1649759610
Copy link
Contributor

@1649759610 1649759610 commented Apr 27, 2023

PR types

New features

PR changes

Models

Description

generate images with hires.fix function.

import paddle
from stable_diffusion_hires_fix import StableDiffusionHiresFixPipeline
from ppdiffusers import EulerAncestralDiscreteScheduler

pipe = StableDiffusionHiresFixPipeline.from_pretrained("stabilityai/stable-diffusion-2", paddle_dtype=paddle.float16)
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)

generator = paddle.Generator().manual_seed(5232132133)
prompt = "1 real girl, long black hair, detailed face, light smile, chinese style, hanfu"
image = pipe(prompt, guidance_scale=7.5, height=768, width=768, generator=generator, num_inference_steps=40, hires_ratio=0.5, hr_resize_width=768, hr_resize_height=1024, enable_hr=True).images[0]

image.show()

Note
The image generated by ppdiffusers has a little difference from webui's due to the difference of generated sigmas. Here show a picture from webui below.

@paddle-bot
Copy link

paddle-bot bot commented Apr 27, 2023

Thanks for your contribution!

@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Merging #5802 (9938f7a) into develop (e70e9d8) will increase coverage by 0.33%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #5802      +/-   ##
===========================================
+ Coverage    61.60%   61.94%   +0.33%     
===========================================
  Files          488      491       +3     
  Lines        68472    69130     +658     
===========================================
+ Hits         42185    42820     +635     
- Misses       26287    26310      +23     

see 32 files with indirect coverage changes


# 12. denoising on hires.fix steps
num_warmup_steps = len(timesteps) - hr_steps * self.scheduler.order
print("Step2: Perform denosing on hires.fix stage.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print 坑你都不要吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted


# 5. Prepare latent variables
if generator is not None:
paddle.Generator().states_["initial_generator"] = copy.deepcopy(paddle.Generator().states_[generator])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

设置一个叫 二阶段的generator,如果二阶段的generator为空,那么我们就用一阶段的generator(不为空的情况下)

Copy link
Contributor Author

@1649759610 1649759610 May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better not to add the second generator, some reasons as follows:

  • This usage may confused user with two random seed, and it seems unreasonable to control a image generation with two seeds.
  • It maybe result in bad image generation.

Copy link
Member

@JunnYu JunnYu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE

@1649759610 1649759610 merged commit 565397c into PaddlePaddle:develop May 12, 2023
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 this pull request may close these issues.

2 participants