Spaces:
Runtime error
Runtime error
Upload 6 files
Browse files- 728cnn.h5 +3 -0
- README.md +11 -11
- bot.py +121 -0
- main.py +234 -0
- show_data.py +74 -0
- skin cancer.txt +8 -0
728cnn.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d51fa0b0842b39569145da65303794529741dde005d154bebc487a4c5deb74f8
|
3 |
+
size 24189336
|
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
emoji: 💬
|
4 |
-
colorFrom: yellow
|
5 |
-
colorTo: purple
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 5.0.1
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# CNN Implementation on Major Skin Cancer Types Classification and NLP Diagnose Robot System
|
2 |
+
To run the script, simply run main file and chatbot will come out. You are allowed to type in messages or file path on your computer. Robot will identify concer type when receive a picture's path.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
## Example:
|
5 |
+

|
6 |
+
|
7 |
+
## Our result
|
8 |
+
<img width="444" alt="Screen Shot 2022-01-22 at 23 02 11" src="https://user-images.githubusercontent.com/52917220/150665638-65ea30c4-9554-4714-95cb-7b6729d1e57f.png">
|
9 |
+
To run the training file, you may run the training script in the train folder.
|
10 |
+
|
11 |
+
## Data Access
|
12 |
+
https://www.kaggle.com/kmader/skin-cancer-mnist-ham10000
|
bot.py
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import nltk
|
2 |
+
import numpy as np
|
3 |
+
import string # to process standard python strings
|
4 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
5 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
6 |
+
|
7 |
+
|
8 |
+
f=open('skin cancer.txt','r',errors = 'ignore')
|
9 |
+
raw=f.read()
|
10 |
+
raw=raw.lower()# converts to lowercase
|
11 |
+
|
12 |
+
sent_tokens = nltk.sent_tokenize(raw)# converts to list of sentences
|
13 |
+
word_tokens = nltk.word_tokenize(raw)# converts to list of words
|
14 |
+
|
15 |
+
lemmer = nltk.stem.WordNetLemmatizer()
|
16 |
+
#
|
17 |
+
def LemTokens(tokens):
|
18 |
+
return [lemmer.lemmatize(token) for token in tokens]
|
19 |
+
remove_punct_dict = dict((ord(punct), None) for punct in string.punctuation)
|
20 |
+
def LemNormalize(text):
|
21 |
+
return LemTokens(nltk.word_tokenize(text.lower().translate(remove_punct_dict)))
|
22 |
+
|
23 |
+
GREETING_INPUTS = ("hello", "hi", "greetings", "sup", "what's up","hey","ai","next")
|
24 |
+
|
25 |
+
GREETING_RESPONSES = ["hi", "hey", "*nods*", "hi there", "hello", "I am glad! You are talking to me","You're welcome, this is my job","You'd better talk with the doctor and you need further treatment"]
|
26 |
+
|
27 |
+
def greeting(sentence):
|
28 |
+
for word in sentence.split():
|
29 |
+
for i in range(len(GREETING_INPUTS)):
|
30 |
+
if word.lower() == GREETING_INPUTS[i]:
|
31 |
+
return GREETING_RESPONSES[i]
|
32 |
+
|
33 |
+
def response(user_response):
|
34 |
+
robo_response=''
|
35 |
+
sent_tokens.append(user_response)
|
36 |
+
TfidfVec = TfidfVectorizer(tokenizer=LemNormalize, stop_words='english')
|
37 |
+
tfidf = TfidfVec.fit_transform(sent_tokens)
|
38 |
+
vals = cosine_similarity(tfidf[-1], tfidf)
|
39 |
+
idx=vals.argsort()[0][-2]
|
40 |
+
flat = vals.flatten()
|
41 |
+
flat.sort()
|
42 |
+
req_tfidf = flat[-2]
|
43 |
+
if(req_tfidf==0):
|
44 |
+
robo_response=robo_response+"I am sorry! I don't understand you"
|
45 |
+
return robo_response
|
46 |
+
else:
|
47 |
+
robo_response = robo_response+sent_tokens[idx]
|
48 |
+
return robo_response
|
49 |
+
|
50 |
+
# cnn part
|
51 |
+
import numpy as np
|
52 |
+
import pandas as pd
|
53 |
+
from tensorflow.keras import models
|
54 |
+
from tensorflow.keras.preprocessing import image
|
55 |
+
from PIL import Image, UnidentifiedImageError
|
56 |
+
|
57 |
+
# load the model
|
58 |
+
loaded_model = models.load_model('728cnn.h5')
|
59 |
+
|
60 |
+
def get_class(str):
|
61 |
+
try:
|
62 |
+
test_image = Image.open(str)
|
63 |
+
Image.open
|
64 |
+
except BaseException:
|
65 |
+
return 'false'
|
66 |
+
else:
|
67 |
+
test_image = test_image.resize((28, 28))
|
68 |
+
test_image = image.img_to_array(test_image)
|
69 |
+
test_image = test_image.reshape(-1, 28, 28, 3)
|
70 |
+
test_image = test_image/255
|
71 |
+
# predict the result
|
72 |
+
result = loaded_model.predict(test_image)
|
73 |
+
# cancer classes
|
74 |
+
classes = {4: ('nv', 'melanocytic nevi'),
|
75 |
+
6: ('mel', 'melanoma'),
|
76 |
+
2: ('bkl', 'benign keratosis-like lesions'),
|
77 |
+
1: ('bcc' , 'basal cell carcinoma'),
|
78 |
+
5: ('vasc', 'pyogenic granulomas and hemorrhage'),
|
79 |
+
0: ('akiec', 'Actinic keratoses and intraepithelial carcinomae'),
|
80 |
+
3: ('df', 'dermatofibroma')}
|
81 |
+
return classes.get(np.argmax(result))[1]
|
82 |
+
|
83 |
+
def is_path(str):
|
84 |
+
pics = ['bmp','png','jpg','jpeg','tiff','gif', 'pcx', 'tga', 'exif', 'fpx', 'svg','psd','cdr','pc','dxf','ufo','eps','ai','raw']
|
85 |
+
if (str.find('.') == -1):
|
86 |
+
return -1
|
87 |
+
elif(str[str.rfind('.')+1::] in pics):
|
88 |
+
return str
|
89 |
+
else:
|
90 |
+
return -1
|
91 |
+
#/Users/yuxizheng/xizheng/proj_past_7007/Week_5/test_pics_with_label/ISIC_0034299_bcc_1.jpg
|
92 |
+
|
93 |
+
def chat(user_response):
|
94 |
+
rob_response = "DOCTOR STRANGE: Hi! I am a chatbot to tell you the diagnosis, please show me your skin picture."
|
95 |
+
# check input is path
|
96 |
+
path = is_path(user_response)
|
97 |
+
if (path == -1):
|
98 |
+
user_response = user_response.lower()
|
99 |
+
# process user response
|
100 |
+
if (user_response != 'bye'):
|
101 |
+
if (user_response == 'thanks' or user_response == 'thank you'):
|
102 |
+
flag = False
|
103 |
+
rob_response = "DOCTOR STRANGE: You are welcome, this is my job"
|
104 |
+
elif (path != -1):
|
105 |
+
r = get_class(path)
|
106 |
+
rob_response = "DOCTOR STRANGE: Please wait few second, your picture is processing."
|
107 |
+
if (r == 'false'):
|
108 |
+
rob_response ="DOCTOR STRANGE: Sorry, cannot find the picture through your input path. Please try again."
|
109 |
+
else:
|
110 |
+
rob_response ="DOCTOR STRANGE: The diagnosis shows that you are having " + r + '\n' + "DOCTOR STRANGE: " + response(r)
|
111 |
+
sent_tokens.remove(r)
|
112 |
+
else:
|
113 |
+
if (greeting(user_response) != None):
|
114 |
+
rob_response ="DOCTOR STRANGE: " + greeting(user_response)
|
115 |
+
else:
|
116 |
+
rob_response ="DOCTOR STRANGE: " +response(user_response)
|
117 |
+
|
118 |
+
sent_tokens.remove(user_response)
|
119 |
+
else:
|
120 |
+
rob_response ="DOCTOR STRANGE: Bye! take care."
|
121 |
+
return rob_response
|
main.py
ADDED
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
import tkinter.messagebox
|
3 |
+
|
4 |
+
|
5 |
+
from tkinter import *
|
6 |
+
from bot import chat
|
7 |
+
|
8 |
+
DIMS = "500x500"
|
9 |
+
|
10 |
+
|
11 |
+
class ChatInterface(Frame):
|
12 |
+
|
13 |
+
def __init__(self, master=None):
|
14 |
+
Frame.__init__(self, master)
|
15 |
+
self.master = master
|
16 |
+
|
17 |
+
# Default background setting
|
18 |
+
self.tl_bg = "#EEEEEE"
|
19 |
+
self.tl_bg2 = "#EEEEEE"
|
20 |
+
self.tl_fg = "#000000"
|
21 |
+
self.font = "Verdana 10"
|
22 |
+
|
23 |
+
# Menu bar
|
24 |
+
menu = Menu(self.master)
|
25 |
+
self.master.config(menu=menu, bd=5)
|
26 |
+
|
27 |
+
# File
|
28 |
+
file = Menu(menu, tearoff=0)
|
29 |
+
menu.add_cascade(label="File", menu=file)
|
30 |
+
|
31 |
+
# Clear chat option
|
32 |
+
file.add_command(label="Clear Chat", command=self.clear_chat)
|
33 |
+
|
34 |
+
# Exit chatbot option
|
35 |
+
file.add_command(label="Exit", command=self.chatexit)
|
36 |
+
|
37 |
+
# Preferences option
|
38 |
+
options = Menu(menu, tearoff=0)
|
39 |
+
menu.add_cascade(label="Preferences", menu=options)
|
40 |
+
|
41 |
+
# Fonts
|
42 |
+
font = Menu(options, tearoff=0)
|
43 |
+
options.add_cascade(label="Font", menu=font)
|
44 |
+
font.add_command(label="Default", command=self.font_change_default)
|
45 |
+
font.add_command(label="System", command=self.font_change_system)
|
46 |
+
|
47 |
+
# Theme
|
48 |
+
color_theme = Menu(options, tearoff=0)
|
49 |
+
options.add_cascade(label="Theme", menu=color_theme)
|
50 |
+
color_theme.add_command(label="Default", command=self.color_theme_default)
|
51 |
+
color_theme.add_command(label="Blue", command=self.color_theme_dark_blue)
|
52 |
+
color_theme.add_command(label="Hacker", command=self.color_theme_hacker)
|
53 |
+
|
54 |
+
help_option = Menu(menu, tearoff=0)
|
55 |
+
menu.add_cascade(label="About", menu=help_option)
|
56 |
+
help_option.add_command(label="About Chatbot", command=self.msg)
|
57 |
+
|
58 |
+
self.text_frame = Frame(self.master, bd=6)
|
59 |
+
self.text_frame.pack(expand=True, fill=BOTH)
|
60 |
+
|
61 |
+
# Scrollbar for text box
|
62 |
+
self.text_box_scrollbar = Scrollbar(self.text_frame, bd=0)
|
63 |
+
self.text_box_scrollbar.pack(fill=Y, side=RIGHT)
|
64 |
+
|
65 |
+
# Contains messages
|
66 |
+
self.text_box = Text(self.text_frame, yscrollcommand=self.text_box_scrollbar.set, state=DISABLED,
|
67 |
+
bd=1, padx=6, pady=6, spacing3=8, wrap=WORD, bg=None, font="Verdana 10", relief=GROOVE,
|
68 |
+
width=10, height=1)
|
69 |
+
self.text_box.pack(expand=True, fill=BOTH)
|
70 |
+
self.text_box_scrollbar.config(command=self.text_box.yview)
|
71 |
+
|
72 |
+
# Frame containing user entry field
|
73 |
+
self.entry_frame = Frame(self.master, bd=1)
|
74 |
+
self.entry_frame.pack(side=LEFT, fill=BOTH, expand=True)
|
75 |
+
|
76 |
+
# Entry field
|
77 |
+
self.entry_field = Entry(self.entry_frame, bd=1, justify=LEFT)
|
78 |
+
self.entry_field.pack(fill=X, padx=6, pady=6, ipady=3)
|
79 |
+
# self.users_message = self.entry_field.get()
|
80 |
+
|
81 |
+
# Frame containing send button and emoji button
|
82 |
+
self.send_button_frame = Frame(self.master, bd=0)
|
83 |
+
self.send_button_frame.pack(fill=BOTH)
|
84 |
+
|
85 |
+
# Send button
|
86 |
+
self.send_button = Button(self.send_button_frame, text="Send", width=5, relief=GROOVE, bg='white',
|
87 |
+
bd=1, command=lambda: self.send_message_insert(None), activebackground="#FFFFFF",
|
88 |
+
activeforeground="#000000")
|
89 |
+
self.send_button.pack(side=LEFT, ipady=8)
|
90 |
+
self.master.bind("<Return>", self.send_message_insert)
|
91 |
+
|
92 |
+
self.last_sent_label(date="No messages sent.")
|
93 |
+
# t2 = threading.Thread(target=self.send_message_insert(, name='t1')
|
94 |
+
# t2.start()
|
95 |
+
|
96 |
+
self.text_box.configure(state=NORMAL)
|
97 |
+
self.text_box.insert(END, "DOCTOR STRANGE: Hi! I am a chatbot to tell you the diagnosis, please show me your skin picture.\n")
|
98 |
+
self.text_box.configure(state=DISABLED)
|
99 |
+
self.text_box.see(END)
|
100 |
+
|
101 |
+
def last_sent_label(self, date):
|
102 |
+
|
103 |
+
try:
|
104 |
+
self.sent_label.destroy()
|
105 |
+
except AttributeError:
|
106 |
+
pass
|
107 |
+
|
108 |
+
self.sent_label = Label(self.entry_frame, font="Verdana 7", text=date, bg=self.tl_bg2, fg=self.tl_fg)
|
109 |
+
self.sent_label.pack(side=LEFT, fill=X, padx=3)
|
110 |
+
|
111 |
+
def clear_chat(self):
|
112 |
+
self.text_box.config(state=NORMAL)
|
113 |
+
self.last_sent_label(date="No messages sent.")
|
114 |
+
self.text_box.delete(1.0, END)
|
115 |
+
self.text_box.delete(1.0, END)
|
116 |
+
self.text_box.config(state=DISABLED)
|
117 |
+
|
118 |
+
def chatexit(self):
|
119 |
+
exit()
|
120 |
+
|
121 |
+
def msg(self):
|
122 |
+
tkinter.messagebox.showinfo("NLP - Neural Network based chatbot")
|
123 |
+
|
124 |
+
def about(self):
|
125 |
+
tkinter.messagebox.showinfo("Chatbot by AI")
|
126 |
+
|
127 |
+
def send_message_insert(self, message):
|
128 |
+
|
129 |
+
user_input = self.entry_field.get()
|
130 |
+
pr1 = "You : " + user_input + "\n"
|
131 |
+
|
132 |
+
self.text_box.configure(state=NORMAL)
|
133 |
+
self.text_box.insert(END, pr1)
|
134 |
+
self.text_box.configure(state=DISABLED)
|
135 |
+
self.text_box.see(END)
|
136 |
+
|
137 |
+
response = chat(user_input)
|
138 |
+
pr = response + "\n" #这个要修改这个要修改#这个要修改这个要修改#这个要修改这个要修改#这个要修改这个要修改#这个要修改这个要修改#这个要修改这个要修改#这个要修改这个要修改
|
139 |
+
|
140 |
+
self.text_box.configure(state=NORMAL)
|
141 |
+
self.text_box.insert(END, pr)
|
142 |
+
self.text_box.configure(state=DISABLED)
|
143 |
+
self.text_box.see(END)
|
144 |
+
self.last_sent_label(str(time.strftime("Last message sent: " + '%B %d, %Y' + ' at ' + '%I:%M %p')))
|
145 |
+
self.entry_field.delete(0, END)
|
146 |
+
|
147 |
+
def font_change_default(self):
|
148 |
+
self.text_box.config(font="Verdana 10")
|
149 |
+
self.entry_field.config(font="Verdana 10")
|
150 |
+
self.font = "Verdana 10"
|
151 |
+
|
152 |
+
def font_change_system(self):
|
153 |
+
self.text_box.config(font="System")
|
154 |
+
self.entry_field.config(font="System")
|
155 |
+
self.font = "System"
|
156 |
+
|
157 |
+
def font_change_fixedsys(self):
|
158 |
+
self.text_box.config(font="fixedsys")
|
159 |
+
self.entry_field.config(font="fixedsys")
|
160 |
+
self.font = "fixedsys"
|
161 |
+
|
162 |
+
def color_theme_default(self):
|
163 |
+
self.master.config(bg="#EEEEEE")
|
164 |
+
self.text_frame.config(bg="#EEEEEE")
|
165 |
+
self.entry_frame.config(bg="#EEEEEE")
|
166 |
+
self.text_box.config(bg="#FFFFFF", fg="#000000")
|
167 |
+
self.entry_field.config(bg="#FFFFFF", fg="#000000", insertbackground="#000000")
|
168 |
+
self.send_button_frame.config(bg="#EEEEEE")
|
169 |
+
self.send_button.config(bg="#FFFFFF", fg="#000000", activebackground="#FFFsFFF", activeforeground="#000000")
|
170 |
+
self.sent_label.config(bg="#EEEEEE", fg="#000000")
|
171 |
+
|
172 |
+
self.tl_bg = "#FFFFFF"
|
173 |
+
self.tl_bg2 = "#EEEEEE"
|
174 |
+
self.tl_fg = "#000000"
|
175 |
+
|
176 |
+
# Dark
|
177 |
+
def color_theme_dark(self):
|
178 |
+
self.master.config(bg="#2a2b2d")
|
179 |
+
self.text_frame.config(bg="#2a2b2d")
|
180 |
+
self.text_box.config(bg="#212121", fg="#FFFFFF")
|
181 |
+
self.entry_frame.config(bg="#2a2b2d")
|
182 |
+
self.entry_field.config(bg="#212121", fg="#FFFFFF", insertbackground="#FFFFFF")
|
183 |
+
self.send_button_frame.config(bg="#2a2b2d")
|
184 |
+
self.send_button.config(bg="#212121", fg="#FFFFFF", activebackground="#212121", activeforeground="#FFFFFF")
|
185 |
+
self.sent_label.config(bg="#2a2b2d", fg="#FFFFFF")
|
186 |
+
|
187 |
+
self.tl_bg = "#212121"
|
188 |
+
self.tl_bg2 = "#2a2b2d"
|
189 |
+
self.tl_fg = "#FFFFFF"
|
190 |
+
|
191 |
+
# Blue
|
192 |
+
def color_theme_dark_blue(self):
|
193 |
+
self.master.config(bg="#263b54")
|
194 |
+
self.text_frame.config(bg="#263b54")
|
195 |
+
self.text_box.config(bg="#1c2e44", fg="#FFFFFF")
|
196 |
+
self.entry_frame.config(bg="#263b54")
|
197 |
+
self.entry_field.config(bg="#1c2e44", fg="#FFFFFF", insertbackground="#FFFFFF")
|
198 |
+
self.send_button_frame.config(bg="#263b54")
|
199 |
+
self.send_button.config(bg="#1c2e44", fg="#FFFFFF", activebackground="#1c2e44", activeforeground="#FFFFFF")
|
200 |
+
self.sent_label.config(bg="#263b54", fg="#FFFFFF")
|
201 |
+
|
202 |
+
self.tl_bg = "#1c2e44"
|
203 |
+
self.tl_bg2 = "#263b54"
|
204 |
+
self.tl_fg = "#FFFFFF"
|
205 |
+
|
206 |
+
# Hacker
|
207 |
+
|
208 |
+
def color_theme_hacker(self):
|
209 |
+
self.master.config(bg="#0F0F0F")
|
210 |
+
self.text_frame.config(bg="#0F0F0F")
|
211 |
+
self.entry_frame.config(bg="#0F0F0F")
|
212 |
+
self.text_box.config(bg="#0F0F0F", fg="#33FF33")
|
213 |
+
self.entry_field.config(bg="#0F0F0F", fg="#33FF33", insertbackground="#33FF33")
|
214 |
+
self.send_button_frame.config(bg="#0F0F0F")
|
215 |
+
self.send_button.config(bg="#0F0F0F", fg="#FFFFFF", activebackground="#0F0F0F", activeforeground="#FFFFFF")
|
216 |
+
self.sent_label.config(bg="#0F0F0F", fg="#33FF33")
|
217 |
+
|
218 |
+
self.tl_bg = "#0F0F0F"
|
219 |
+
self.tl_bg2 = "#0F0F0F"
|
220 |
+
self.tl_fg = "#33FF33"
|
221 |
+
|
222 |
+
# Default font and color theme
|
223 |
+
def default_format(self):
|
224 |
+
self.font_change_default()
|
225 |
+
self.color_theme_default()
|
226 |
+
|
227 |
+
|
228 |
+
root = Tk()
|
229 |
+
ob = ChatInterface(root)
|
230 |
+
root.geometry(DIMS)
|
231 |
+
root.title("Chatbot")
|
232 |
+
|
233 |
+
|
234 |
+
root.mainloop()
|
show_data.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# cnn part
|
2 |
+
import numpy as np
|
3 |
+
import pandas as pd
|
4 |
+
from tensorflow.keras import models
|
5 |
+
from tensorflow.keras.preprocessing import image
|
6 |
+
from PIL import Image, UnidentifiedImageError
|
7 |
+
|
8 |
+
# load the model
|
9 |
+
loaded_model = models.load_model('728cnn.h5')
|
10 |
+
|
11 |
+
print(loaded_model.summary())
|
12 |
+
|
13 |
+
'''import numpy as np
|
14 |
+
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
|
15 |
+
# plot the graph of disease distribution in different positions
|
16 |
+
from matplotlib import pyplot as plt
|
17 |
+
|
18 |
+
dataset = pd.read_csv("/Users/yuxizheng/xizheng/proj_past_7007/Week_5/Skin_Cancer_MNIST_HAM10000/hmnist_28_28_RGB.csv")
|
19 |
+
|
20 |
+
image_data = dataset.drop(['label'], axis = 1)
|
21 |
+
image_data = np.array(image_data)
|
22 |
+
images = image_data.reshape(-1, 28, 28, 3)
|
23 |
+
|
24 |
+
plt.figure(figsize = (10,20))
|
25 |
+
for i in range(5) :
|
26 |
+
plt.subplot(1,5,i+1)
|
27 |
+
plt.imshow(images[i])
|
28 |
+
plt.show()'''
|
29 |
+
|
30 |
+
'''
|
31 |
+
import numpy as np
|
32 |
+
import pandas as pd
|
33 |
+
from tensorflow.keras import models
|
34 |
+
import joblib
|
35 |
+
|
36 |
+
# load the model
|
37 |
+
# training = models.load_model("828cnn.h5")
|
38 |
+
dataset = pd.read_csv("/Users/yuxizheng/xizheng/proj_past_7007/Week_5/Skin_Cancer_MNIST_HAM10000/hmnist_28_28_RGB.csv")
|
39 |
+
metadata = pd.read_csv("/Users/yuxizheng/xizheng/proj_past_7007/Week_5/Skin_Cancer_MNIST_HAM10000/HAM10000_metadata.csv")
|
40 |
+
print(metadata['dx'].value_counts())
|
41 |
+
from matplotlib import pyplot as plt
|
42 |
+
import seaborn as sns
|
43 |
+
sns.countplot(x = 'dx', data = metadata)
|
44 |
+
plt.title('Disease class distribution')
|
45 |
+
plt.show()
|
46 |
+
'''
|
47 |
+
'''
|
48 |
+
history = joblib.load('/Users/yuxizheng/xizheng/proj_past_7007/Week_9/history_cnn')
|
49 |
+
|
50 |
+
print(history['accuracy'])
|
51 |
+
print(history['val_accuracy'])
|
52 |
+
print(history['loss'])
|
53 |
+
print(history['val_loss'])
|
54 |
+
'''
|
55 |
+
'''
|
56 |
+
from matplotlib import pyplot as plt
|
57 |
+
# plot the accuracy of training and validation
|
58 |
+
plt.plot(history['accuracy'])
|
59 |
+
plt.plot(history['val_accuracy'])
|
60 |
+
plt.title('model accuracy')
|
61 |
+
plt.ylabel('accuracy')
|
62 |
+
plt.xlabel('epoch')
|
63 |
+
plt.legend(['train', 'validation'])
|
64 |
+
plt.show()
|
65 |
+
|
66 |
+
# plot the loss of training and validation
|
67 |
+
plt.plot(history['loss'])
|
68 |
+
plt.plot(history['val_loss'])
|
69 |
+
plt.title('model loss')
|
70 |
+
plt.ylabel('loss')
|
71 |
+
plt.xlabel('epoch')
|
72 |
+
plt.legend(['train', 'validation'])
|
73 |
+
plt.show()
|
74 |
+
'''
|
skin cancer.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Basal cell carcinoma (BCC) is the most common form of skin cancer and the most frequently occurring form of all cancers. In tbyehe U.S. alone, an estimated 3.6 million cases are diagnosed each year. BCCs arise from abnormal, uncontrolled growth of basal cells. Because BCCs grow slowly, most are curable and cause minimal damage when caught and treated early. Understanding BCC causes, risk factors and warning signs can help you detect them early, when they are easiest to treat and cure.
|
2 |
+
Dermofibroma is a benign tumor in the dermis caused by the focal proliferation of fibroblasts or histiocytes. The disease can occur at any age. It is more common in young and middle-aged people, and more women than men. It can occur naturally or after trauma. Tawny or light red intradermal papules or nodules are the clinical features of this disease. The lesions grow slowly, exist for a long time, and rarely resolve spontaneously.
|
3 |
+
Melanoma, usually refers to malignant melanoma, is a highly malignant tumor derived from melanocytes, referred to as malignant melanoma, which occurs mostly in the skin, but also in mucous membranes and internal organs, accounting for about 3% of all tumors. Skin malignant melanoma accounts for the third place (about 6.8%~20%) of skin malignant tumors. It is more common in adults, white-skinned whites have a high incidence, while dark-skinned Asians and Africans have a lower incidence and are rarely seen in children. Some patients have familial multiple findings. Malignant melanoma can evolve from congenital or acquired benign melanocytic nevi, or malignantly evolve from dysplastic nevi, or it can occur newly. In recent years, the incidence and mortality of malignant melanoma have been increasing year by year. Compared with other solid tumors, the age of death is lower. Except for early surgical resection, malignant melanoma lacks specific treatment and has a poor prognosis. Therefore, the early diagnosis and treatment of malignant melanoma is extremely important.
|
4 |
+
Melanocytic nevi is produced by a group of benign melanocytes that gather at the junction of the epidermis and the dermis. Melanocytes may be distributed in the lower reticular diemis, between collagen bundles, and other accessory organs surrounding the skin such as sweat glands, hair follicles, blood vessels, nerves, etc., and occasionally extend under the skin. Fat.
|
5 |
+
Actinic keratosis is an occupational disease, which is mainly induced by sunlight, ultraviolet rays, radioactive heat, asphalt or coal and its extracts. The lesions are more common in the sun-exposed parts of middle-aged men and older, such as the face, auricles, and the back of the hands. Mainly manifested as rough surface with visible keratinizing scales. Peel off the scales, you can see that the underlying base surface is ruddy, bumpy, and papillary. Treatment generally takes external medication and surgical treatment. 20% can develop secondary squamous cell carcinoma.
|
6 |
+
Benign keratosis-like lesions is a group of skin diseases with hyperkeratosis as the main change. It can show local skin keratinous hyperplasia, dry skin, scaly, chapped, generally no subjective discomfort, sometimes itching or pain, often aggravated in winter.
|
7 |
+
Vascular lesions are congenital benign tumors or vascular malformations commonly found in the skin and soft tissues formed by the proliferation of hemangioblasts during the embryonic period. They are more common at birth or shortly after birth. The remaining embryonic hemangioblasts and active endothelioid germs invade adjacent tissues to form endothelioid cords, which are connected to the remaining blood vessels to form hemangioma after tubeization. The blood vessels in the tumor form a system of its own and are not connected to the surrounding blood vessels.
|
8 |
+
Cancer treatment methods mainly include surgery, chemotherapy, radiotherapy, and targeted and immunotherapy developed in recent years. Traditional Chinese medicine treatment can also achieve certain therapeutic effects for some malignant tumors.
|