Skip to content

Commit 13fb2d1

Browse files
fix: Add Depth Anything V2 as a new option
It is also now the default in the UI replacing Depth Anything V1 small
1 parent 95dde80 commit 13fb2d1

File tree

7 files changed

+269
-132
lines changed

7 files changed

+269
-132
lines changed

invokeai/app/invocations/controlnet_image_processors.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,12 @@ def run_processor(self, image: Image.Image) -> Image.Image:
593593
return color_map
594594

595595

596-
DEPTH_ANYTHING_MODEL_SIZES = Literal["large", "base", "small"]
596+
DEPTH_ANYTHING_MODEL_SIZES = Literal["large", "base", "small", "small_v2"]
597597
DEPTH_ANYTHING_MODELS = {
598598
"large": "LiheYoung/depth-anything-large-hf",
599599
"base": "LiheYoung/depth-anything-base-hf",
600-
"small": "depth-anything/Depth-Anything-V2-Small-hf",
600+
"small": "LiheYoung/depth-anything-small-hf",
601+
"small_v2": "depth-anything/Depth-Anything-V2-Small-hf",
601602
}
602603

603604

invokeai/frontend/web/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
"delete": "Delete",
201201
"depthAnything": "Depth Anything",
202202
"depthAnythingDescription": "Depth map generation using the Depth Anything technique",
203+
"depthAnythingSmallV2": "Small V2",
203204
"depthMidas": "Depth (Midas)",
204205
"depthMidasDescription": "Depth map generation using Midas",
205206
"depthZoe": "Depth (Zoe)",

invokeai/frontend/web/src/features/controlAdapters/components/processors/DepthAnyThingProcessor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const DepthAnythingProcessor = (props: Props) => {
4545
{ label: t('controlnet.small'), value: 'small' },
4646
{ label: t('controlnet.base'), value: 'base' },
4747
{ label: t('controlnet.large'), value: 'large' },
48+
{ label: t('controlnet.depthAnythingSmallV2'), value: 'small_v2' },
4849
],
4950
[t]
5051
);

invokeai/frontend/web/src/features/controlAdapters/store/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export type RequiredDepthAnythingImageProcessorInvocation = O.Required<
8484
'type' | 'model_size' | 'resolution' | 'offload'
8585
>;
8686

87-
const zDepthAnythingModelSize = z.enum(['large', 'base', 'small']);
87+
const zDepthAnythingModelSize = z.enum(['large', 'base', 'small', 'small_v2']);
8888
export type DepthAnythingModelSize = z.infer<typeof zDepthAnythingModelSize>;
8989
export const isDepthAnythingModelSize = (v: unknown): v is DepthAnythingModelSize =>
9090
zDepthAnythingModelSize.safeParse(v).success;

invokeai/frontend/web/src/features/controlLayers/components/ControlAndIPAdapter/processors/DepthAnythingProcessor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const DepthAnythingProcessor = memo(({ onChange, config }: Props) => {
2424

2525
const options: { label: string; value: DepthAnythingModelSize }[] = useMemo(
2626
() => [
27+
{ label: t('controlnet.depthAnythingSmallV2'), value: 'small_v2' },
2728
{ label: t('controlnet.small'), value: 'small' },
2829
{ label: t('controlnet.base'), value: 'base' },
2930
{ label: t('controlnet.large'), value: 'large' },

invokeai/frontend/web/src/features/controlLayers/util/controlAdapters.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const zContentShuffleProcessorConfig = z.object({
3636
});
3737
export type ContentShuffleProcessorConfig = z.infer<typeof zContentShuffleProcessorConfig>;
3838

39-
const zDepthAnythingModelSize = z.enum(['large', 'base', 'small']);
39+
const zDepthAnythingModelSize = z.enum(['large', 'base', 'small', 'small_v2']);
4040
export type DepthAnythingModelSize = z.infer<typeof zDepthAnythingModelSize>;
4141
export const isDepthAnythingModelSize = (v: unknown): v is DepthAnythingModelSize =>
4242
zDepthAnythingModelSize.safeParse(v).success;
@@ -298,7 +298,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
298298
buildDefaults: () => ({
299299
id: 'depth_anything_image_processor',
300300
type: 'depth_anything_image_processor',
301-
model_size: 'small',
301+
model_size: 'small_v2',
302302
}),
303303
buildNode: (image, config) => ({
304304
...config,

invokeai/frontend/web/src/services/api/schema.ts

Lines changed: 260 additions & 127 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)