Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing copyright, cleanup and fix docs #110

Merged
merged 5 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: "\U0001F41B Bug Report"
about: Create a report to help us improve torchvision
title: ''
labels: bug
labels: bug / fix
assignees: ''

---
Expand Down
1 change: 1 addition & 0 deletions docs/source/notebooks/export_relay_inference_tvm.ipynb
1 change: 1 addition & 0 deletions docs/source/notebooks/load_model_as_ultralytics.ipynb
1 change: 1 addition & 0 deletions docs/source/notebooks/visualize_jit_models.ipynb
8 changes: 7 additions & 1 deletion yolort/utils/graph_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Copyright (c) 2020, Thomas Viehmann. All Rights Reserved.
"""
Plotting a graph with bad gradient nodes marked in red.
Visualizing JIT Modules

Mostly copy-paste from https://github.com/t-vi/pytorch-tvmisc/tree/master/hacks
with license under the CC-BY-SA 4.0.

Please link to Thomas's blog post or the original github source (linked from the
blog post) with the attribution notice.
"""
from graphviz import Digraph

Expand Down
8 changes: 5 additions & 3 deletions yolort/utils/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

import torch
from torch import Tensor
from torchvision import transforms

from torchvision.ops.boxes import box_convert

from typing import Optional

import logging
logger = logging.getLogger(__name__)



def plot_one_box(box, img, color=None, label=None, line_thickness=None):
Expand Down Expand Up @@ -47,7 +47,7 @@ def cv2_imshow(
convert_bgr_to_rgb: bool = True,
) -> None:
"""
A replacement for cv2.imshow() for use in Jupyter notebooks.
A replacement of cv2.imshow() for using in Jupyter notebooks.

Args:
image (np.ndarray):. shape (N, M) or (N, M, 1) is an NxM grayscale image. shape (N, M, 3)
Expand Down Expand Up @@ -194,6 +194,8 @@ def load_names(category_path):

@torch.no_grad()
def overlay_boxes(detections, path, time_consume, args):
logger = logging.getLogger(__name__)

img = cv2.imread(path) if args.save_img else None

for i, pred in enumerate(detections): # detections per image
Expand Down
11 changes: 6 additions & 5 deletions yolort/utils/yolo2coco.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (c) 2020, Zhiqiang Wang. All Rights Reserved.
from pathlib import Path
import argparse

Expand All @@ -7,7 +8,7 @@
from .builtin_meta import COCO_CATEGORIES


class Yolo2Coco:
class YOLO2COCO:

def __init__(self, root, split):
self.info = {
Expand All @@ -24,8 +25,8 @@ def __init__(self, root, split):
self.type = 'instances'
self.split = split
self.root_path = Path(root)
self.label_path = self.root_path.joinpath('labels')
self.annotation_root = self.root_path.joinpath('annotations')
self.label_path = self.root_path / 'labels'
self.annotation_root = self.root_path / 'annotations'
Path(self.annotation_root).mkdir(parents=True, exist_ok=True)

self.categories = [{
Expand All @@ -48,7 +49,7 @@ def generate(self, coco_type='instances', annotation_format='bbox'):
'annotations': annotations,
'categories': self.categories,
}
output_path = self.annotation_root.joinpath(f'{coco_type}_{self.split}.json')
output_path = self.annotation_root / f'{coco_type}_{self.split}.json'
with open(output_path, 'w') as json_file:
json.dump(json_data, json_file, sort_keys=True)

Expand Down Expand Up @@ -124,5 +125,5 @@ def _get_annotation(vertex_info, height, width):

args = parser.parse_args()

converter = Yolo2Coco(args.data_path, args.split)
converter = YOLO2COCO(args.data_path, args.split)
converter.generate()