remove size selector
This commit is contained in:
@@ -10,7 +10,6 @@ export default async function inpaint(
|
|||||||
croperRect: Rect,
|
croperRect: Rect,
|
||||||
prompt?: string,
|
prompt?: string,
|
||||||
negativePrompt?: string,
|
negativePrompt?: string,
|
||||||
sizeLimit?: string,
|
|
||||||
seed?: number,
|
seed?: number,
|
||||||
maskBase64?: string,
|
maskBase64?: string,
|
||||||
customMask?: File,
|
customMask?: File,
|
||||||
@@ -94,12 +93,6 @@ export default async function inpaint(
|
|||||||
settings.controlnetConditioningScale.toString()
|
settings.controlnetConditioningScale.toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
if (sizeLimit === undefined) {
|
|
||||||
fd.append('sizeLimit', '1080')
|
|
||||||
} else {
|
|
||||||
fd.append('sizeLimit', sizeLimit)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_ENDPOINT}/inpaint`, {
|
const res = await fetch(`${API_ENDPOINT}/inpaint`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import { useWindowSize, useKey, useKeyPressEvent } from 'react-use'
|
|||||||
import inpaint, { downloadToOutput, runPlugin } from '../../adapters/inpainting'
|
import inpaint, { downloadToOutput, runPlugin } from '../../adapters/inpainting'
|
||||||
import Button from '../shared/Button'
|
import Button from '../shared/Button'
|
||||||
import Slider from './Slider'
|
import Slider from './Slider'
|
||||||
import SizeSelector from './SizeSelector'
|
|
||||||
import {
|
import {
|
||||||
askWritePermission,
|
askWritePermission,
|
||||||
copyCanvasImage,
|
copyCanvasImage,
|
||||||
@@ -169,7 +168,6 @@ export default function Editor() {
|
|||||||
const [scale, setScale] = useState<number>(1)
|
const [scale, setScale] = useState<number>(1)
|
||||||
const [panned, setPanned] = useState<boolean>(false)
|
const [panned, setPanned] = useState<boolean>(false)
|
||||||
const [minScale, setMinScale] = useState<number>(1.0)
|
const [minScale, setMinScale] = useState<number>(1.0)
|
||||||
const [sizeLimit, setSizeLimit] = useState<number>(1080)
|
|
||||||
const windowSize = useWindowSize()
|
const windowSize = useWindowSize()
|
||||||
const windowCenterX = windowSize.width / 2
|
const windowCenterX = windowSize.width / 2
|
||||||
const windowCenterY = windowSize.height / 2
|
const windowCenterY = windowSize.height / 2
|
||||||
@@ -387,7 +385,6 @@ export default function Editor() {
|
|||||||
croperRect,
|
croperRect,
|
||||||
promptVal,
|
promptVal,
|
||||||
negativePromptVal,
|
negativePromptVal,
|
||||||
sizeLimit.toString(),
|
|
||||||
seedVal,
|
seedVal,
|
||||||
useCustomMask ? undefined : maskCanvas.toDataURL(),
|
useCustomMask ? undefined : maskCanvas.toDataURL(),
|
||||||
useCustomMask ? customMask : undefined,
|
useCustomMask ? customMask : undefined,
|
||||||
@@ -439,7 +436,6 @@ export default function Editor() {
|
|||||||
settings.graduallyInpainting,
|
settings.graduallyInpainting,
|
||||||
settings,
|
settings,
|
||||||
croperRect,
|
croperRect,
|
||||||
sizeLimit,
|
|
||||||
promptVal,
|
promptVal,
|
||||||
negativePromptVal,
|
negativePromptVal,
|
||||||
drawOnCurrentRender,
|
drawOnCurrentRender,
|
||||||
@@ -684,8 +680,6 @@ export default function Editor() {
|
|||||||
if (!initialCentered) {
|
if (!initialCentered) {
|
||||||
viewportRef.current?.centerView(s, 1)
|
viewportRef.current?.centerView(s, 1)
|
||||||
setInitialCentered(true)
|
setInitialCentered(true)
|
||||||
const imageSizeLimit = Math.max(original.width, original.height)
|
|
||||||
setSizeLimit(imageSizeLimit)
|
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
context?.canvas,
|
context?.canvas,
|
||||||
@@ -1229,10 +1223,6 @@ export default function Editor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSizeLimitChange = (_sizeLimit: number) => {
|
|
||||||
setSizeLimit(_sizeLimit)
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggleShowBrush = (newState: boolean) => {
|
const toggleShowBrush = (newState: boolean) => {
|
||||||
if (newState !== showBrush && !isPanning) {
|
if (newState !== showBrush && !isPanning) {
|
||||||
setShowBrush(newState)
|
setShowBrush(newState)
|
||||||
@@ -1544,15 +1534,6 @@ export default function Editor() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="editor-toolkit-panel">
|
<div className="editor-toolkit-panel">
|
||||||
{isDiffusionModels || file === undefined ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
<SizeSelector
|
|
||||||
onChange={onSizeLimitChange}
|
|
||||||
originalWidth={original.naturalWidth}
|
|
||||||
originalHeight={original.naturalHeight}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Slider
|
<Slider
|
||||||
label="Brush"
|
label="Brush"
|
||||||
min={MIN_BRUSH_SIZE}
|
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
|
interpolation = cv2.INTER_CUBIC
|
||||||
|
|
||||||
form = request.form
|
form = request.form
|
||||||
size_limit: Union[int, str] = form.get("sizeLimit", "1080")
|
size_limit = max(image.shape)
|
||||||
if size_limit == "Original":
|
|
||||||
size_limit = max(image.shape)
|
|
||||||
else:
|
|
||||||
size_limit = int(size_limit)
|
|
||||||
|
|
||||||
if "paintByExampleImage" in input:
|
if "paintByExampleImage" in input:
|
||||||
paint_by_example_example_image, _ = load_img(
|
paint_by_example_example_image, _ = load_img(
|
||||||
|
|||||||
Reference in New Issue
Block a user