fix bug too large image uploaded

This commit is contained in:
HappyZ 2023-04-30 21:05:38 -07:00
parent 6d0bc3ebab
commit 13778778f9
2 changed files with 34 additions and 1 deletions

View File

@ -429,6 +429,14 @@
if (isNaN(stepsVal)) {
stepsVal = 50;
}
var widthVal = parseInt($('#inputWidth').val());
if (isNaN(widthVal)) {
widthVal = 512;
}
var heightVal = parseInt($('#inputHeight').val());
if (isNaN(heightVal)) {
heightVal = 512;
}
var strengthVal = parseInt($('#inputStrength').val());
if (isNaN(strengthVal)) {
strengthVal = 0.5;
@ -449,6 +457,25 @@
return;
}
if (widthVal < 8 || widthVal > 960) {
alert("width must be between 8 and 960!");
return;
}
if (widthVal % 8 != 0) {
alert("width must be divisible by 8!");
return;
}
if (heightVal < 8 || heightVal > 960) {
alert("height must be between 8 and 960!");
return;
}
if (heightVal % 8 != 0) {
alert("height must be divisible by 8!");
return;
}
if (stepsVal > 200 || stepsVal < 1) {
alert("steps value must be between 1 and 200!");
return;
@ -467,6 +494,8 @@
'prompt': promptVal,
'seed': seedVal,
'steps': stepsVal,
'width': widthVal,
'height': heightVal,
'guidance_scale': guidanceScaleVal,
'strength': strengthVal,
'neg_prompt': negPromptVal

View File

@ -60,7 +60,11 @@ class Img2Img:
self.__logger.info("current seed: {}".format(seed))
if isinstance(reference_image, str):
reference_image = base64_to_image(reference_image).convert('RGB')
reference_image = (
base64_to_image(reference_image)
.thumbnail(config.get_width(), config.get_height())
.convert("RGB")
)
result = self.model.img2img_pipeline(
prompt=prompt,