Adding Depth Anything V2 to Transformers
Author: MackinationsAi
Pull request: yes

# What does this PR do?
This version of transformers v4.44.1 has the depth_anything_v2 models added in for use w/ sd-webui-controlnet, as well as forge. In addition it has all of the necessary additions for the huggingface transformers library/page. I have tested it, using the transformers-4.44.1-py3-none-any.whl I built & it works for both a1111 & forge, in addition it passed the test you have us run w/ no errors.

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc 

Documentation: @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
The test_torch failed is w/ the main repo (I didn't touch this script), has nothing to do w/ my additions. ```FAILED tests/trainer/test_trainer_seq2seq.py::Seq2seqTrainerTester::test_bad_generation_config_fail_early - AssertionError: ValueError not raised
=========== 1 failed, 2824 passed, 4025 skipped in 145.18s (0:02:25) ===========``` My version of this - tests/trainer/test_trainer_seq2seq.py is identical to your main. I would pass the run_tests is this was fixed.

Not sure how to fix this - ```Would reformat: tests/models/depth_anything_v2/test_modeling_depth_anything_v2.py
1 file would be reformatted, 2703 files already formatted
Exited with code exit status 1```

tests_pipelines_tf failed also has nothing to do w/ my pull request & stems from the main repo. ```FAILED tests/models/roberta/test_modeling_tf_roberta.py::TFRobertaModelTest::test_pipeline_text_classification - requests.exceptions.ReadTimeout: (ReadTimeoutError("HTTPSConnectionPool(host='huggingface.co', port=443): Read timed out. (read timeout=10)"), '(Request ID: 4c671cea-c951-4a22-9703-0fb0a2fb9d85)')
=========== 1 failed, 207 passed, 7848 skipped in 276.69s (0:04:36) ============```

Tired to fix this but the suggested fix didn't work. ```Traceback (most recent call last):
  File "/root/transformers/utils/check_dummies.py", line 237, in <module>
    check_dummies(args.fix_and_overwrite)
  File "/root/transformers/utils/check_dummies.py", line 225, in check_dummies
    raise ValueError(
ValueError: The main __init__ has objects that are not present in transformers.utils.dummy_pt_objects.py. Run `make fix-copies` to fix this.
Exited with code exit status 1```

Other than the reformatted portion, my additions aren't throwing up any errors or failures. Please help me make any other necessary changes to get Depth Anything V2 added to Transformers!

Hi @MackinationsAi, thanks for opening a PR! 
There's a PR already opened for this model addition #31522 


> Hi @MackinationsAi, thanks for opening a PR! There's a PR already opened for this model addition #31522

Hi @amyeroberts, thank you for reaching out. I haven't seen anything that works for Depth Anything V2 on the HF - transformers page. I built a preprocessor in sd-webui-controlnet for depth anything v2 that is working off of the transformer .whl connected to this PR. https://github.com/Mikubill/sd-webui-controlnet/pull/2977. If I'm wrong & transformers already supports Depth Anything V2 then my apologies!

Hi @MackinationsAi, thanks for sharing your work! 

The PR #31522 is still open, so the model isn't available yet in transformers but should be soon. Looking [at the comments](https://github.com/huggingface/transformers/pull/31522#issuecomment-2199900198) and the [relevant org on the hub](https://huggingface.co/depth-anything) it seems it's pending a transfer of converted checkpoints. 

> Hi @MackinationsAi, thanks for sharing your work!
> 
> The PR #31522 is still open, so the model isn't available yet in transformers but should be soon. Looking [at the comments](https://github.com/huggingface/transformers/pull/31522#issuecomment-2199900198) and the [relevant org on the hub](https://huggingface.co/depth-anything) it seems it's pending a transfer of converted checkpoints.

Gotcha, I'm glad to hear that it will be in transformers soon. If you all need anything that's already functional & formatted to your guidelines checkout the 11 file changes above. Otherwise seems like you can close this PR then. Appreciate your time @amyeroberts!