Upload folder using huggingface_hub
#1
by
YiYiXu
- opened
- __pycache__/block.cpython-311.pyc +0 -0
- block.py +54 -0
- config.json +21 -0
- requirements.txt +1 -0
__pycache__/block.cpython-311.pyc
ADDED
|
Binary file (2.69 kB). View file
|
|
|
block.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
from diffusers.pipelines.modular_pipeline import PipelineState, PipelineBlock
|
| 5 |
+
from diffusers.pipelines.modular_pipeline_utils import (
|
| 6 |
+
InputParam,
|
| 7 |
+
ComponentSpec,
|
| 8 |
+
OutputParam,
|
| 9 |
+
)
|
| 10 |
+
from image_gen_aux import DepthPreprocessor
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class DepthProcessorBlock(PipelineBlock):
|
| 14 |
+
@property
|
| 15 |
+
def expected_components(self):
|
| 16 |
+
return [
|
| 17 |
+
ComponentSpec(
|
| 18 |
+
name="depth_processor",
|
| 19 |
+
type_hint=DepthPreprocessor,
|
| 20 |
+
repo="depth-anything/Depth-Anything-V2-Large-hf",
|
| 21 |
+
)
|
| 22 |
+
]
|
| 23 |
+
|
| 24 |
+
@property
|
| 25 |
+
def inputs(self) -> List[InputParam]:
|
| 26 |
+
return [
|
| 27 |
+
InputParam(
|
| 28 |
+
"image",
|
| 29 |
+
PipelineImageInput,
|
| 30 |
+
required=True,
|
| 31 |
+
description="Image(s) to use to extract depth maps",
|
| 32 |
+
)
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
@property
|
| 36 |
+
def intermediates_outputs(self) -> List[OutputParam]:
|
| 37 |
+
return [
|
| 38 |
+
OutputParam(
|
| 39 |
+
"image",
|
| 40 |
+
type_hint=torch.Tensor,
|
| 41 |
+
description="Depth Map(s) of input Image(s)",
|
| 42 |
+
),
|
| 43 |
+
]
|
| 44 |
+
|
| 45 |
+
@torch.no_grad()
|
| 46 |
+
def __call__(self, pipeline, state: PipelineState) -> PipelineState:
|
| 47 |
+
block_state = self.get_block_state(state)
|
| 48 |
+
|
| 49 |
+
image = block_state.image
|
| 50 |
+
depth_map = pipeline.depth_processor(image)
|
| 51 |
+
block_state.image = depth_map.to(block_state.device)
|
| 52 |
+
|
| 53 |
+
self.add_block_state(state, block_state)
|
| 54 |
+
return pipeline, state
|
config.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "DepthProcessorBlock",
|
| 3 |
+
"auto_map": {
|
| 4 |
+
"PipelineBlock": "block.DepthProcessorBlock"
|
| 5 |
+
},
|
| 6 |
+
"_component_names": [
|
| 7 |
+
"depth_processor"
|
| 8 |
+
],
|
| 9 |
+
"depth_processor": [
|
| 10 |
+
null,
|
| 11 |
+
null,
|
| 12 |
+
{
|
| 13 |
+
"repo": "depth-anything/Depth-Anything-V2-Large-hf",
|
| 14 |
+
"type_hint": [
|
| 15 |
+
"image_gen_aux",
|
| 16 |
+
"DepthPreprocessor"
|
| 17 |
+
],
|
| 18 |
+
"variant": null
|
| 19 |
+
}
|
| 20 |
+
]
|
| 21 |
+
}
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
git+https://github.com/huggingface/image_gen_aux.git
|