Skip to content

Commit

Permalink
chore: yolox export filenames and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
beniz committed Jan 27, 2022
1 parent 02872eb commit 024d241
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions tools/torch/README.md
Expand Up @@ -16,3 +16,23 @@ Utility script to trace NLP models from Huggingface's pytorch-transformers. Requ
pip3 install --user pytorch-transformers==1.1
```
At the moment a CUDA model can not be convertible to CPU and vice versa. This may change with a future version of pytorch-transformers.

* `trace_yolox.py`

Requirements:

```
pip3 install thop
pip3 install loguru
```
and custom YOLOX repository:
```
git clone https://github.com/jolibrain/YOLOX.git
git checkout jit_script
```

Then to export a pretrained model before using it with DeepDetect:

```
python3 trace_yolox.py yolox-m -o /path/to/output/ --yolox_path /path/to/YOLOX/ --backbone_weights /path/to/pretrained/yolox_m.pth --num_classes 2 --img_width 300 --img_height 300
```
2 changes: 1 addition & 1 deletion tools/torch/trace_yolox.py
Expand Up @@ -104,7 +104,7 @@ def main():
model.to(device)
model.eval()

filename += ".pt"
filename += "-" + str(args.img_width) + 'x' + str(args.img_height) + "_cls" + str(args.num_classes) + ".pt"
script_module = torch.jit.script(model)
logging.info("Save jit model at %s" % filename)
script_module.save(filename)
Expand Down

0 comments on commit 024d241

Please sign in to comment.