Team Ai
Apppublic

Arulkumar03/Fox_Sheep_Detector_Computer_Vision_model

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes
conf.py396 linesDownload Raw Back to docs
1# -*- coding: utf-8 -*-2# Copyright (c) Facebook, Inc. and its affiliates.3 4# flake8: noqa5 6# Configuration file for the Sphinx documentation builder.7#8# This file does only contain a selection of the most common options. For a9# full list see the documentation:10# http://www.sphinx-doc.org/en/master/config11 12# -- Path setup --------------------------------------------------------------13 14# If extensions (or modules to document with autodoc) are in another directory,15# add these directories to sys.path here. If the directory is relative to the16# documentation root, use os.path.abspath to make it absolute, like shown here.17#18import os19import sys20from unittest import mock21from sphinx.domains import Domain22from typing import Dict, List, Tuple23 24# The theme to use for HTML and HTML Help pages.  See the documentation for25# a list of builtin themes.26#27import sphinx_rtd_theme28 29 30class GithubURLDomain(Domain):31    """32    Resolve certain links in markdown files to github source.33    """34 35    name = "githuburl"36    ROOT = "https://github.com/facebookresearch/detectron2/blob/main/"37    LINKED_DOC = ["tutorials/install", "tutorials/getting_started"]38 39    def resolve_any_xref(self, env, fromdocname, builder, target, node, contnode):40        github_url = None41        if not target.endswith("html") and target.startswith("../../"):42            url = target.replace("../", "")43            github_url = url44        if fromdocname in self.LINKED_DOC:45            # unresolved links in these docs are all github links46            github_url = target47 48        if github_url is not None:49            if github_url.endswith("MODEL_ZOO") or github_url.endswith("README"):50                # bug of recommonmark.51                # https://github.com/readthedocs/recommonmark/blob/ddd56e7717e9745f11300059e4268e204138a6b1/recommonmark/parser.py#L152-L15552                github_url += ".md"53            print("Ref {} resolved to github:{}".format(target, github_url))54            contnode["refuri"] = self.ROOT + github_url55            return [("githuburl:any", contnode)]56        else:57            return []58 59 60# to support markdown61from recommonmark.parser import CommonMarkParser62 63sys.path.insert(0, os.path.abspath("../"))64os.environ["_DOC_BUILDING"] = "True"65DEPLOY = os.environ.get("READTHEDOCS") == "True"66 67 68# -- Project information -----------------------------------------------------69 70# fmt: off71try:72    import torch  # noqa73except ImportError:74    for m in [75        "torch", "torchvision", "torch.nn", "torch.nn.parallel", "torch.distributed", "torch.multiprocessing", "torch.autograd",76        "torch.autograd.function", "torch.nn.modules", "torch.nn.modules.utils", "torch.utils", "torch.utils.data", "torch.onnx",77        "torchvision", "torchvision.ops",78    ]:79        sys.modules[m] = mock.Mock(name=m)80    sys.modules['torch'].__version__ = "1.7"  # fake version81    HAS_TORCH = False82else:83    try:84        torch.ops.detectron2 = mock.Mock(name="torch.ops.detectron2")85    except:86        pass87    HAS_TORCH = True88 89for m in [90    "cv2", "scipy", "portalocker", "detectron2._C",91    "pycocotools", "pycocotools.mask", "pycocotools.coco", "pycocotools.cocoeval",92    "google", "google.protobuf", "google.protobuf.internal", "onnx",93    "caffe2", "caffe2.proto", "caffe2.python", "caffe2.python.utils", "caffe2.python.onnx", "caffe2.python.onnx.backend",94]:95    sys.modules[m] = mock.Mock(name=m)96# fmt: on97sys.modules["cv2"].__version__ = "3.4"98 99import detectron2  # isort: skip100 101if HAS_TORCH:102    from detectron2.utils.env import fixup_module_metadata103 104    fixup_module_metadata("torch.nn", torch.nn.__dict__)105    fixup_module_metadata("torch.utils.data", torch.utils.data.__dict__)106 107 108project = "detectron2"109copyright = "2019-2020, detectron2 contributors"110author = "detectron2 contributors"111 112# The short X.Y version113version = detectron2.__version__114# The full version, including alpha/beta/rc tags115release = version116 117 118# -- General configuration ---------------------------------------------------119 120# If your documentation needs a minimal Sphinx version, state it here.121#122needs_sphinx = "3.0"123 124# Add any Sphinx extension module names here, as strings. They can be125# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom126# ones.127extensions = [128    "recommonmark",129    "sphinx.ext.autodoc",130    "sphinx.ext.napoleon",131    "sphinx.ext.intersphinx",132    "sphinx.ext.todo",133    "sphinx.ext.coverage",134    "sphinx.ext.mathjax",135    "sphinx.ext.viewcode",136    "sphinx.ext.githubpages",137]138 139# -- Configurations for plugins ------------140napoleon_google_docstring = True141napoleon_include_init_with_doc = True142napoleon_include_special_with_doc = True143napoleon_numpy_docstring = False144napoleon_use_rtype = False145autodoc_inherit_docstrings = False146autodoc_member_order = "bysource"147 148if DEPLOY:149    intersphinx_timeout = 10150else:151    # skip this when building locally152    intersphinx_timeout = 0.5153intersphinx_mapping = {154    "python": ("https://docs.python.org/3.7", None),155    "numpy": ("https://docs.scipy.org/doc/numpy/", None),156    "torch": ("https://pytorch.org/docs/master/", None),157}158# -------------------------159 160 161# Add any paths that contain templates here, relative to this directory.162templates_path = ["_templates"]163 164source_suffix = [".rst", ".md"]165 166# The master toctree document.167master_doc = "index"168 169# The language for content autogenerated by Sphinx. Refer to documentation170# for a list of supported languages.171#172# This is also used if you do content translation via gettext catalogs.173# Usually you set "language" from the command line for these cases.174language = None175 176# List of patterns, relative to source directory, that match files and177# directories to ignore when looking for source files.178# This pattern also affects html_static_path and html_extra_path.179exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "build", "README.md", "tutorials/README.md"]180 181# The name of the Pygments (syntax highlighting) style to use.182pygments_style = "sphinx"183 184 185# -- Options for HTML output -------------------------------------------------186 187html_theme = "sphinx_rtd_theme"188html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]189 190# Theme options are theme-specific and customize the look and feel of a theme191# further.  For a list of options available for each theme, see the192# documentation.193#194# html_theme_options = {}195 196# Add any paths that contain custom static files (such as style sheets) here,197# relative to this directory. They are copied after the builtin static files,198# so a file named "default.css" will overwrite the builtin "default.css".199html_static_path = ["_static"]200html_css_files = ["css/custom.css"]201 202# Custom sidebar templates, must be a dictionary that maps document names203# to template names.204#205# The default sidebars (for documents that don't match any pattern) are206# defined by theme itself.  Builtin themes are using these templates by207# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',208# 'searchbox.html']``.209#210# html_sidebars = {}211 212 213# -- Options for HTMLHelp output ---------------------------------------------214 215# Output file base name for HTML help builder.216htmlhelp_basename = "detectron2doc"217 218 219# -- Options for LaTeX output ------------------------------------------------220 221latex_elements = {222    # The paper size ('letterpaper' or 'a4paper').223    #224    # 'papersize': 'letterpaper',225    # The font size ('10pt', '11pt' or '12pt').226    #227    # 'pointsize': '10pt',228    # Additional stuff for the LaTeX preamble.229    #230    # 'preamble': '',231    # Latex figure (float) alignment232    #233    # 'figure_align': 'htbp',234}235 236# Grouping the document tree into LaTeX files. List of tuples237# (source start file, target name, title,238#  author, documentclass [howto, manual, or own class]).239latex_documents = [240    (master_doc, "detectron2.tex", "detectron2 Documentation", "detectron2 contributors", "manual")241]242 243 244# -- Options for manual page output ------------------------------------------245 246# One entry per manual page. List of tuples247# (source start file, name, description, authors, manual section).248man_pages = [(master_doc, "detectron2", "detectron2 Documentation", [author], 1)]249 250 251# -- Options for Texinfo output ----------------------------------------------252 253# Grouping the document tree into Texinfo files. List of tuples254# (source start file, target name, title, author,255#  dir menu entry, description, category)256texinfo_documents = [257    (258        master_doc,259        "detectron2",260        "detectron2 Documentation",261        author,262        "detectron2",263        "One line description of project.",264        "Miscellaneous",265    )266]267 268 269# -- Options for todo extension ----------------------------------------------270 271# If true, `todo` and `todoList` produce output, else they produce nothing.272todo_include_todos = True273 274 275def autodoc_skip_member(app, what, name, obj, skip, options):276    # we hide something deliberately277    if getattr(obj, "__HIDE_SPHINX_DOC__", False):278        return True279 280    # Hide some that are deprecated or not intended to be used281    HIDDEN = {282        "ResNetBlockBase",283        "GroupedBatchSampler",284        "build_transform_gen",285        "apply_transform_gens",286        "TransformGen",287        "apply_augmentations",288        "StandardAugInput",289        "build_batch_data_loader",290        "draw_panoptic_seg_predictions",291        "WarmupCosineLR",292        "WarmupMultiStepLR",293        "downgrade_config",294        "upgrade_config",295        "add_export_config",296    }297    try:298        if name in HIDDEN or (299            hasattr(obj, "__doc__") and obj.__doc__.lower().strip().startswith("deprecated")300        ):301            print("Skipping deprecated object: {}".format(name))302            return True303    except:304        pass305    return skip306 307 308_PAPER_DATA = {309    "resnet": ("1512.03385", "Deep Residual Learning for Image Recognition"),310    "fpn": ("1612.03144", "Feature Pyramid Networks for Object Detection"),311    "mask r-cnn": ("1703.06870", "Mask R-CNN"),312    "faster r-cnn": (313        "1506.01497",314        "Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks",315    ),316    "deformconv": ("1703.06211", "Deformable Convolutional Networks"),317    "deformconv2": ("1811.11168", "Deformable ConvNets v2: More Deformable, Better Results"),318    "panopticfpn": ("1901.02446", "Panoptic Feature Pyramid Networks"),319    "retinanet": ("1708.02002", "Focal Loss for Dense Object Detection"),320    "cascade r-cnn": ("1712.00726", "Cascade R-CNN: Delving into High Quality Object Detection"),321    "lvis": ("1908.03195", "LVIS: A Dataset for Large Vocabulary Instance Segmentation"),322    "rrpn": ("1703.01086", "Arbitrary-Oriented Scene Text Detection via Rotation Proposals"),323    "imagenet in 1h": ("1706.02677", "Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour"),324    "xception": ("1610.02357", "Xception: Deep Learning with Depthwise Separable Convolutions"),325    "mobilenet": (326        "1704.04861",327        "MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications",328    ),329    "deeplabv3+": (330        "1802.02611",331        "Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation",332    ),333    "dds": ("2003.13678", "Designing Network Design Spaces"),334    "scaling": ("2103.06877", "Fast and Accurate Model Scaling"),335    "fcos": ("2006.09214", "FCOS: A Simple and Strong Anchor-free Object Detector"),336    "rethinking-batchnorm": ("2105.07576", 'Rethinking "Batch" in BatchNorm'),337    "vitdet": ("2203.16527", "Exploring Plain Vision Transformer Backbones for Object Detection"),338    "mvitv2": (339        "2112.01526",340        "MViTv2: Improved Multiscale Vision Transformers for Classification and Detection",341    ),342    "swin": (343        "2103.14030",344        "Swin Transformer: Hierarchical Vision Transformer using Shifted Windows",345    ),346    "omni3d": (347        "2207.10660",348        "Omni3D: A Large Benchmark and Model for 3D Object Detection in the Wild",349    ),350}351 352 353def paper_ref_role(354    typ: str,355    rawtext: str,356    text: str,357    lineno: int,358    inliner,359    options: Dict = {},360    content: List[str] = [],361):362    """363    Parse :paper:`xxx`. Similar to the "extlinks" sphinx extension.364    """365    from docutils import nodes, utils366    from sphinx.util.nodes import split_explicit_title367 368    text = utils.unescape(text)369    has_explicit_title, title, link = split_explicit_title(text)370    link = link.lower()371    if link not in _PAPER_DATA:372        inliner.reporter.warning("Cannot find paper " + link)373        paper_url, paper_title = "#", link374    else:375        paper_url, paper_title = _PAPER_DATA[link]376        if "/" not in paper_url:377            paper_url = "https://arxiv.org/abs/" + paper_url378    if not has_explicit_title:379        title = paper_title380    pnode = nodes.reference(title, title, internal=False, refuri=paper_url)381    return [pnode], []382 383 384def setup(app):385    from recommonmark.transform import AutoStructify386 387    app.add_domain(GithubURLDomain)388    app.connect("autodoc-skip-member", autodoc_skip_member)389    app.add_role("paper", paper_ref_role)390    app.add_config_value(391        "recommonmark_config",392        {"enable_math": True, "enable_inline_math": True, "enable_eval_rst": True},393        True,394    )395    app.add_transform(AutoStructify)396