WKO_PROJEKT/yolov5/Untitled0.ipynb

1 line
15 KiB
Plaintext
Raw Permalink Normal View History

2023-02-01 23:02:19 +01:00
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyOXFHc2xvoxJ7m00QoFZhde"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":1,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":235},"id":"zmkKG8v8f3Hx","executionInfo":{"status":"error","timestamp":1675163073561,"user_tz":-60,"elapsed":4279,"user":{"displayName":"marti Xooo","userId":"17000102553335328898"}},"outputId":"819779e2-d89b-49a4-bb60-c873c1b841ce"},"outputs":[{"output_type":"error","ename":"NameError","evalue":"ignored","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)","\u001b[0;32m<ipython-input-1-4ff1ecfd1ccc>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0mFILE\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPath\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0m__file__\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mresolve\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0mROOT\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mFILE\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparents\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;31m# YOLOv5 root directory\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mROOT\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;31mNameError\u001b[0m: name '__file__' is not defined"]}],"source":["\n","import argparse\n","import os\n","import platform\n","import sys\n","from pathlib import Path\n","\n","import torch\n","\n","FILE = Path(__file__).resolve()\n","ROOT = FILE.parents[0] # YOLOv5 root directory\n","if str(ROOT) not in sys.path:\n"," sys.path.append(str(ROOT)) # add ROOT to PATH\n","ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative\n","\n","from models.common import DetectMultiBackend\n","from utils.dataloaders import IMG_FORMATS, VID_FORMATS, LoadImages, LoadScreenshots, LoadStreams\n","from utils.general import (LOGGER, Profile, check_file, check_img_size, check_imshow, check_requirements, colorstr, cv2,\n"," increment_path, non_max_suppression, print_args, scale_boxes, strip_optimizer, xyxy2xywh)\n","from utils.plots import Annotator, colors, save_one_box\n","from utils.torch_utils import select_device, smart_inference_mode\n","\n","\n","@smart_inference_mode()\n","def run(\n"," weights=ROOT / 'yolov5s.pt', # model path or triton URL\n"," source=ROOT / 'data/images', # file/dir/URL/glob/screen/0(webcam)\n"," data=ROOT / 'data/coco128.yaml', # dataset.yaml path\n"," imgsz=(640, 640), # inference size (height, width)\n"," conf_thres=0.25, # confidence threshold\n"," iou_thres=0.45, # NMS IOU threshold\n"," max_det=1000, # maximum detections per image\n"," device='', # cuda device, i.e. 0 or 0,1,2,3 or cpu\n"," view_img=False, # show results\n"," save_txt=False, # save results to *.txt\n"," save_conf=False, # save confidences in --save-txt labels\n"," save_crop=False, # save cropped prediction boxes\n"," nosave=False, # do not save images/videos\n"," classes=None, # filter by class: --class 0, or --class 0 2 3\n"," agnostic_nms=False, # class-agnostic NMS\n"," augment=False, # augmented inference\n