-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (43 loc) · 1.7 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main.py'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# 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.
import sys
from PyQt5 import QtGui
from tts_wrapper import PollyTTS, AwsCredentials
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QLabel, QWidget, QApplication
from PyQt5.QtGui import QPixmap
import mainwindow
import BreastCancer
from PIL import Image,ImageTk
from playsound import playsound
global img_png # 定义全局变量 图像的
class MainCode(QMainWindow, mainwindow.Ui_mainWindow):
def __init__(self):
QMainWindow.__init__(self)
mainwindow.Ui_mainWindow.__init__(self)
self.setupUi(self)
self.predict.clicked.connect(self.on_predict)
self.loadimage.clicked.connect(self.on_open)
def on_predict(self):
result = BreastCancer.predictImage()
print(result)
tts.synth("We think your breast tumor is "+result, result+'.wav')
voice_path = str('./voice/' + result + '.mp3')
playsound(voice_path)
def on_open(self):
image_path, _ = QFileDialog.getOpenFileName(self, '打开', r'./', 'JPG (*.jpg)')
image = QPixmap(image_path)
image.save('My_image.jpg')
image = QPixmap(image_path).scaled(351, 211)#和lable大小一样
self.label_2.setPixmap(image)
#sys.exit(app.exec_())
if __name__ == '__main__':
app = QApplication(sys.argv)
# Create an image viewer widget.
md = MainCode()
md.show()
sys.exit(app.exec_())