chore: ram vram usage in resource
This commit is contained in:
@@ -125,7 +125,7 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = forwardRef(
|
||||
</Form.Item>
|
||||
);
|
||||
});
|
||||
}, [formFields, intl, watchFields]);
|
||||
}, [formFields, paramsConfig, intl, watchFields]);
|
||||
|
||||
return (
|
||||
<Form
|
||||
|
||||
@@ -55,7 +55,9 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
initialValues,
|
||||
parameters,
|
||||
isOpenaiCompatible
|
||||
} = useInitImageMeta(props);
|
||||
} = useInitImageMeta(props, {
|
||||
type: 'create'
|
||||
});
|
||||
const {
|
||||
loading,
|
||||
tokenResult,
|
||||
|
||||
@@ -75,13 +75,16 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
updateParamsConfig,
|
||||
setParamsConfig,
|
||||
form,
|
||||
modelMeta,
|
||||
watchFields,
|
||||
formFields,
|
||||
paramsConfig,
|
||||
initialValues,
|
||||
parameters,
|
||||
isOpenaiCompatible
|
||||
} = useInitImageMeta(props);
|
||||
} = useInitImageMeta(props, {
|
||||
type: 'edit'
|
||||
});
|
||||
const {
|
||||
loading,
|
||||
tokenResult,
|
||||
@@ -225,10 +228,21 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
|
||||
const handleOnScaleImageSize = useCallback(
|
||||
(data: { rawWidth: number; rawHeight: number }) => {
|
||||
const { width, height } = scaleImageSize({
|
||||
let { width, height } = scaleImageSize({
|
||||
width: data.rawWidth,
|
||||
height: data.rawHeight
|
||||
});
|
||||
const { max_width: maxWidth, max_height: maxHeight } = modelMeta;
|
||||
|
||||
// update width, height
|
||||
if (maxWidth) {
|
||||
width = Math.max(Math.min(width, maxWidth), 512);
|
||||
}
|
||||
|
||||
if (maxHeight) {
|
||||
height = Math.max(Math.min(height, maxHeight), 512);
|
||||
}
|
||||
|
||||
const newParamsConfig = updateParamsConfig({
|
||||
size: 'custom',
|
||||
isOpenaiCompatible
|
||||
@@ -248,7 +262,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||
});
|
||||
setInitialValues(newParameters);
|
||||
},
|
||||
[parameters, isOpenaiCompatible]
|
||||
[parameters, modelMeta, isOpenaiCompatible]
|
||||
);
|
||||
|
||||
const handleUpdateImageList = useCallback(
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import useOverlayScroller from '@/hooks/use-overlay-scroller';
|
||||
import {
|
||||
ImageAdvancedParamsConfig,
|
||||
ImageCountConfig,
|
||||
ImageCustomSizeConfig,
|
||||
ImageSizeConfig,
|
||||
ImageSizeItem,
|
||||
ImageconstExtraConfig,
|
||||
ImageAdvancedParamsConfig as ImgAdvancedParamsConfig,
|
||||
imageSizeOptions as imageSizeList
|
||||
} from '@/pages/playground/config/params-config';
|
||||
import { useSearchParams } from '@umijs/max';
|
||||
@@ -117,7 +117,7 @@ export const useInitLLmMeta = (
|
||||
if (!val) return;
|
||||
const model = modelList.find((item) => item.value === val);
|
||||
const { form: initialData, meta } = extractLLMMeta(model?.meta);
|
||||
setModelMeta(meta || {});
|
||||
setModelMeta(meta);
|
||||
setInitialValues({
|
||||
...initialData,
|
||||
model: val
|
||||
@@ -185,8 +185,16 @@ export const useInitLLmMeta = (
|
||||
};
|
||||
};
|
||||
|
||||
export const useInitImageMeta = (props: MessageProps) => {
|
||||
export const useInitImageMeta = (
|
||||
props: MessageProps,
|
||||
options: { type: string }
|
||||
) => {
|
||||
const { modelList } = props;
|
||||
const ImageAdvancedParamsConfig =
|
||||
options.type === 'edit'
|
||||
? ImgAdvancedParamsConfig
|
||||
: ImgAdvancedParamsConfig.filter((item) => item.name !== 'strength');
|
||||
|
||||
const form = useRef<any>(null);
|
||||
const [searchParams] = useSearchParams();
|
||||
const [modelMeta, setModelMeta] = useState<any>({});
|
||||
@@ -473,6 +481,7 @@ export const useInitImageMeta = (props: MessageProps) => {
|
||||
updateParamsConfig,
|
||||
setParamsConfig,
|
||||
form,
|
||||
modelMeta,
|
||||
formFields,
|
||||
watchFields,
|
||||
paramsConfig,
|
||||
|
||||
Reference in New Issue
Block a user