{"id":354934,"date":"2024-05-20T22:58:21","date_gmt":"2024-05-20T22:58:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=354934"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=354934","title":{"rendered":"<span>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 YOLO \u0438 ResNet \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/13f\/9db\/115\/13f9db1158208517d24fe63fbfd292d9.png\" width=\"1024\" height=\"680\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/13f\/9db\/115\/13f9db1158208517d24fe63fbfd292d9.png\"\/><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u00a0\u0432\u0430\u043c\u0438 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438 <a href=\"https:\/\/newtechaudit.ru\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 NTA<\/a> \u041f\u043e\u043f\u043e\u0432 \u0418\u0432\u0430\u043d \u0438 \u0427\u0438\u043c\u0431\u0435\u0435\u0432 \u0410\u043d\u0430\u0442\u043e\u043b\u0438\u0439.<\/p>\n<p>\u0412\u00a0\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u043c\u0438\u0440\u0435, \u0433\u0434\u0435 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0438\u0433\u0440\u0430\u044e\u0442 \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432\u00a0\u0441\u0444\u0435\u0440\u0435 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0434\u0438\u0430, \u043e\u043d\u043b\u0430\u0439\u043d\u2011\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e, \u0432\u0430\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f\u00a0\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430\u00a0\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445. \u0412\u00a0\u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0438\u0437\u00a0\u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 <strong>YOLO \u0438 ResNet<\/strong> \u0434\u043b\u044f\u00a0\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445.<\/p>\n<details class=\"spoiler\">\n<summary>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u043f\u043e \u043f\u043e\u0441\u0442\u0443<\/summary>\n<div class=\"spoiler__content\">\n<ul>\n<li>\n<p><a href=\"#%D0%BE%20%D0%BC%D0%BE%D0%B4%D0%B5%D0%BB%D1%8F%D1%85\" rel=\"noopener noreferrer nofollow\">\u041e \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#yolo\" rel=\"noopener noreferrer nofollow\">\u041c\u043e\u0434\u0435\u043b\u044c YOLO8x<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#resnet\" rel=\"noopener noreferrer nofollow\">\u041c\u043e\u0434\u0435\u043b\u044c RESNET101<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#%D1%80%D0%B5%D0%B7%D1%83%D0%BB%D1%8C%D1%82%D0%B0%D1%82%D1%8B\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 YOLO \u0438 Resnet<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#%D0%B8%D1%82%D0%BE%D0%B3%D0%B8\" rel=\"noopener noreferrer nofollow\">\u0418\u0442\u043e\u0433\u0438<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<h2>\u041e \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p><a class=\"anchor\" name=\"%D0%BE%20%D0%BC%D0%BE%D0%B4%D0%B5%D0%BB%D1%8F%D1%85\" id=\"\u043e \u043c\u043e\u0434\u0435\u043b\u044f\u0445\"><\/a><\/p>\n<p><strong>YOLO (You Only Look Once)<\/strong>\u00a0\u2014 \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437\u00a0\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u043b\u044f\u00a0\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430\u00a0\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u0432\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041e\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430\u00a0\u0441\u0432\u0435\u0440\u0442\u043e\u0447\u043d\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0435\u0437\u00a0\u0443\u0449\u0435\u0440\u0431\u0430 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. YOLO \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u00a0\u0441\u0435\u0442\u043a\u0443 \u044f\u0447\u0435\u0435\u043a \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0435.<\/p>\n<p><strong>ResNet (Residual Neural Network)<\/strong>\u00a0\u2014 \u044d\u0442\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u0430\u044f \u0434\u043b\u044f\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0430\u0442\u0443\u0445\u0430\u043d\u0438\u044f \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430. \u041e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u00abskip connections\u00bb \u0438\u043b\u0438 \u00abresidual connections\u00bb, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u00a0\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u043a\u00a0\u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u043c\u0438\u043d\u0443\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0441\u043b\u043e\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0443\u0447\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0435 \u0441\u0435\u0442\u0438 \u0441\u00a0\u043b\u0443\u0447\u0448\u0435\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u043b\u044f\u00a0\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445. \u0423\u00a0\u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432\u00a0\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u0445 \u0441\u0430\u0439\u0442\u0430 \u0414\u043e\u043c\u041a\u043b\u0438\u043a. \u041d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439\u00a0\u0431\u044b\u043b \u043f\u043e\u0438\u0441\u043a \u043d\u0430\u00a0\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u0442\u0430\u043a\u0438\u0445 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u0430\u043a\u00a0\u043e\u0440\u0443\u0436\u0438\u0435, \u0430\u043b\u043a\u043e\u0433\u043e\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u043f\u0438\u0442\u043a\u0438, \u0441\u0438\u0433\u0430\u0440\u0435\u0442\u044b \u0438\u043b\u0438\u00a0\u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0438\u0441\u0442\u0441\u043a\u0430\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0438\u043a\u0430.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0447\u0442\u0435\u043d\u0438\u0435 csv-\u0444\u0430\u0439\u043b\u0430 \u0441 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0438\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430.<\/p>\n<pre><code class=\"python\">import os import shutil from urllib.request import Request, urlopen  URL = 'https:\/\/img.dmclk.ru\/vitrina\/owner\/'  import pandas as pd from tqdm import tqdm  def loader(url_input, local_path):     url = URL + url_input     req = Request(url, headers={'User-Agent': 'Mozilla\/5.0'})      with urllib.request.urlopen(req) as response, open(local_path, 'wb') as out_file:         shutil.copyfileobj(response, out_file)  photo_df = pd.read_csv('full_sample_photo_res.csv', sep='^') photo_df.loc[:, 'list_url'] = photo_df['list_url'].apply(lambda x: x.split(',')) os.makedirs('photos', exist_ok=True)  df = photo_df.explode('list_url', ignore_index=True) for i in tqdm(df.index):     file_name = os.path.basename(df.loc[i, 'list_url'])     local_path = f'photos\/{file_name}'     loader(df.loc[i, 'list_url'], local_path)     df.loc[i, 'local_path'] = local_path<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043d\u043e\u0436\u0430\u043c\u0438. <\/p>\n<h2>\u041c\u043e\u0434\u0435\u043b\u044c YOLO8x<\/h2>\n<p><a class=\"anchor\" name=\"yolo\" id=\"yolo\"><\/a><\/p>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0438 <a href=\"https:\/\/roboflow.com\/universe\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/a> \u0432\u00a0\u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043e\u043d\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 <a href=\"https:\/\/roboflow.com\/train\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0430\u00a0\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445<\/a>, \u0435\u0441\u043b\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0435\u00a0\u0445\u0432\u0430\u0442\u0430\u0435\u0442. <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c YOLO v8x \u0434\u043b\u044f\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (Detection) \u043d\u0430 1000\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445 \u0438\u0437\u00a0Domclick.ru. \u0414\u043b\u044f\u00a0\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 (\u0442\u0430\u043a \u043a\u0430\u043a\u00a0\u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043e\u0431\u044a\u0451\u043c\u043d\u044b\u043c, \u043c\u044b \u0441\u043a\u0440\u044b\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u0434\u00a0\u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c):<\/p>\n<details class=\"spoiler\">\n<summary> YOLO v8x<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from roboflow import Roboflow import os HOME = os.getcwd() from IPython import display display.clear_output() import ultralytics from ultralytics import YOLO from IPython.display import display, Image from threading import Event, Thread from queue import Empty, Queue import shutil from urllib.error import HTTPError from urllib.request import Request, urlopen import pandas as pd  from tqdm import tqdm  THREADS = 11 RESULT_FILE = 'result.csv' URL = 'https:\/\/img.dmclk.ru\/vitrina\/owner\/' PHOTO_PATH = 'photos'  STOP_EVENT = Event()  def img_loader(url_input, local_path):     url = URL + url_input     req = Request(url, headers={'User-Agent': 'Mozilla\/5.0'})      with urlopen(req) as response, open(local_path, 'wb') as out_file:         shutil.copyfileobj(response, out_file)  def worker(input_queue: Queue, output_queue: Queue):          #model = YOLO('yolov8x.pt')     while not STOP_EVENT.is_set():         try:             try:                 img = input_queue.get()             except Empty:                 tqdm.write('thread stop')                 break             img_name = os.path.basename(img)             img_path = f'{PHOTO_PATH}\/{img_name}'             print(img_path)             try:                 img_loader(img, img_path)                 res1 = model.predict(img_path, conf=0.25, save_txt=True, save_conf=True)                 palette = 1                 img_sus = 1                 output_queue.put((img, img_sus, palette))                 os.remove(img_path)             except HTTPError:                 output_queue.put((img, '404', None))         except Exception as e:             tqdm.write(e.__str__())     output_queue.put('DONE')     print('thread finished')  def listener(output_queue: Queue, total_files: int):     pbar = tqdm(total=total_files)     working_threads = THREADS     while working_threads:         try:             try:                 item = output_queue.get()             except Empty:                 continue             if item == 'DONE':                 working_threads -= 1             else:                 line = f'{item[0]};{item[1]};{item[2]}\\n'                 with open(RESULT_FILE, 'a') as r:                     r.write(line)                 pbar.update(1)         except KeyboardInterrupt:             tqdm.write('STOP')             STOP_EVENT.set()     pbar.close()  input_queue = Queue() output_queue = Queue() model = YOLO('yolov8n.pt') photo_df = pd.read_csv('photo3.csv', sep='^') photo_df.loc[:, 'list_url'] = photo_df['list_url'].apply(lambda x: x.split(',')) df = photo_df.explode('list_url', ignore_index=True)[1:] df.drop_duplicates(subset=['list_url'], inplace=True, ignore_index=True) to_process = df.loc[:, 'list_url'].tolist()  try:     processed = pd.read_csv(RESULT_FILE, sep=';')     processed_files = processed.loc[:, 'file'].tolist()      to_process = set(to_process).difference(processed_files) except FileNotFoundError:     with open(RESULT_FILE, 'w') as r:         r.write('file;is_file_sus;palette\\n') total = len(to_process)  for file in to_process:     input_queue.put(file)  threads = [] for i in range(THREADS):     print(f'thread {i} launching')     thread = Thread(target=worker, args=(input_queue, output_queue))     threads.append(thread)     thread.start()  print(f'listener launching') listener(output_queue, len(df['list_url']))  print('empying queue') while not input_queue.empty():     input_queue.get()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430:<\/p>\n<pre><code class=\"python\">model = YOLO('yolov8x.pt') res1 = model.predict(img_path, conf=0.25, save_txt=True, save_conf=True)<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u00a0\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u00a0\u044d\u043a\u0440\u0430\u043d.<\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u0437\u0430\u043d\u044f\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 16\u00a0\u043c\u0438\u043d\u0443\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.\u00a0\u0411\u044b\u043b\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e 686\u00a0\u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432. \u041f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043c \u043f\u043e\u0438\u0441\u043a \u043d\u0430\u00a0\u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u043e\u00a0\u0441\u043b\u043e\u0432\u0443 knife (\u041d\u043e\u0436) \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c 6\u00a0\u0444\u043e\u0442\u043e, \u0433\u0434\u0435\u00a0\u0431\u044b\u043b\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u044b \u043d\u043e\u0436\u0438:<\/p>\n<p>image 1\/1 C:\\Users\\chimb\\WORK\\photos\\b77190191fbf40d18f1cca62ddbcdd84.jpg: 480&#215;640 3 bottles, 4 cups, <strong>2 knifes<\/strong>, 2 spoons, 2 bowls, 1 bed, 1 dining table, 1 tv, 2 ovens, 1 sink, 7429.8ms<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/78b\/167\/3d6\/78b1673d666ae7959d3d97f920d13a80.jpg\" width=\"560\" height=\"420\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/78b\/167\/3d6\/78b1673d666ae7959d3d97f920d13a80.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>image 1\/1 C:\\Users\\chimb\\WORK\\photos\\8bd91f5dc622460c91119d168e199b2d.jpg: 384&#215;640 3 bottles, 1 fork, <strong>8 knifes<\/strong>, 1 spoon, 1 sink, 7209.2ms<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/ab7\/6b1\/15a\/ab76b115a5b4d0ab78a7bdf2506e528a.jpg\" width=\"658\" height=\"370\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ab7\/6b1\/15a\/ab76b115a5b4d0ab78a7bdf2506e528a.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>image 1\/1 C:\\Users\\chimb\\WORK\\photos\\c86b4f2189ff41ba97729e8ffa9168df.jpg: 480&#215;640 2 bottles, 2 cups, <strong>1 knife<\/strong>, 1 bowl, 1 chair, 1 dining table, 1 cell phone, 1 oven, 1 refrigerator, 11615.4ms<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c9f\/25d\/fa8\/c9f25dfa815b83aeb592a1c7375c27a4.jpg\" width=\"645\" height=\"484\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c9f\/25d\/fa8\/c9f25dfa815b83aeb592a1c7375c27a4.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>image 1\/1 C:\\Users\\chimb\\WORK\\photos\\4928822c7c62451d82e7535163c84073.jpg: 640&#215;480 6 bottles, <strong>1 knife<\/strong>, 1 bowl, 2 bananas, 1 carrot, 1 microwave, 1 oven, 1 sink, 10649.5ms. <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/f78\/787\/498\/f787874984af44e4c53789be634ee9a3.jpg\" width=\"459\" height=\"611\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f78\/787\/498\/f787874984af44e4c53789be634ee9a3.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>image 1\/1 C:\\Users\\chimb\\WORK\\photos\\f4853d8d75b24bd7bb430b05c78f4962.jpg: 640&#215;480 1 bottle, <strong>1 knife<\/strong>, 1 oven, 6389.7ms<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/93b\/edf\/d43\/93bedfd434c7e62bf4b5f1272162ca92.jpg\" width=\"451\" height=\"602\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/93b\/edf\/d43\/93bedfd434c7e62bf4b5f1272162ca92.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u041d\u0430\u00a0\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e\u00a0\u0431\u044b\u043b\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u044b \u0432\u00a0\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u043a\u0443\u0445\u043e\u043d\u043d\u043e\u0439 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430\u00a0\u043d\u043e\u0436\u0438.<\/p>\n<h2>\u041c\u043e\u0434\u0435\u043b\u044c RESNET101<\/h2>\n<p><a class=\"anchor\" name=\"resnet\" id=\"resnet\"><\/a><\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (Detection) \u043d\u0430 1000 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445 \u0438\u0437 Domclick.ru, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u043e\u0434\u0435\u043b\u044c RESNET101. \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 (\u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c).<\/p>\n<details class=\"spoiler\">\n<summary>RESNET101<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from torchvision import models #dir(models) # \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c resnet-101 layers pre-trained model # resnet = models.resnet101(weights=True) # # resnet resnet.eval()  import torch from PIL import Image from torchvision import transforms  def preprocessing(img):     #     # \u0424\u0443\u043d\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443      #     preprocess = transforms.Compose([             transforms.Resize(256),             transforms.CenterCrop(224),             transforms.ToTensor(),             transforms.Normalize(             mean=[0.485, 0.456, 0.406],             std=[0.229, 0.224, 0.225]         )])     img_cat_preprocessed = preprocess(img)     batch_img_cat_tensor = torch.unsqueeze(img_cat_preprocessed, 0)     return batch_img_cat_tensor  def labeler(tens):     with open('c:\/Users\/chimb\/.fastai\/data\/\/imagenet_classes.txt') as f:         labels = [line.strip() for line in f.readlines()]     _, index = torch.max(tens, 1)     percentage = torch.nn.functional.softmax(tens, dim=1)[0] * 100     print(labels[index[0]], percentage[index[0]].item())     _, indices = torch.sort(tens, descending=True)     [(labels[idx], percentage[idx].item()) for idx in indices[0][:5]]  from threading import Event, Thread import os from queue import Empty, Queue import shutil from urllib.error import HTTPError from urllib.request import Request, urlopen import pandas as pd  from tqdm import tqdm  THREADS = 11 RESULT_FILE = 'result.csv' URL = 'https:\/\/img.dmclk.ru\/vitrina\/owner\/' PHOTO_PATH = 'photos'  STOP_EVENT = Event()  def img_loader(url_input, local_path):     url = URL + url_input     req = Request(url, headers={'User-Agent': 'Mozilla\/5.0'})      with urlopen(req) as response, open(local_path, 'wb') as out_file:         shutil.copyfileobj(response, out_file)  def worker(input_queue: Queue, output_queue: Queue):     while not STOP_EVENT.is_set():         try:             try:                 img = input_queue.get()             except Empty:                 tqdm.write('thread stop')                 break             img_name = os.path.basename(img)             img_path = f'{PHOTO_PATH}\/{img_name}'             print(img_path)             try:   img_loader(img, img_path)   img_cat = Image.open(img_path).convert('RGB')   img_prep = preprocessing(img_cat)   out = resnet(img_prep)   labeler(out)   palette = 1   img_sus = 1   output_queue.put((img, img_sus, palette))   os.remove(img_path)              except HTTPError:   output_queue.put((img, '404', None))           except Exception as e:              tqdm.write(e.__str__()) output_queue.put('DONE') print('thread finished')  def listener(output_queue: Queue, total_files: int):     pbar = tqdm(total=total_files)     working_threads = THREADS     while working_threads:         try:             try:                 item = output_queue.get()             except Empty:                 continue             if item == 'DONE':                 working_threads -= 1             else:                 line = f'{item[0]};{item[1]};{item[2]}\\n'                 with open(RESULT_FILE, 'a') as r:                     r.write(line)                 pbar.update(1)         except KeyboardInterrupt:             tqdm.write('STOP')             STOP_EVENT.set()                    pbar.close()   input_queue = Queue() output_queue = Queue() photo_df = pd.read_csv('photo3.csv', sep='^') photo_df.loc[:, 'list_url'] = photo_df['list_url'].apply(lambda x: x.split(',')) df = photo_df.explode('list_url', ignore_index=True)[1:] df.drop_duplicates(subset=['list_url'], inplace=True, ignore_index=True) to_process = df.loc[:, 'list_url'].tolist()  try:    processed = pd.read_csv(RESULT_FILE, sep=';')    processed_files = processed.loc[:, 'file'].tolist()     to_process = set(to_process).difference(processed_files) except FileNotFoundError:    with open(RESULT_FILE, 'w') as r:         r.write('file;is_file_sus;palette\\n') total = len(to_process)  for file in to_process:     input_queue.put(file)  threads = [] for i in range(THREADS):     print(f'thread {i} launching')     thread = Thread(target=worker, args=(input_queue, output_queue))     threads.append(thread)     thread.start()  print(f'listener launching') listener(output_queue, len(df['list_url']))  print('empying queue') while not input_queue.empty():     input_queue.get()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u00a0\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u00a0\u044d\u043a\u0440\u0430\u043d.<\/p>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u0438\u0441\u043a \u043d\u0430\u00a0\u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u043e\u00a0\u0441\u043b\u043e\u0432\u0443 knife (\u041d\u043e\u0436) \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u0447\u0442\u043e\u00a0\u043d\u043e\u0436\u0438 \u043d\u0435\u00a0\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u044b. \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u043e\u00a0\u0442\u043e\u043c, \u0447\u0442\u043e\u00a0\u043c\u043e\u0434\u0435\u043b\u044c YOLO \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u00a0\u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u0434\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0430\u00a0\u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 \u043d\u043e\u0436\u0435\u0439. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u043b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. <\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u00a0\u043d\u043e\u0436\u0430\u043c\u0438 \u0441 <a href=\"https:\/\/universe.roboflow.com\/kmitl%E2%80%91evvyr\/weapon%E2%80%91detection%E2%80%91knife\/model\/1\" rel=\"noopener noreferrer nofollow\">\u0441\u0430\u0439\u0442\u0430<\/a>. \u0414\u043b\u044f\u00a0\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">from roboflow import Roboflow rf = Roboflow(api_key=\"ne2aD5LuLH2xQyAFcVip\") project = rf.workspace().project(\"weapon-detection-knife\") model = project.version(1).model print(model.predict(img_path, confidence=40, overlap=30).json())<\/code><\/pre>\n<p>\u0412\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e\u00a0\u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u043e\u0436\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u0430\u00a0\u043d\u043e\u0436\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b. \u041d\u0430\u00a0\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u043e\u0436\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0447\u0430\u0441\u0442\u044c \u0434\u043e\u043c\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/bdf\/c4f\/282\/bdfc4f282fc65e105f429f0855a65948.jpg\" width=\"697\" height=\"330\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bdf\/c4f\/282\/bdfc4f282fc65e105f429f0855a65948.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c RCNN ResNet 50\u00a0FPN V2. \u041c\u044b \u043e\u0431\u0443\u0447\u0438\u043c \u0435\u0451 \u043d\u0430\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c. <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438\u0437 55\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u041f\u0440\u0438\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0434\u043b\u044f\u00a0\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c 55\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0441\u00a0\u0414\u043e\u043c\u041a\u043b\u0438\u043a, \u0433\u0434\u0435\u00a0\u0431\u044b\u043b\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u044b \u043d\u043e\u0436\u0438 \u043c\u043e\u0434\u0435\u043b\u044c\u044e Yolo8x. \u041c\u043e\u0434\u0435\u043b\u044c RCNN ResNet 50\u00a0FPN V2\u00a0\u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u00a0\u0431\u044b\u043b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d \u0432\u00a0\u0444\u043e\u0440\u043c\u0430\u0442\u0435 Pascal VOC format. \u0412\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u00a0\u0442\u0440\u0435\u043c\u044f \u043f\u043e\u0434\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u043c\u0438 test, train, valid c \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u043c\u0438. Test \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438\u0437 5\u00a0\u0444\u0430\u0439\u043b\u043e\u0432, 39\u00a0\u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437\u00a0train \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f\u00a0\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, 11\u00a0\u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437\u00a0valid \u0434\u043b\u044f\u00a0\u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439. \u0414\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0441\u00a0\u043d\u043e\u0436\u0430\u043c\u0438 \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u00a0\u043a\u0430\u043a\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u044d\u0442\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u044b __background__&#8217;, &#8216;knifes\u2011detect&#8217;, &#8216;knifes&#8217;, &#8216;no_knifes&#8217;, &#8216;object&#8217;.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cee\/24f\/227\/cee24f2274515a949a3e1a30baa47315.png\" width=\"639\" height=\"640\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cee\/24f\/227\/cee24f2274515a949a3e1a30baa47315.png\"\/><\/figure>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b YAML \u0434\u043b\u044f\u00a0\u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u00a0\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u0438 \u043f\u0443\u0442\u044f\u0445 \u043a\u00a0XML\u2011\u0444\u0430\u0439\u043b\u0430\u043c. \u041d\u0430\u0440\u044f\u0434\u0443 \u0441\u00a0\u044d\u0442\u0438\u043c, \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043c\u0435\u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u00a0\u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0424\u0430\u0439\u043b knifes-detect.yaml:<\/p>\n<pre><code>TRAIN_DIR_IMAGES: 'data\/knifes-detect\/dataset\/train' TRAIN_DIR_LABELS: 'data\/ knifes-detect \/dataset\/train' VALID_DIR_IMAGES: 'data\/ knifes-detect \/dataset\/valid' VALID_DIR_LABELS: 'data\/ knifes-detect \/dataset\/valid'  CLASSES: [     '__background__',     'knifes-detect', 'knifes', 'no_knifes','object' ]  NC: 5  SAVE_VALID_PREDICTION_IMAGES: True<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043c\u043e\u0434\u0435\u043b\u0438. Torch vision \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0435 \u043d\u0430\u00a0\u0434\u0440\u0443\u0433\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"python\">import torchvision from torchvision.models.detection.faster_rcnn import FastRCNNPredictor def create_model(num_classes, pretrained=True, coco_model=False):     model = torchvision.models.detection.fasterrcnn_resnet50_fpn_v2( weights=torchvision.models.detection.FasterRCNN_ResNet50_FPN_V2_Weights.DEFAULT )     if coco_model:          return model     in_features = model.roi_heads.box_predictor.cls_score.in_features     model.roi_heads.box_predictor = FastRCNNPredictor(in_features, num_classes)      return model  if __name__ == '__main__':     model = create_model(num_classes=81, pretrained=True, coco_model=True)     print(model)     total_params = sum(p.numel() for p in model.parameters())     print(f\"{total_params:,} total parameters.\")     total_trainable_params = sum(     p.numel() for p in model.parameters() if p.requires_grad)     print(f\"{total_trainable_params:,} training parameters.\")<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code>python train.py --model fasterrcnn_resnet50_fpn_v2 --config data_configs\/ppe.yaml --epochs 50 --project-name fasterrcnn_resnet50_fpn_v2_ppe --use-train-aug --no-mosaic<\/code><\/pre>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u044d\u043f\u043e\u0445\u0438.<\/p>\n<pre><code>Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.203  Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.243  Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.189  Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.018  Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.084  Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.352  Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.256  Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.125  Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.250  Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.450<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 mAP@0.50:0.95\u00a0IoU 35,2%. \u041d\u043e\u00a0\u0434\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u043b\u0443\u0447\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u043b\u0435 45-\u0439 \u044d\u043f\u043e\u0445\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 37,3\u00a0\u043f\u0440\u0438 0.50:0.95\u00a0IoU. \u041e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u044d\u043f\u043e\u0445\u0438, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u043b\u0443\u0447\u0448\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f\u00a0\u0432\u044b\u0432\u043e\u0434\u0430.<\/p>\n<p>\u0412\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d43\/901\/332\/d439013326c4ae8900966e3bb47b7317.png\" width=\"1000\" height=\"700\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d43\/901\/332\/d439013326c4ae8900966e3bb47b7317.png\"\/><\/figure>\n<p>\u041d\u0430\u00a0\u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e\u00a0\u0441\u0430\u043c\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 mAP \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u043d\u0430\u00a0\u044d\u043f\u043e\u0445\u0435 45.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0433\u0440\u0430\u0444\u0438\u043a \u043f\u043e\u0442\u0435\u0440\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043d\u0438\u0436\u0430\u043b\u0441\u044f \u0434\u043e\u00a0\u043a\u043e\u043d\u0446\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c17\/f54\/191\/c17f541916a9bea0ee407af581b7a428.png\" width=\"1000\" height=\"700\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c17\/f54\/191\/c17f541916a9bea0ee407af581b7a428.png\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430\u0448\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code>python inference.py \u2013weights outputs\/training\/fasterrcnn_resnet50_fpn_v2_ppe\/best_model.pth \u2013input data\/dataset\/test\/1123.jpg \u2013show-image \u2013threshold 0.9<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u043e\u0436\u0438 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<h2>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 YOLO \u0438 Resnet<\/h2>\n<p><a class=\"anchor\" name=\"%D1%80%D0%B5%D0%B7%D1%83%D0%BB%D1%8C%D1%82%D0%B0%D1%82%D1%8B\" id=\"\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b\"><\/a><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"254\" width=\"254\">\n<p align=\"center\">\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<\/td>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"center\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<\/td>\n<td data-colwidth=\"132\" width=\"132\">\n<p align=\"center\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430   \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445 Domclick.ru<\/p>\n<\/td>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435<\/p>\n<\/td>\n<td>\n<p align=\"center\">mAP\u2013 \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"254\" width=\"254\">\n<p align=\"left\">Yolo8x<\/p>\n<\/td>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\">\u0414\u0430<\/p>\n<\/td>\n<td data-colwidth=\"132\" width=\"132\">\n<p align=\"left\">\u0414\u0430<\/p>\n<\/td>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"left\">\u0414\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">93,3%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"254\" width=\"254\">\n<p align=\"left\">ResNet101<\/p>\n<\/td>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\">\u0414\u0430<\/p>\n<\/td>\n<td data-colwidth=\"132\" width=\"132\">\n<p align=\"left\">\u041d\u0435\u0442<\/p>\n<\/td>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"left\">\u0414\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">0%<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"254\" width=\"254\">\n<p align=\"left\">RCNN   ResNet 50 FPN V2   <\/p>\n<\/td>\n<td data-colwidth=\"110\" width=\"110\">\n<p align=\"left\">\u0414\u0430<\/p>\n<\/td>\n<td data-colwidth=\"132\" width=\"132\">\n<p align=\"left\">\u041d\u0435\u0442<\/p>\n<\/td>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"left\">\u0414\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">0%<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p><a class=\"anchor\" name=\"%D0%B8%D1%82%D0%BE%D0%B3%D0%B8\" id=\"\u0438\u0442\u043e\u0433\u0438\"><\/a><\/p>\n<p>\u0412\u00a0\u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b:<\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445 \u043c\u043e\u0436\u0435\u0442\u00a0\u0431\u044b\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0430 \u043f\u0443\u0442\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 YOLO8. \u0414\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0432\u00a0\u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0412\u00a0\u0441\u0432\u043e\u0435\u043c \u0441\u043e\u0441\u0442\u0430\u0432\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439. \u041f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c Yolo8x.pt \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u00a0\u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 Resnet \u043d\u0435\u00a0\u0441\u043c\u043e\u0433\u043b\u0438 \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u00a0\u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0436\u0435\u0439 \u043d\u0430\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445. \u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u0434\u043e\u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 Resnet \u043d\u0430\u00a0\u0441\u0432\u043e\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u00a0\u0443\u0432\u0435\u043d\u0447\u0430\u043b\u0430\u0441\u044c \u0443\u0441\u043f\u0435\u0445\u043e\u043c. \u0414\u043b\u044f\u00a0\u0434\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 Resnet \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0434\u043b\u044f\u00a0\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u00a0\u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0431\u043e\u043b\u0435\u0435 \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 YOLO \u0432\u00a0\u0441\u0435\u0442\u0438 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e\u00a0\u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 YOLO8\u00a0\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0434\u043b\u044f\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/761200\/\"> https:\/\/habr.com\/ru\/articles\/761200\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u00a0\u0432\u0430\u043c\u0438 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0438 <a href=\"https:\/\/newtechaudit.ru\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 NTA<\/a> \u041f\u043e\u043f\u043e\u0432 \u0418\u0432\u0430\u043d \u0438 \u0427\u0438\u043c\u0431\u0435\u0435\u0432 \u0410\u043d\u0430\u0442\u043e\u043b\u0438\u0439.<\/p>\n<p>\u0412\u00a0\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u043c\u0438\u0440\u0435, \u0433\u0434\u0435 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0438\u0433\u0440\u0430\u044e\u0442 \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432\u00a0\u0441\u0444\u0435\u0440\u0435 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0434\u0438\u0430, \u043e\u043d\u043b\u0430\u0439\u043d\u2011\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e, \u0432\u0430\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f\u00a0\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430\u00a0\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445. \u0412\u00a0\u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0438\u0437\u00a0\u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 <strong>YOLO \u0438 ResNet<\/strong> \u0434\u043b\u044f\u00a0\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445.<\/p>\n<details class=\"spoiler\">\n<summary>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u043f\u043e \u043f\u043e\u0441\u0442\u0443<\/summary>\n<div class=\"spoiler__content\">\n<ul>\n<li>\n<p><a href=\"#%D0%BE%20%D0%BC%D0%BE%D0%B4%D0%B5%D0%BB%D1%8F%D1%85\" rel=\"noopener noreferrer nofollow\">\u041e \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#yolo\" rel=\"noopener noreferrer nofollow\">\u041c\u043e\u0434\u0435\u043b\u044c YOLO8x<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#resnet\" rel=\"noopener noreferrer nofollow\">\u041c\u043e\u0434\u0435\u043b\u044c RESNET101<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#%D1%80%D0%B5%D0%B7%D1%83%D0%BB%D1%8C%D1%82%D0%B0%D1%82%D1%8B\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 YOLO \u0438 Resnet<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#%D0%B8%D1%82%D0%BE%D0%B3%D0%B8\" rel=\"noopener noreferrer nofollow\">\u0418\u0442\u043e\u0433\u0438<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<h2>\u041e \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p><a class=\"anchor\" name=\"%D0%BE%20%D0%BC%D0%BE%D0%B4%D0%B5%D0%BB%D1%8F%D1%85\" id=\"\u043e \u043c\u043e\u0434\u0435\u043b\u044f\u0445\">\u043b\u044f\u0445&#187;><\/a><\/p>\n<p><strong>YOLO (You Only Look Once)<\/strong>\u00a0\u2014 \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437\u00a0\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u043b\u044f\u00a0\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430\u00a0\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u0432\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041e\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430\u00a0\u0441\u0432\u0435\u0440\u0442\u043e\u0447\u043d\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0435\u0437\u00a0\u0443\u0449\u0435\u0440\u0431\u0430 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. YOLO \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u00a0\u0441\u0435\u0442\u043a\u0443 \u044f\u0447\u0435\u0435\u043a \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0435.<\/p>\n<p><strong>ResNet (Residual Neural Network)<\/strong>\u00a0\u2014 \u044d\u0442\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u0430\u044f \u0434\u043b\u044f\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0437\u0430\u0442\u0443\u0445\u0430\u043d\u0438\u044f \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430. \u041e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u00abskip connections\u00bb \u0438\u043b\u0438 \u00abresidual connections\u00bb, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u00a0\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u043a\u00a0\u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u043c\u0438\u043d\u0443\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0441\u043b\u043e\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0443\u0447\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0435 \u0441\u0435\u0442\u0438 \u0441\u00a0\u043b\u0443\u0447\u0448\u0435\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u043b\u044f\u00a0\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445. \u0423\u00a0\u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432\u00a0\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u0445 \u0441\u0430\u0439\u0442\u0430 \u0414\u043e\u043c\u041a\u043b\u0438\u043a. \u041d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439\u00a0\u0431\u044b\u043b \u043f\u043e\u0438\u0441\u043a \u043d\u0430\u00a0\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 \u0442\u0430\u043a\u0438\u0445 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u0430\u043a\u00a0\u043e\u0440\u0443\u0436\u0438\u0435, \u0430\u043b\u043a\u043e\u0433\u043e\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u043f\u0438\u0442\u043a\u0438, \u0441\u0438\u0433\u0430\u0440\u0435\u0442\u044b \u0438\u043b\u0438\u00a0\u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0438\u0441\u0442\u0441\u043a\u0430\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0438\u043a\u0430.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0447\u0442\u0435\u043d\u0438\u0435 csv-\u0444\u0430\u0439\u043b\u0430 \u0441 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0438\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430.<\/p>\n<pre><code class=\"python\">import os import shutil from urllib.request import Request, urlopen  URL = 'https:\/\/img.dmclk.ru\/vitrina\/owner\/'  import pandas as pd from tqdm import tqdm  def loader(url_input, local_path):     url = URL + url_input     req = Request(url, headers={'User-Agent': 'Mozilla\/5.0'})      with urllib.request.urlopen(req) as response, open(local_path, 'wb') as out_file:         shutil.copyfileobj(response, out_file)  photo_df = pd.read_csv('full_sample_photo_res.csv', sep='^') photo_df.loc[:, 'list_url'] = photo_df['list_url'].apply(lambda x: x.split(',')) os.makedirs('photos', exist_ok=True)  df = photo_df.explode('list_url', ignore_index=True) for i in tqdm(df.index):     file_name = os.path.basename(df.loc[i, 'list_url'])     local_path = f'photos\/{file_name}'     loader(df.loc[i, 'list_url'], local_path)     df.loc[i, 'local_path'] = local_path<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043d\u043e\u0436\u0430\u043c\u0438. <\/p>\n<h2>\u041c\u043e\u0434\u0435\u043b\u044c YOLO8x<\/h2>\n<p><a class=\"anchor\" name=\"yolo\" id=\"yolo\"><\/a><\/p>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0438 <a href=\"https:\/\/roboflow.com\/universe\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/a> \u0432\u00a0\u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043e\u043d\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 <a href=\"https:\/\/roboflow.com\/train\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0430\u00a0\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445<\/a>, \u0435\u0441\u043b\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0435\u00a0\u0445\u0432\u0430\u0442\u0430\u0435\u0442. <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c YOLO v8x \u0434\u043b\u044f\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (Detection) \u043d\u0430 1000\u00a0\u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445 \u0438\u0437\u00a0Domclick.ru. \u0414\u043b\u044f\u00a0\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 (\u0442\u0430\u043a \u043a\u0430\u043a\u00a0\u043a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043e\u0431\u044a\u0451\u043c\u043d\u044b\u043c, \u043c\u044b \u0441\u043a\u0440\u044b\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u0434\u00a0\u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c):<\/p>\n<details class=\"spoiler\">\n<summary> YOLO v8x<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from roboflow import Roboflow import os HOME = os.getcwd() from IPython import display display.clear_output() import ultralytics from ultralytics import YOLO from IPython.display import display, Image from threading import Event, Thread from queue import Empty, Queue import shutil from urllib.error import HTTPError from urllib.request import Request, urlopen import pandas as pd  from tqdm import tqdm  THREADS = 11 RESULT_FILE = 'result.csv' URL = 'https:\/\/img.dmclk.ru\/vitrina\/owner\/' PHOTO_PATH = 'photos'  STOP_EVENT = Event()  def img_loader(url_input, local_path):     url = URL + url_input     req = Request(url, headers={'User-Agent': 'Mozilla\/5.0'})      with urlopen(req) as response, open(local_path, 'wb') as out_file:         shutil.copyfileobj(response, out_file)  def worker(input_queue: Queue, output_queue: Queue):          #model = YOLO('yolov8x.pt')     while not STOP_EVENT.is_set():         try:             try:                 img = input_queue.get()             except Empty:                 tqdm.write('thread stop')                 break             img_name = os.path.basename(img)             img_path = f'{PHOTO_PATH}\/{img_name}'             print(img_path)             try:                 img_loader(img, img_path)                 res1 = model.predict(img_path, conf=0.25, save_txt=True, save_conf=True)                 palette = 1                 img_sus = 1                 output_queue.put((img, img_sus, palette))                 os.remove(img_path)             except HTTPError:                 output_queue.put((img, '404', None))         except Exception as e:             tqdm.write(e.__str__())     output_queue.put('DONE')     print('thread finished')  def listener(output_queue: Queue, total_files: int):     pbar = tqdm(total=total_files)     working_threads = THREADS     while working_threads:         try:             try:                 item = output_queue.get()             except Empty:                 continue             if item == 'DONE':                 working_threads -= 1             else:                 line = f'{item[0]};{item[1]};{item[2]}\\n'                 with open(RESULT_FILE, 'a') as r:                     r.write(line)                 pbar.update(1)         except KeyboardInterrupt:             tqdm.write('STOP')             STOP_EVENT.set()     pbar.close()  input_queue = Queue() output_queue = Queue() model = YOLO('yolov8n.pt') photo_df = pd.read_csv('photo3.csv', sep='^') photo_df.loc[:, 'list_url'] = photo_df['list_url'].apply(lambda x: x.split(',')) df = photo_df.explode('list_url', ignore_index=True)[1:] df.drop_duplicates(subset=['list_url'], inplace=True, ignore_index=True) to_process = df.loc[:, 'list_url'].tolist()  try:     processed = pd.read_csv(RESULT_FILE, sep=';')     processed_files = processed.loc[:, 'file'].tolist()      to_process = set(to_process).difference(processed_files) except FileNotFoundError:     with open(RESULT_FILE, 'w') as r:         r.write('file;is_file_sus;palette\\n') total = len(to_process)  for file in to_process:     input_queue.put(file)  threads = [] for i in range(THREADS):     print(f'thread {i} launching')     thread = Thread(target=worker, args=(input_queue, output_queue))     threads.append(thread)     thread.start()  print(f'listener launching') listener(output_queue, len(df['list_url']))  print('empying queue') while not input_queue.empty():     input_queue.get()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430:<\/p>\n<pre><code class=\"python\">model = YOLO('yolov8x.pt') res1 = model.predict(img_path, conf=0.25, save_txt=True, save_conf=True)<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u00a0\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u00a0\u044d\u043a\u0440\u0430\u043d.<\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u0437\u0430\u043d\u044f\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 16\u00a0\u043c\u0438\u043d\u0443\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.\u00a0\u0411\u044b\u043b\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e 686\u00a0\u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432. \u041f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043c \u043f\u043e\u0438\u0441\u043a \u043d\u0430\u00a0\u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u043e\u00a0\u0441\u043b\u043e\u0432\u0443 knife (\u041d\u043e\u0436) \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c 6\u00a0\u0444\u043e\u0442\u043e, \u0433\u0434\u0435\u00a0\u0431\u044b\u043b\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u044b \u043d\u043e\u0436\u0438:<\/p>\n<p>image 1\/1 C:\\Users\\chimb\\WORK\\photos\\b77190191fbf40d18f1cca62ddbcdd84.jpg: 480&#215;640 3 bottles, 4 cups, <strong>2 knifes<\/strong>, 2 spoons, 2 bowls, 1 bed, 1 dining table, 1 tv, 2 ovens, 1 sink, 7429.8ms<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>image 1\/1 C:\\Users\\chimb\\WORK\\photos\\8bd91f5dc622460c91119d168e199b2d.jpg: 384&#215;640 3 bottles, 1 fork, <strong>8 knifes<\/strong>, 1 spoon, 1 sink, 7209.2ms<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>image 1\/1 C:\\Users\\chimb\\WORK\\photos\\c86b4f2189ff41ba97729e8ffa9168df.jpg: 480&#215;640 2 bottles, 2 cups, <strong>1 knife<\/strong>, 1 bowl, 1 chair, 1 dining table, 1 cell phone, 1 oven, 1 refrigerator, 11615.4ms<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>image 1\/1 C:\\Users\\chimb\\WORK\\photos\\4928822c7c62451d82e7535163c84073.jpg: 640&#215;480 6 bottles, <strong>1 knife<\/strong>, 1 bowl, 2 bananas, 1 carrot, 1 microwave, 1 oven, 1 sink, 10649.5ms. <\/p>\n<figure class=\"\"><\/figure>\n<p>image 1\/1 C:\\Users\\chimb\\WORK\\photos\\f4853d8d75b24bd7bb430b05c78f4962.jpg: 640&#215;480 1 bottle, <strong>1 knife<\/strong>, 1 oven, 6389.7ms<\/p>\n<figure class=\"\"><\/figure>\n<p>\u041d\u0430\u00a0\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e\u00a0\u0431\u044b\u043b\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u044b \u0432\u00a0\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u043a\u0443\u0445\u043e\u043d\u043d\u043e\u0439 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430\u00a0\u043d\u043e\u0436\u0438.<\/p>\n<h2>\u041c\u043e\u0434\u0435\u043b\u044c RESNET101<\/h2>\n<p><a class=\"anchor\" name=\"resnet\" id=\"resnet\"><\/a><\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (Detection) \u043d\u0430 1000 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u0445 \u0438\u0437 Domclick.ru, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u043e\u0434\u0435\u043b\u044c RESNET101. \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 (\u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c).<\/p>\n<details class=\"spoiler\">\n<summary>RESNET101<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from torchvision import models #dir(models) # \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c resnet-101 layers pre-trained model # resnet = models.resnet101(weights=True) # # resnet resnet.eval()  import torch from PIL import Image from torchvision import transforms  def preprocessing(img):     #     # \u0424\u0443\u043d\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443      #     preprocess = transforms.Compose([             transforms.Resize(256),             transforms.CenterCrop(224),             transforms.ToTensor(),             transforms.Normalize(             mean=[0.485, 0.456, 0.406],             std=[0.229, 0.224, 0.225]         )])     img_cat_preprocessed = preprocess(img)     batch_img_cat_tensor = torch.unsqueeze(img_cat_preprocessed, 0)     return batch_img_cat_tensor  def labeler(tens):     with open('c:\/Users\/chimb\/.fastai\/data\/\/imagenet_classes.txt') as f:         labels = [line.strip() for line in f.readlines()]     _, index = torch.max(tens, 1)     percentage = torch.nn.functional.softmax(tens, dim=1)[0] * 100     print(labels[index[0]], percentage[index[0]].item())     _, indices = torch.sort(tens, descending=True)     [(labels[idx], percentage[idx].item()) for idx in indices[0][:5]]  from threading import Event, Thread import os from queue import Empty, Queue import shutil from urllib.error import HTTPError from urllib.request import Request, urlopen import pandas as pd  from tqdm import tqdm  THREADS = 11 RESULT_FILE = 'result.csv' URL = 'https:\/\/img.dmclk.ru\/vitrina\/owner\/' PHOTO_PATH = 'photos'  STOP_EVENT = Event()  def img_loader(url_input, local_path):     url = URL + url_input     req = Request(url, headers={'User-Agent': 'Mozilla\/5.0'})      with urlopen(req) as response, open(local_path, 'wb') as out_file:         shutil.copyfileobj(response, out_file)  def worker(input_queue: Queue, output_queue: Queue):     while not STOP_EVENT.is_set():         try:             try:                 img = input_queue.get()<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-354934","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354934","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=354934"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354934\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=354934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=354934"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=354934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}