Add files via upload

This commit is contained in:
bedirkaraabali 2024-05-19 14:26:11 +03:00 committed by GitHub
parent eb4d529719
commit 3968e1acfe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 234 additions and 35 deletions

85
main.py
View File

@ -1,19 +1,11 @@
from ultralytics import YOLO
from window import Ui_Dialog
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtTest import *
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QPushButton, QFileDialog
from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent
from PyQt5.QtMultimediaWidgets import QVideoWidget
from PyQt5.QtCore import QUrl
from PyQt5 import QtCore, QtGui, QtWidgets
import os, cv2
from PyQt5.QtWidgets import QApplication, QMainWindow,QFileDialog
from PyQt5.QtMultimedia import QMediaContent
from PyQt5.QtCore import QUrl, QTimer
import cv2
import threading
#os.environ["QT_QPA_PLATFORM"] = "xcb"
class Program(QMainWindow):
@ -22,6 +14,7 @@ class Program(QMainWindow):
self.userInterface = Ui_Dialog()
self.userInterface.setupUi(self)
self.setWindowTitle("KUŞ YUVASI BUL")
self.setFixedSize(1184,601)
self.setWindowFlag(False)
#self.setWindowIcon()
@ -29,18 +22,22 @@ class Program(QMainWindow):
self.path = None
self.filename = None
self.model_path = "best.pt"
self.total_frames=1
self.frame_counter=1
self.local_flag = False
self.url_flag = False
self.conf_val = 50
self.timer= None
self.progress_rate=0
self.Texts = []
self.buttons = [
self.userInterface.pushButton
self.userInterface.pushButton,
self.userInterface.pushButton_2
]
self.graphics = [
@ -48,16 +45,13 @@ class Program(QMainWindow):
self.userInterface.video_widget
]
self.plainTexts = [
self.userInterface.plainTextEdit
]
self.labels = [
self.userInterface.label
self.userInterface.label,
self.userInterface.label_2
]
self.radio_buttons = [
self.userInterface.radioButton,
self.userInterface.radioButton_1,
self.userInterface.radioButton_2
]
@ -65,19 +59,38 @@ class Program(QMainWindow):
self.userInterface.progess_bar
]
self.sliders = [
self.userInterface.horizontalSlider
]
self.moves()
def readText(self):
text = self.plainTexts[0].toPlainText()
self.Texts.append(text)
self.open_media()
def model_yukle(self):
self.model_path, _ = QFileDialog.getOpenFileName(self, "modl Dosyası Seç", "", "model dosyaları(v8) (*.pt)")
def slider(self):
self.labels[0].setText("dogruluk esigi")
self.sliders[0].setValue(self.conf_val)
self.labels[1].setText(str(self.conf_val))
self.sliders[0].setMaximum(100)
self.sliders[0].setMinimum(0)
self.sliders[0].actionTriggered.connect(self.slider_update)
def slider_update(self):
self.conf_val = self.sliders[0].value()
self.labels[1].setText(str(self.conf_val))
def moves(self):
self.slider()
self.radio_button_select()
self.buttons[0].clicked.connect(self.readText)
self.buttons[0].clicked.connect(self.open_media)
self.buttons[1].clicked.connect(self.model_yukle)
@ -87,26 +100,21 @@ class Program(QMainWindow):
if self.radio_buttons[0].isChecked():
self.local_flag = True
self.url_flag = False
self.plainTexts[0].setEnabled(True)
elif self.radio_buttons[1].isChecked():
self.local_flag = True
self.url_flag = False
self.plainTexts[0].setEnabled(False)
else:
self.labels[0].setText("bir işaretleme yapın..")
self.local_flag = False
self.url_flag = False
def model_youtube(self):
model = YOLO('best.pt')
results = model(self.path, stream=True, save=True, conf=0.5)
def model(self):
model = YOLO('best.pt')
model = YOLO(self.model_path)
#fourcc = cv2.VideoWriter_fourcc(*'mp4v')
#output_path = os.path.join(os.getcwd(), 'videos', 'output.mp4')
@ -117,10 +125,10 @@ class Program(QMainWindow):
self.frame_counter=1
cap.release()
results = model(self.path, stream=True, save=True, conf=0.5)
results = model(self.path, stream=True, save=True, conf=(self.conf_val/100))
for res in results:
self.frame_counter+=1
self.progress_rate = (int(self.frame_counter)/int(self.total_frames))*100
self.progress_rate = ((int(self.frame_counter)/int(self.total_frames))*100)
"""
@ -152,10 +160,16 @@ class Program(QMainWindow):
"""
def image_control(self):
model = YOLO(self.model_path)
model.predict(self.path, save=True, show=True, conf=(self.conf_val/100))
def showVideo(self):
if self.path != '':
self.plainTexts[0].setPlainText(self.path)
self.graphics[0].setMedia(QMediaContent(QUrl.fromLocalFile(self.path)))
self.graphics[0].play()
@ -163,7 +177,8 @@ class Program(QMainWindow):
if self.radio_buttons[0].isChecked():
self.radio_button_select()
self.model_youtube()
self.path, self.filename = QFileDialog.getOpenFileName(self, "resim Dosyası Seç", "", "resim Dosyaları (*.png *.jpeg *.jpg)")
self.image_control()
elif self.radio_buttons[1].isChecked():
self.radio_button_select()

184
window.py Normal file
View File

@ -0,0 +1,184 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'window2.ui'
#
# Created by: PyQt5 UI code generator 5.15.10
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtMultimediaWidgets import QVideoWidget
from PyQt5.QtMultimedia import QMediaPlayer
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(1184, 601)
Dialog.setStyleSheet("QDialog {\n"
"background-color:#54784E;\n"
"}")
self.video_widget = QVideoWidget(Dialog)
self.video_widget.setGeometry(QtCore.QRect(80, 30, 480, 270))
self.video_widget.setObjectName("video_widget")
self.video_widget.setGeometry(QtCore.QRect(10, 10, 960, 540))
self.video_widget.setStyleSheet("QGraphicsView {\n"
" background-color:#D7B8F3;\n"
"}")
self.media_player = QMediaPlayer(Dialog, QMediaPlayer.VideoSurface)
self.media_player.setObjectName("media_player")
self.media_player.setVideoOutput(self.video_widget)
self.tabWidget = QtWidgets.QTabWidget(Dialog)
self.tabWidget.setGeometry(QtCore.QRect(980, 20, 191, 531))
self.tabWidget.setStyleSheet("QTabWidget {\n"
" background-color: #0d1b2a;\n"
" border-radius: 12px;\n"
" padding: 5px;\n"
"}\n"
"\n"
"/* Sekme başlıklarının stilini belirleme */\n"
"QTabBar::tab {\n"
" background: #1b263b;\n"
" color: white;\n"
" padding: 10px;\n"
" border-top-left-radius: 10px;\n"
" border-top-right-radius: 10px;\n"
" margin: 5px;\n"
"}\n"
"\n"
"\n"
"QTabBar::tab:hover {\n"
" background: #324a67;\n"
" color: #ffffff;\n"
"}\n"
"\n"
"")
self.progess_bar = QtWidgets.QProgressBar(Dialog)
self.progess_bar.setGeometry(1010,415, 111,25)
self.progess_bar.setValue(0)
self.tabWidget.setObjectName("tabWidget")
self.tab = QtWidgets.QWidget()
self.tab.setObjectName("tab")
self.horizontalSlider = QtWidgets.QSlider(self.tab)
self.horizontalSlider.setGeometry(QtCore.QRect(10, 130, 160, 16))
self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSlider.setObjectName("horizontalSlider")
self.label = QtWidgets.QLabel(self.tab)
self.label.setGeometry(QtCore.QRect(30, 80, 121, 19))
self.label.setStyleSheet("QLabel {\n"
"\n"
" color:white;\n"
"}")
self.label.setObjectName("label")
self.radioButton_1 = QtWidgets.QRadioButton(self.tab)
self.radioButton_1.setGeometry(QtCore.QRect(20, 170, 92, 25))
self.radioButton_1.setStyleSheet("QCRadioButton {\n"
"\n"
" color:white;\n"
"}")
self.radioButton_1.setObjectName("radioButton_1")
self.radioButton_2 = QtWidgets.QRadioButton(self.tab)
self.radioButton_2.setGeometry(QtCore.QRect(20, 210, 92, 25))
self.radioButton_2.setStyleSheet("QRadioButton {\n"
"\n"
" color:white;\n"
"}")
self.radioButton_2.setObjectName("radioButton_2")
self.textBrowser = QtWidgets.QTextBrowser(self.tab)
self.textBrowser.setGeometry(QtCore.QRect(20, 270, 141, 71))
self.textBrowser.setStyleSheet("QTextBrowser {\n"
"\n"
" color:white;\n"
" background-color:#6a040f;\n"
"}")
self.textBrowser.setObjectName("textBrowser")
self.pushButton = QtWidgets.QPushButton(self.tab)
self.pushButton.setGeometry(QtCore.QRect(20, 390, 141, 31))
self.pushButton.setStyleSheet("QPushButton {\n"
" color:white;\n"
" background-color:#232E21;\n"
" border-radius:12px;\n"
"}")
self.pushButton.setObjectName("pushButton")
self.label_2 = QtWidgets.QLabel(self.tab)
self.label_2.setGeometry(QtCore.QRect(70, 110, 66, 19))
self.label_2.setStyleSheet("QLabel {\n"
"\n"
" color:white;\n"
"}")
self.label_2.setObjectName("label_2")
self.frame = QtWidgets.QFrame(self.tab)
self.frame.setGeometry(QtCore.QRect(10, 380, 161, 51))
self.frame.setStyleSheet("QFrame {\n"
" background-color:white;\n"
" border-radius:12px;\n"
"}")
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame.setObjectName("frame")
self.frame.raise_()
self.horizontalSlider.raise_()
self.label.raise_()
self.radioButton_1.raise_()
self.radioButton_2.raise_()
self.textBrowser.raise_()
self.pushButton.raise_()
self.label_2.raise_()
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
self.pushButton_2 = QtWidgets.QPushButton(self.tab_2)
self.pushButton_2.setGeometry(QtCore.QRect(20, 430, 151, 41))
self.pushButton_2.setStyleSheet("QPushButton {\n"
" font: 75 14pt \"Ubuntu Sans\";\n"
" color:black;\n"
" background-color:white;\n"
" border-radius:12px;\n"
"}")
self.pushButton_2.setObjectName("pushButton_2")
self.textBrowser_2 = QtWidgets.QTextBrowser(self.tab_2)
self.textBrowser_2.setGeometry(QtCore.QRect(10, 10, 161, 391))
self.textBrowser_2.setStyleSheet("QTextBrowser {\n"
"\n"
" color:white;\n"
" background-color:#6a040f;\n"
"}")
self.textBrowser_2.setObjectName("textBrowser_2")
self.tabWidget.addTab(self.tab_2, "")
self.retranslateUi(Dialog)
self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Doğruluk eşiği"))
self.radioButton_1.setText(_translate("Dialog", "resim"))
self.radioButton_2.setText(_translate("Dialog", "video"))
self.textBrowser.setHtml(_translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Ubuntu Sans\'; font-size:11pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">ÇIKTILAR İÇİN RUNS KLASÖRÜNÜ KONTROL EDİN</p></body></html>"))
self.pushButton.setText(_translate("Dialog", "DOSYA SEC"))
self.label_2.setText(_translate("Dialog", "0"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("Dialog", "Tab 1"))
self.pushButton_2.setText(_translate("Dialog", "yukle"))
self.textBrowser_2.setHtml(_translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Ubuntu Sans\'; font-size:11pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt;\">Burda kendi modelinizi yükeleyebilir ve bu çıktıları görebilirsiniz modelinizin </span><span style=\" font-size:14pt; font-weight:600;\">YOLOv8</span><span style=\" font-size:14pt;\"> ile uyumlu olması gerekir detaylı bilgi için </span><a href=\"https://docs.ultralytics.com/tr/modes/predict\"><span style=\" font-size:14pt; text-decoration: underline; color:#0000ff;\">buraya </span></a><span style=\" font-size:14pt;\">bakabilirsiniz.</span></p></body></html>"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("Dialog", "Tab 2"))

BIN
yolov8s.pt Normal file

Binary file not shown.