Arulkumar03/Wheat_HEAD_Detection_Counting_ComputerVision_Model
0
1#!/usr/bin/env python2# Copyright (c) Facebook, Inc. and its affiliates.3# -*- coding: utf-8 -*-4 5import argparse6 7template = """<details><summary> install </summary><pre><code>\8python -m pip install detectron2{d2_version} -f \\9 https://dl.fbaipublicfiles.com/detectron2/wheels/{cuda}/torch{torch}/index.html10</code></pre> </details>"""11CUDA_SUFFIX = {12 "11.3": "cu113",13 "11.1": "cu111",14 "11.0": "cu110",15 "10.2": "cu102",16 "10.1": "cu101",17 "10.0": "cu100",18 "9.2": "cu92",19 "cpu": "cpu",20}21 22 23def gen_header(torch_versions):24 return '<table class="docutils"><tbody><th width="80"> CUDA </th>' + "".join(25 [26 '<th valign="bottom" align="left" width="100">torch {}</th>'.format(t)27 for t in torch_versions28 ]29 )30 31 32if __name__ == "__main__":33 parser = argparse.ArgumentParser()34 parser.add_argument("--d2-version", help="detectron2 version number, default to empty")35 args = parser.parse_args()36 d2_version = f"=={args.d2_version}" if args.d2_version else ""37 38 all_versions = (39 [("1.8", k) for k in ["11.1", "10.2", "10.1", "cpu"]]40 + [("1.9", k) for k in ["11.1", "10.2", "cpu"]]41 + [("1.10", k) for k in ["11.3", "11.1", "10.2", "cpu"]]42 )43 44 torch_versions = sorted(45 {k[0] for k in all_versions}, key=lambda x: int(x.split(".")[1]), reverse=True46 )47 cuda_versions = sorted(48 {k[1] for k in all_versions}, key=lambda x: float(x) if x != "cpu" else 0, reverse=True49 )50 51 table = gen_header(torch_versions)52 for cu in cuda_versions:53 table += f""" <tr><td align="left">{cu}</td>"""54 cu_suffix = CUDA_SUFFIX[cu]55 for torch in torch_versions:56 if (torch, cu) in all_versions:57 cell = template.format(d2_version=d2_version, cuda=cu_suffix, torch=torch)58 else:59 cell = ""60 table += f"""<td align="left">{cell} </td> """61 table += "</tr>"62 table += "</tbody></table>"63 print(table)64 