remove size selector
This commit is contained in:
@@ -10,7 +10,6 @@ export default async function inpaint(
|
||||
croperRect: Rect,
|
||||
prompt?: string,
|
||||
negativePrompt?: string,
|
||||
sizeLimit?: string,
|
||||
seed?: number,
|
||||
maskBase64?: string,
|
||||
customMask?: File,
|
||||
@@ -94,12 +93,6 @@ export default async function inpaint(
|
||||
settings.controlnetConditioningScale.toString()
|
||||
)
|
||||
|
||||
if (sizeLimit === undefined) {
|
||||
fd.append('sizeLimit', '1080')
|
||||
} else {
|
||||
fd.append('sizeLimit', sizeLimit)
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(`${API_ENDPOINT}/inpaint`, {
|
||||
method: 'POST',
|
||||
|
||||
@@ -21,7 +21,6 @@ import { useWindowSize, useKey, useKeyPressEvent } from 'react-use'
|
||||
import inpaint, { downloadToOutput, runPlugin } from '../../adapters/inpainting'
|
||||
import Button from '../shared/Button'
|
||||
import Slider from './Slider'
|
||||
import SizeSelector from './SizeSelector'
|
||||
import {
|
||||
askWritePermission,
|
||||
copyCanvasImage,
|
||||
@@ -169,7 +168,6 @@ export default function Editor() {
|
||||
const [scale, setScale] = useState<number>(1)
|
||||
const [panned, setPanned] = useState<boolean>(false)
|
||||
const [minScale, setMinScale] = useState<number>(1.0)
|
||||
const [sizeLimit, setSizeLimit] = useState<number>(1080)
|
||||
const windowSize = useWindowSize()
|
||||
const windowCenterX = windowSize.width / 2
|
||||
const windowCenterY = windowSize.height / 2
|
||||
@@ -387,7 +385,6 @@ export default function Editor() {
|
||||
croperRect,
|
||||
promptVal,
|
||||
negativePromptVal,
|
||||
sizeLimit.toString(),
|
||||
seedVal,
|
||||
useCustomMask ? undefined : maskCanvas.toDataURL(),
|
||||
useCustomMask ? customMask : undefined,
|
||||
@@ -439,7 +436,6 @@ export default function Editor() {
|
||||
settings.graduallyInpainting,
|
||||
settings,
|
||||
croperRect,
|
||||
sizeLimit,
|
||||
promptVal,
|
||||
negativePromptVal,
|
||||
drawOnCurrentRender,
|
||||
@@ -684,8 +680,6 @@ export default function Editor() {
|
||||
if (!initialCentered) {
|
||||
viewportRef.current?.centerView(s, 1)
|
||||
setInitialCentered(true)
|
||||
const imageSizeLimit = Math.max(original.width, original.height)
|
||||
setSizeLimit(imageSizeLimit)
|
||||
}
|
||||
}, [
|
||||
context?.canvas,
|
||||
@@ -1229,10 +1223,6 @@ export default function Editor() {
|
||||
}
|
||||
}
|
||||
|
||||
const onSizeLimitChange = (_sizeLimit: number) => {
|
||||
setSizeLimit(_sizeLimit)
|
||||
}
|
||||
|
||||
const toggleShowBrush = (newState: boolean) => {
|
||||
if (newState !== showBrush && !isPanning) {
|
||||
setShowBrush(newState)
|
||||
@@ -1544,15 +1534,6 @@ export default function Editor() {
|
||||
)}
|
||||
|
||||
<div className="editor-toolkit-panel">
|
||||
{isDiffusionModels || file === undefined ? (
|
||||
<></>
|
||||
) : (
|
||||
<SizeSelector
|
||||
onChange={onSizeLimitChange}
|
||||
originalWidth={original.naturalWidth}
|
||||
originalHeight={original.naturalHeight}
|
||||
/>
|
||||
)}
|
||||
<Slider
|
||||
label="Brush"
|
||||
min={MIN_BRUSH_SIZE}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
import React, { useCallback, useEffect, useState } from 'react'
|
||||
import Selector from '../shared/Selector'
|
||||
|
||||
const sizes = ['720', '1080', '2000', 'Original']
|
||||
|
||||
type SizeSelectorProps = {
|
||||
originalWidth: number
|
||||
originalHeight: number
|
||||
onChange: (value: number) => void
|
||||
}
|
||||
|
||||
export default function SizeSelector(props: SizeSelectorProps) {
|
||||
const { originalHeight, originalWidth, onChange } = props
|
||||
const [activeSize, setActiveSize] = useState<string>('Original')
|
||||
const longSide: number = Math.max(originalWidth, originalHeight)
|
||||
|
||||
const getSizeShowName = useCallback(
|
||||
(size: string) => {
|
||||
if (size === 'Original') {
|
||||
return `${originalWidth}x${originalHeight}`
|
||||
}
|
||||
const scale = parseInt(size, 10) / longSide
|
||||
if (originalWidth > originalHeight) {
|
||||
const newHeight = Math.ceil(originalHeight * scale)
|
||||
return `${size}x${newHeight}`
|
||||
}
|
||||
const newWidth = Math.ceil(originalWidth * scale)
|
||||
return `${newWidth}x${size}`
|
||||
},
|
||||
[originalWidth, originalHeight, longSide]
|
||||
)
|
||||
|
||||
const getValidSizes = useCallback(() => {
|
||||
const validSizes: string[] = []
|
||||
for (let i = 0; i < sizes.length; i += 1) {
|
||||
if (sizes[i] === 'Original') {
|
||||
validSizes.push(getSizeShowName(sizes[i]))
|
||||
}
|
||||
if (parseInt(sizes[i], 10) < longSide) {
|
||||
validSizes.push(getSizeShowName(sizes[i]))
|
||||
}
|
||||
}
|
||||
return validSizes
|
||||
}, [longSide, getSizeShowName])
|
||||
|
||||
const sizeChangeHandler = (value: string) => {
|
||||
const currentRes = value.split('x')
|
||||
if (originalWidth > originalHeight) {
|
||||
setActiveSize(currentRes[0])
|
||||
onChange(parseInt(currentRes[0], 10))
|
||||
} else {
|
||||
setActiveSize(currentRes[1])
|
||||
onChange(parseInt(currentRes[1], 10))
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Selector
|
||||
width={100}
|
||||
autoFocusAfterClose={false}
|
||||
value={getSizeShowName(activeSize.toString())}
|
||||
options={getValidSizes()}
|
||||
onChange={sizeChangeHandler}
|
||||
chevronDirection="up"
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -211,11 +211,7 @@ def process():
|
||||
interpolation = cv2.INTER_CUBIC
|
||||
|
||||
form = request.form
|
||||
size_limit: Union[int, str] = form.get("sizeLimit", "1080")
|
||||
if size_limit == "Original":
|
||||
size_limit = max(image.shape)
|
||||
else:
|
||||
size_limit = int(size_limit)
|
||||
size_limit = max(image.shape)
|
||||
|
||||
if "paintByExampleImage" in input:
|
||||
paint_by_example_example_image, _ = load_img(
|
||||
|
||||
Reference in New Issue
Block a user