added link to detect.py

This commit is contained in:
bednarco 2021-01-25 13:35:24 +01:00
parent b4d08d6d4e
commit a6a80f409c
13 changed files with 17 additions and 11 deletions

BIN
files/input/contr.mp4 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
#import tkinter as tk #import tkinter as tk
import sys import sys
import os import os, subprocess
import shutil import shutil
from datetime import datetime from datetime import datetime
import time import time
@ -18,9 +18,9 @@ LIB_VIS = 1
def files(path): def files(path):
for file in os.listdir(path): for subdir, dirs, files_list in os.walk(path):
if os.path.isfile(os.path.join(path, file)): for file in files_list:
yield file yield os.path.join(subdir, file)
def save_input(oldpath): def save_input(oldpath):
# make timestampt the filename, so it wouln't overwrite # make timestampt the filename, so it wouln't overwrite
@ -55,7 +55,11 @@ class LibraryTableButtons(QWidget):
table.fillTable(type) table.fillTable(type)
def analyzeFile(): def analyzeFile():
# todo: run script detect.py --source ../files/input/file.mp4 cmd = "py detect.py --source {} --view-img".format(str(file))
popen = subprocess.Popen(cmd, cwd="../yolov5/", stdout=subprocess.PIPE)
popen.wait()
# todo: display gif/spinning wheel
pass pass
layout = QHBoxLayout() layout = QHBoxLayout()
@ -115,9 +119,10 @@ class LibraryTable(QTableWidget):
self.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents) self.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents)
dates = [] dates = []
names = [] names = []
for index, file in enumerate(files(filePath)): for index, file in enumerate(files(filePath)):
dates.append(QTableWidgetItem(str(datetime.fromtimestamp(os.path.getmtime(filePath + '/' + file))))) dates.append(QTableWidgetItem(str(datetime.fromtimestamp(os.path.getmtime(file)))))
names.append(QTableWidgetItem(str(file))) names.append(QTableWidgetItem(str(file)))
self.setRowCount(len(dates)) self.setRowCount(len(dates))
@ -125,7 +130,7 @@ class LibraryTable(QTableWidget):
for index, date in enumerate(dates): for index, date in enumerate(dates):
self.setItem(index,0,date) self.setItem(index,0,date)
self.setItem(index,1,names[index]) self.setItem(index,1,names[index])
self.setCellWidget(index,2,LibraryTableButtons(filePath + '\\' + names[index].text(), self, type)) self.setCellWidget(index,2,LibraryTableButtons(names[index].text(), self, type))
class formatHelp(QLabel): class formatHelp(QLabel):

View File

@ -237,7 +237,7 @@ def detect(save_img=False):
h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
vid_writer = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*fourcc), fps, (w, h)) vid_writer = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*fourcc), fps, (w, h))
vid_writer.write(im0) vid_writer.write(im0)
print(save_path)
if save_txt or save_img: if save_txt or save_img:
s = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels saved to {save_dir / 'labels'}" if save_txt else '' s = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels saved to {save_dir / 'labels'}" if save_txt else ''
print(f"Results saved to {save_dir}{s}") print(f"Results saved to {save_dir}{s}")
@ -260,7 +260,7 @@ if __name__ == '__main__':
parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS') parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS')
parser.add_argument('--augment', action='store_true', help='augmented inference') parser.add_argument('--augment', action='store_true', help='augmented inference')
parser.add_argument('--update', action='store_true', help='update all models') parser.add_argument('--update', action='store_true', help='update all models')
parser.add_argument('--project', default='../files/output', help='save results to project/name') parser.add_argument('--project', default='../win_venv/files/output', help='save results to project/name')
parser.add_argument('--name', default='exp', help='save results to project/name') parser.add_argument('--name', default='exp', help='save results to project/name')
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment') parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
parser.add_argument("--config_deepsort", type=str, default="deep_sort_pytorch/configs/deep_sort.yaml") parser.add_argument("--config_deepsort", type=str, default="deep_sort_pytorch/configs/deep_sort.yaml")

View File

@ -170,7 +170,8 @@ class LoadImages: # for inference
ret_val, img0 = self.cap.read() ret_val, img0 = self.cap.read()
self.frame += 1 self.frame += 1
print('video %g/%g (%g/%g) %s: ' % (self.count + 1, self.nf, self.frame, self.nframes, path), end='') # print('video %g/%g (%g/%g) %s: ' % (self.count + 1, self.nf, self.frame, self.nframes, path), end='')
print('video %g/%g (%g/%g) : ' % (self.count + 1, self.nf, self.frame, self.nframes), end='')
else: else:
# Read image # Read image