@@ -6,16 +6,19 @@ import { setActiveTab } from 'features/ui/store/uiSlice';
6
6
import { useCallback , useEffect , useMemo } from 'react' ;
7
7
import { Trans , useTranslation } from 'react-i18next' ;
8
8
import { useControlNetModels } from 'services/api/hooks/modelsByType' ;
9
+ import { useIsTooLargeToUpscale } from '../../../parameters/hooks/useIsTooLargeToUpscale' ;
9
10
10
11
export const UpscaleWarning = ( ) => {
11
12
const { t } = useTranslation ( ) ;
12
13
const model = useAppSelector ( ( s ) => s . generation . model ) ;
13
14
const upscaleModel = useAppSelector ( ( s ) => s . upscale . upscaleModel ) ;
14
15
const tileControlnetModel = useAppSelector ( ( s ) => s . upscale . tileControlnetModel ) ;
16
+ const upscaleInitialImage = useAppSelector ( ( s ) => s . upscale . upscaleInitialImage ) ;
15
17
const dispatch = useAppDispatch ( ) ;
16
18
const [ modelConfigs , { isLoading } ] = useControlNetModels ( ) ;
17
19
const disabledTabs = useAppSelector ( ( s ) => s . config . disabledTabs ) ;
18
20
const shouldShowButton = useMemo ( ( ) => ! disabledTabs . includes ( 'models' ) , [ disabledTabs ] ) ;
21
+ const isTooLargeToUpscale = useIsTooLargeToUpscale ( upscaleInitialImage || undefined ) ;
19
22
20
23
useEffect ( ( ) => {
21
24
const validModel = modelConfigs . find ( ( cnetModel ) => {
@@ -24,7 +27,7 @@ export const UpscaleWarning = () => {
24
27
dispatch ( tileControlnetModelChanged ( validModel || null ) ) ;
25
28
} , [ model ?. base , modelConfigs , dispatch ] ) ;
26
29
27
- const warnings = useMemo ( ( ) => {
30
+ const modelWarnings = useMemo ( ( ) => {
28
31
const _warnings : string [ ] = [ ] ;
29
32
if ( ! model ) {
30
33
_warnings . push ( t ( 'upscaling.mainModelDesc' ) ) ;
@@ -35,33 +38,43 @@ export const UpscaleWarning = () => {
35
38
if ( ! upscaleModel ) {
36
39
_warnings . push ( t ( 'upscaling.upscaleModelDesc' ) ) ;
37
40
}
38
-
39
41
return _warnings ;
40
42
} , [ model , tileControlnetModel , upscaleModel , t ] ) ;
41
43
44
+ const otherWarnings = useMemo ( ( ) => {
45
+ console . log ( { isTooLargeToUpscale } ) ;
46
+ const _warnings : string [ ] = [ ] ;
47
+ if ( isTooLargeToUpscale ) {
48
+ _warnings . push ( t ( 'upscaling.outputTooLarge' ) ) ;
49
+ }
50
+ return _warnings ;
51
+ } , [ isTooLargeToUpscale ] ) ;
52
+
42
53
const handleGoToModelManager = useCallback ( ( ) => {
43
54
dispatch ( setActiveTab ( 'models' ) ) ;
44
55
$installModelsTab . set ( 3 ) ;
45
56
} , [ dispatch ] ) ;
46
57
47
- if ( ! warnings . length || isLoading || ! shouldShowButton ) {
58
+ if ( ( ! modelWarnings . length && ! otherWarnings . length ) || isLoading || ! shouldShowButton ) {
48
59
return null ;
49
60
}
50
61
51
62
return (
52
63
< Flex bg = "error.500" borderRadius = "base" padding = { 4 } direction = "column" fontSize = "sm" gap = { 2 } >
53
- < Text >
54
- < Trans
55
- i18nKey = "upscaling.missingModelsWarning"
56
- components = { {
57
- LinkComponent : (
58
- < Button size = "sm" flexGrow = { 0 } variant = "link" color = "base.50" onClick = { handleGoToModelManager } />
59
- ) ,
60
- } }
61
- />
62
- </ Text >
64
+ { ! ! modelWarnings . length && (
65
+ < Text >
66
+ < Trans
67
+ i18nKey = "upscaling.missingModelsWarning"
68
+ components = { {
69
+ LinkComponent : (
70
+ < Button size = "sm" flexGrow = { 0 } variant = "link" color = "base.50" onClick = { handleGoToModelManager } />
71
+ ) ,
72
+ } }
73
+ />
74
+ </ Text >
75
+ ) }
63
76
< UnorderedList >
64
- { warnings . map ( ( warning ) => (
77
+ { [ ... modelWarnings , ... otherWarnings ] . map ( ( warning ) => (
65
78
< ListItem key = { warning } > { warning } </ ListItem >
66
79
) ) }
67
80
</ UnorderedList >
0 commit comments