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

Update default parameters #9

Merged
merged 4 commits into from
Dec 2, 2020
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
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ python -m utils.updated_checkpoint [--checkpoint_path ./yolov5s.pt]

### 🔥 Loading via `torch.hub`

The models are also available via torch hub, to load `yolov5` with pretrained weights simply do:
The models are also available via torch hub, to load `yolov5s` with pretrained weights simply do:

```python
model = torch.hub.load('zhiqwang/yolov5-rt-stack', 'yolov5', pretrained=True)
model = torch.hub.load('zhiqwang/yolov5-rt-stack', 'yolov5s', pretrained=True)
```

### ✨ Inference on `PyTorch` backend
Expand All @@ -52,8 +52,7 @@ conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
To read a source image and detect its objects run:

```bash
python -m detect [--model_cfg yolov5s.yaml]
[--input_source YOUR_IMAGE_SOURCE_DIR]
python -m detect [--input_source YOUR_IMAGE_SOURCE_DIR]
[--labelmap ./notebooks/assets/coco.names]
[--output_dir ./data-bin/output]
[--min_size 640]
Expand Down
6 changes: 2 additions & 4 deletions detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from torchvision.ops import box_convert

from utils.image_utils import plot_one_box
from hubconf import yolov5
from hubconf import yolov5s


def load_names(category_path):
Expand Down Expand Up @@ -86,7 +86,7 @@ def main(args):
print(args)
device = torch.device("cuda") if torch.cuda.is_available() and args.gpu else torch.device("cpu")

model = yolov5(
model = yolov5s(
pretrained=True,
min_size=args.min_size,
max_size=args.max_size,
Expand Down Expand Up @@ -132,8 +132,6 @@ def main(args):
import argparse
parser = argparse.ArgumentParser(description=__doc__)

parser.add_argument('--model_cfg', type=str, default='yolov5s.yaml',
help='path where the model cfg in')
parser.add_argument('--labelmap', type=str, default='./notebooks/assets/coco.names',
help='path where the coco category in')
parser.add_argument('--input_source', type=str, default='./notebooks/assets/zidane.jpg',
Expand Down
3 changes: 1 addition & 2 deletions hubconf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Optional list of dependencies required by the package
dependencies = ['yaml', 'torch', 'torchvision']

from models import yolov5, yolov5s, yolov5m, yolov5l
from models import yolov5_onnx
from models import yolov5s, yolov5m, yolov5l
6 changes: 3 additions & 3 deletions notebooks/export-onnx-inference-onnxruntime.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
"metadata": {},
"outputs": [],
"source": [
"path0 = 'notebooks/assets/bus.jpg'\n",
"path1 = 'notebooks/assets/zidane.jpg'\n",
"path0 = './notebooks/assets/bus.jpg'\n",
"path1 = './notebooks/assets/zidane.jpg'\n",
"\n",
"img_test0 = read_image(path0, is_half=False)\n",
"img_test0 = img_test0.to(device)\n",
Expand Down Expand Up @@ -350,4 +350,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
4 changes: 2 additions & 2 deletions notebooks/inference-pytorch-export-libtorch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"import torch\n",
"from torch import nn\n",
"\n",
"from hubconf import yolov5\n",
"from hubconf import yolov5s\n",
"\n",
"from detect import read_image, load_names, overlay_boxes\n",
"from utils.image_utils import cv2_imshow"
Expand Down Expand Up @@ -50,7 +50,7 @@
"metadata": {},
"outputs": [],
"source": [
"model = yolov5(pretrained=True, min_size=320, max_size=416, score_thresh=0.5)"
"model = yolov5s(pretrained=True, min_size=320, max_size=416, score_thresh=0.5)"
]
},
{
Expand Down
17 changes: 5 additions & 12 deletions notebooks/visualize-jit-models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"import torchvision\n",
"\n",
"from utils.graph_utils import make_graph\n",
"from hubconf import yolov5"
"from hubconf import yolov5s"
]
},
{
Expand All @@ -19,7 +19,7 @@
"metadata": {},
"outputs": [],
"source": [
"model = yolov5(pretrained=True)\n",
"model = yolov5s(pretrained=True)\n",
"model = model.eval()"
]
},
Expand Down Expand Up @@ -88,7 +88,7 @@
],
"source": [
"d = make_graph(tm.m, classes_to_visit={})\n",
"d.render('yolov5.highlevel')"
"d.render('./data-bin/output/yolov5.highlevel')"
]
},
{
Expand Down Expand Up @@ -247,7 +247,7 @@
],
"source": [
"d = make_graph(tm.m, classes_to_visit={'YoloHead'})\n",
"d.render(\"yolov5.detail\")"
"d.render(\"./data-bin/output/yolov5.detail\")"
]
},
{
Expand Down Expand Up @@ -476,13 +476,6 @@
"source": [
"d"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -506,4 +499,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Cython
matplotlib>=3.2.2
numpy>=1.18.5
opencv-python>=4.1.2
pillow
PyYAML>=5.3
scipy>=1.4.1
Expand Down