Upload копия_блокнота__turtorial_ipynb_ (3).py
Browse files
копия_блокнота__turtorial_ipynb_ (3).py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""Копия_блокнота_"turtorial_ipynb".ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/github/kisa-misa/YOLOv5_Torchvision-Yekaterinburg-crossroads-results/blob/main/%D0%9A%D0%BE%D0%BF%D0%B8%D1%8F_%D0%B1%D0%BB%D0%BE%D0%BA%D0%BD%D0%BE%D1%82%D0%B0_%22turtorial_ipynb%22.ipynb
|
8 |
+
|
9 |
+
# Setup
|
10 |
+
Clone repo and install dependencies.
|
11 |
+
"""
|
12 |
+
|
13 |
+
# Commented out IPython magic to ensure Python compatibility.
|
14 |
+
!git clone https://github.com/meituan/YOLOv6.git
|
15 |
+
# %cd YOLOv6
|
16 |
+
# %pip install -r requirements.txt
|
17 |
+
|
18 |
+
"""# Inference
|
19 |
+
First, download a pretrained model from the YOLOv6 [release](https://github.com/meituan/YOLOv6/releases).
|
20 |
+
|
21 |
+
### You can also use torch.hub style to load the pretrained model or custom model to inference.
|
22 |
+
"""
|
23 |
+
|
24 |
+
# Download a pretrained model
|
25 |
+
import torch
|
26 |
+
torch.hub.download_url_to_file('https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6s.pt', 'yolov6s.pt')
|
27 |
+
|
28 |
+
import torch
|
29 |
+
|
30 |
+
model_local = torch.hub.load('.', 'yolov6n', source='local')
|
31 |
+
|
32 |
+
img_path = 'data/images/image1.jpg'
|
33 |
+
prediction = model_local.predict(img_path)
|
34 |
+
|
35 |
+
model_local.show_predict(img_path)
|