eyupipler commited on
Commit
d9a0d0e
1 Parent(s): 7a2ccff

TR and EN languages

Browse files
Files changed (1) hide show
  1. README.md +336 -11
README.md CHANGED
@@ -15,6 +15,330 @@ tags:
15
  - neura
16
  - neuro
17
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  # bai Models
19
 
20
  ## Model Details
@@ -26,7 +350,7 @@ tags:
26
  - **Developed by:** _Neurazum_
27
  - **Shared by:** _Eyüp İpler_
28
  - **Model type:** _EEG_
29
- - **License:** CC-BY-NC-SA-4.0
30
 
31
  ## Uses
32
 
@@ -35,7 +359,6 @@ tags:
35
  - _To analyse the person's emotion instantly,_
36
  - _To warn dangerous patients such as epilepsy and MS early before the seizure and to take the necessary precautions,_
37
  - _Early diagnosis for Alzheimer's patients and the bai model helps the person by memorising forgotten words,_
38
- - _Development of mind-controlled games for players,_
39
  - _Development of a voice assistant that can be used in everyday life,_
40
  - _Reducing the margin of error in disease diagnosis thanks to the 12 cranial nerves in the human body._
41
 
@@ -180,9 +503,10 @@ class MainWindow(QMainWindow):
180
  data = np.frombuffer(stream.read(CHUNK), dtype=np.int16)
181
  data = np.abs(data)
182
  voltage_data = data * (3.3 / 1024) # Voltage to "mV"
 
183
 
184
  self.line1.set_ydata(data)
185
- self.line2.set_ydata(voltage_data)
186
 
187
  for coll in self.ax1.collections:
188
  coll.remove()
@@ -194,7 +518,7 @@ class MainWindow(QMainWindow):
194
  self.ax1.fill_between(self.x, data, where=((self.x >= 30) & (self.x <= 100)), color='purple', alpha=1)
195
 
196
  self.ax1.legend(handles=self.legend_elements, loc='upper right')
197
- self.ax1.set_ylabel('Value (dB)')
198
  self.ax1.set_xlabel('Frequency (Hz)')
199
  self.ax1.set_title('Frequency and mV')
200
 
@@ -289,6 +613,7 @@ print(f'Accuracy: %{accuracy * 100:.5f}')
289
 
290
  ## How to Get Started with the Model
291
 
 
292
  - ```bash
293
  pip install -r requirements.txt
294
  ```
@@ -297,9 +622,9 @@ print(f'Accuracy: %{accuracy * 100:.5f}')
297
 
298
  ## Evaluation
299
 
300
- - bai-2.0 (Accuracy very high = 97%, 93621013133208)(EMOTIONAL CLASSIFICATION) (AUTONOMOUS MODEL) (High probability of OVERFITTING)
301
- - bai-2.1 (Accuracy very high = 97%, 93621013133208)(EMOTIONAL CLASSIFICATION) (AUTONOMOUS MODEL) (Low probability of OVERFITTING)
302
- - bai-2.2 (Accuracy very high = 94%, 8874296435272)(EMOTIONAL CLASSIFICATION) (AUTONOMOUS MODEL) (Low probability of OVERFITTING)
303
 
304
  ### Results
305
 
@@ -325,14 +650,14 @@ You can then operate this EEG device (for the time being only with audio input)
325
 
326
  GitHub: https://github.com/neurazum/Realtime-EEG-Monitoring
327
 
328
- ## More Information
329
 
330
  LinkedIn: https://www.linkedin.com/company/neurazum
331
 
332
- ## Model Card Authors
333
 
334
  Eyüp İpler - https://www.linkedin.com/in/eyupipler/
335
 
336
- ## Model Card Contact
337
 
338
- neurazum@gmail.com
 
15
  - neura
16
  - neuro
17
  ---
18
+ # bai Modelleri
19
+
20
+ ## Model Detayları
21
+
22
+ #### bai Modelleri EEG verilerini okumak için eğitilmiştir. Bu modellerin eğitildiği veri setleri Neurazum tarafından gizli tutulmaktadır. Derin öğrenme yöntemleri ile eğitilir ve çok yüksek doğruluk oranları ile EEG üzerinde hassas bir şekilde çalışabilir. Elektrot sayısına bakılmaksızın her türlü EEG cihazı üzerinde çalışabilmektedir (Optimizasyon ve iyileştirmeler devam etmektedir). Nörobilim alanındaki geri kalmışlığa, ilkelliğe ve hata paylarına son vermeyi hedeflemektedir.
23
+
24
+ ### Model Tanımı
25
+
26
+ - **Geliştirici:** _Neurazum_
27
+ - **Yayımcı:** _Eyüp İpler_
28
+ - **Model Tipi:** _EEG_
29
+ - **Lisans:** _CC-BY-NC-SA-4.0_
30
+
31
+ ## Kullanımlar
32
+
33
+ **Bu modellerdeki amacımız;**
34
+
35
+ - _Kişinin duygusunu anlık olarak analiz etmek,_
36
+ - _Epilepsi ve MS gibi tehlikeli hastalıkları nöbet öncesi erken uyarmak ve gerekli önlemleri almak,_
37
+ - _Alzheimer hastaları için erken teşhis ve unutulan kelimeleri bai modeline aktararak hafızada tutmak,_
38
+ - _Günlük hayatta kullanılabilecek bir sesli yapay zeka asistanının geliştirilmesi._
39
+ - _İnsan vücudunda bulunan 12 adet kraniyal sinir sayesinde hastalık teşhisinde hata payının azaltılması._
40
+
41
+ ## Direkt Kullanımlar
42
+
43
+ **Klasik Kullanım:**
44
+
45
+ ```python
46
+ import numpy as np
47
+ import pandas as pd
48
+ from sklearn.preprocessing import StandardScaler
49
+ from tensorflow.keras.models import load_model
50
+ import matplotlib.pyplot as plt
51
+
52
+ model_path = 'model-yolu'
53
+
54
+ model = load_model(model_path)
55
+
56
+ model_name = model_path.split('/')[-1].split('.')[0]
57
+
58
+ plt.figure(figsize=(10, 6))
59
+ plt.title(f'Duygu Tahmini ({model_name})')
60
+ plt.xlabel('Zaman')
61
+ plt.ylabel('Sınıf')
62
+ plt.legend(loc='upper right')
63
+ plt.grid(True)
64
+ plt.show()
65
+ model.summary()
66
+ ```
67
+
68
+ **Tahmin Testi:**
69
+
70
+ ```python
71
+ import numpy as np
72
+ import pandas as pd
73
+ from sklearn.preprocessing import StandardScaler
74
+ from tensorflow.keras.models import load_model
75
+
76
+ model_path = 'model-yolu'
77
+
78
+ model = load_model(model_path)
79
+
80
+ scaler = StandardScaler()
81
+
82
+ predictions = model.predict(X_new_reshaped)
83
+ predicted_labels = np.argmax(predictions, axis=1)
84
+
85
+ label_mapping = {'NEGATIVE': 0, 'NEUTRAL': 1, 'POSITIVE': 2}
86
+ label_mapping_reverse = {v: k for k, v in label_mapping.items()}
87
+
88
+ #new_input = np.array([[23, 465, 12, 9653] * 637])
89
+ new_input = np.random.rand(1, 2548) # 1 örnek ve 2548 özellik
90
+ new_input_scaled = scaler.fit_transform(new_input)
91
+ new_input_reshaped = new_input_scaled.reshape((new_input_scaled.shape[0], 1, new_input_scaled.shape[1]))
92
+
93
+ new_prediction = model.predict(new_input_reshaped)
94
+ predicted_label = np.argmax(new_prediction, axis=1)[0]
95
+ predicted_emotion = label_mapping_reverse[predicted_label]
96
+
97
+ # TR Lang
98
+ if predicted_emotion == 'NEGATIVE':
99
+ predicted_emotion = 'Negatif'
100
+ elif predicted_emotion == 'NEUTRAL':
101
+ predicted_emotion = 'Nötr'
102
+ elif predicted_emotion == 'POSITIVE':
103
+ predicted_emotion = 'Pozitif'
104
+
105
+ print(f'Girilen Veri: {new_input}')
106
+ print(f'Tahmin Edilen Duygu: {predicted_emotion}')
107
+ ```
108
+ **Gerçek Zamanlı Kullanım (Modelsiz):**
109
+
110
+ ```python
111
+ import sys
112
+ import pyaudio
113
+ import numpy as np
114
+ import matplotlib.pyplot as plt
115
+ from matplotlib.lines import Line2D
116
+ from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget
117
+ from PyQt5.QtCore import QTimer
118
+ from PyQt5.QtGui import QIcon
119
+ from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
120
+ from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
121
+
122
+
123
+ CHUNK = 1000 # Chunk size
124
+ FORMAT = pyaudio.paInt16 # Data type (16-bit PCM)
125
+ CHANNELS = 1 # (Mono)
126
+ RATE = 2000 # Sample rate (Hz)
127
+
128
+ p = pyaudio.PyAudio()
129
+
130
+ stream = p.open(format=FORMAT,
131
+ channels=CHANNELS,
132
+ rate=RATE,
133
+ input=True,
134
+ frames_per_buffer=CHUNK)
135
+
136
+
137
+ class MainWindow(QMainWindow):
138
+ def __init__(self):
139
+ super().__init__()
140
+
141
+ self.initUI()
142
+
143
+ self.timer = QTimer()
144
+ self.timer.timeout.connect(self.update_plot)
145
+ self.timer.start(1)
146
+
147
+ def initUI(self):
148
+ self.setWindowTitle('EEG Monitoring by Neurazum')
149
+ self.setWindowIcon(QIcon('/neurazumicon.ico'))
150
+
151
+ self.central_widget = QWidget()
152
+ self.setCentralWidget(self.central_widget)
153
+
154
+ self.layout = QVBoxLayout(self.central_widget)
155
+
156
+ self.fig, (self.ax1, self.ax2) = plt.subplots(2, 1, figsize=(12, 8), gridspec_kw={'height_ratios': [9, 1]})
157
+ self.fig.tight_layout()
158
+ self.canvas = FigureCanvas(self.fig)
159
+
160
+ self.layout.addWidget(self.canvas)
161
+
162
+ self.toolbar = NavigationToolbar(self.canvas, self)
163
+ self.layout.addWidget(self.toolbar)
164
+
165
+ self.x = np.arange(0, 2 * CHUNK, 2)
166
+ self.line1, = self.ax1.plot(self.x, np.random.rand(CHUNK))
167
+ self.line2, = self.ax2.plot(self.x, np.random.rand(CHUNK))
168
+
169
+ self.legend_elements = [
170
+ Line2D([0, 4], [0], color='yellow', lw=4, label='DELTA (0hz-4hz)'),
171
+ Line2D([4, 7], [0], color='blue', lw=4, label='TETA (4hz-7hz)'),
172
+ Line2D([8, 12], [0], color='green', lw=4, label='ALFA (8hz-12hz)'),
173
+ Line2D([12, 30], [0], color='red', lw=4, label='BETA (12hz-30hz)'),
174
+ Line2D([30, 100], [0], color='purple', lw=4, label='GAMA (30hz-100hz)')
175
+ ]
176
+
177
+ def update_plot(self):
178
+ data = np.frombuffer(stream.read(CHUNK), dtype=np.int16)
179
+ data = np.abs(data)
180
+ voltage_data = data * (3.3 / 1024) # Voltajı "mV"'ye dönüştürme
181
+ frequency = voltage_data / (RATE * 1000) # Frekans hesaplama
182
+
183
+ self.line1.set_ydata(data)
184
+ self.line2.set_ydata(frequency)
185
+
186
+ for coll in self.ax1.collections:
187
+ coll.remove()
188
+
189
+ self.ax1.fill_between(self.x, data, where=((self.x >= 0) & (self.x <= 4)), color='yellow', alpha=1)
190
+ self.ax1.fill_between(self.x, data, where=((self.x >= 4) & (self.x <= 7)), color='blue', alpha=1)
191
+ self.ax1.fill_between(self.x, data, where=((self.x >= 8) & (self.x <= 12)), color='green', alpha=1)
192
+ self.ax1.fill_between(self.x, data, where=((self.x >= 12) & (self.x <= 30)), color='red', alpha=1)
193
+ self.ax1.fill_between(self.x, data, where=((self.x >= 30) & (self.x <= 100)), color='purple', alpha=1)
194
+
195
+ self.ax1.legend(handles=self.legend_elements, loc='upper right')
196
+ self.ax1.set_ylabel('Genlik (uV)')
197
+ self.ax1.set_xlabel('Frekans (Hz)')
198
+ self.ax1.set_title('Frekans ve Genlik Değerleri')
199
+
200
+ self.ax2.set_ylabel('Voltaj (mV)')
201
+ self.ax2.set_xlabel('Zaman')
202
+
203
+ self.canvas.draw()
204
+
205
+ def close_application(self):
206
+ self.timer.stop()
207
+ stream.stop_stream()
208
+ stream.close()
209
+ p.terminate()
210
+ sys.exit(app.exec_())
211
+
212
+
213
+ if __name__ == '__main__':
214
+ app = QApplication(sys.argv)
215
+ mainWin = MainWindow()
216
+ mainWin.show()
217
+ sys.exit(app.exec_())
218
+ ```
219
+
220
+ **Duyguları İçeren Veri Seti Üzerinde Tahmin:**
221
+
222
+ ```python
223
+ import numpy as np
224
+ import pandas as pd
225
+ from sklearn.preprocessing import StandardScaler
226
+ from tensorflow.keras.models import load_model
227
+
228
+ model_path = 'model-yolu'
229
+ new_data_path = 'veri-seti-yolu'
230
+
231
+ model = load_model(model_path)
232
+
233
+ new_data = pd.read_csv(new_data_path)
234
+
235
+ X_new = new_data.drop('label', axis=1)
236
+ y_new = new_data['label']
237
+
238
+ scaler = StandardScaler()
239
+ X_new_scaled = scaler.fit_transform(X_new)
240
+ X_new_reshaped = X_new_scaled.reshape((X_new_scaled.shape[0], 1, X_new_scaled.shape[1]))
241
+
242
+ predictions = model.predict(X_new_reshaped)
243
+ predicted_labels = np.argmax(predictions, axis=1)
244
+
245
+ label_mapping = {'NEGATIVE': 0, 'NEUTRAL': 1, 'POSITIVE': 2}
246
+ label_mapping_reverse = {v: k for k, v in label_mapping.items()}
247
+ actual_labels = y_new.replace(label_mapping).values
248
+
249
+ accuracy = np.mean(predicted_labels == actual_labels)
250
+
251
+ new_input = np.random.rand(2548, 2548) # 1 örnek ve 2548 özellik
252
+ new_input_scaled = scaler.transform(new_input)
253
+ new_input_reshaped = new_input_scaled.reshape((new_input_scaled.shape[0], 1, new_input_scaled.shape[1]))
254
+
255
+ new_prediction = model.predict(new_input_reshaped)
256
+ predicted_label = np.argmax(new_prediction, axis=1)[0]
257
+ predicted_emotion = label_mapping_reverse[predicted_label]
258
+
259
+
260
+ # TR Lang
261
+ if predicted_emotion == 'NEGATIVE':
262
+ predicted_emotion = 'Negatif'
263
+ elif predicted_emotion == 'NEUTRAL':
264
+ predicted_emotion = 'Nötr'
265
+ elif predicted_emotion == 'POSITIVE':
266
+ predicted_emotion = 'Pozitif'
267
+
268
+ print(f'Giriş Verisi: {new_input}')
269
+ print(f'Tahmin Edilen Duygu: {predicted_emotion}')
270
+ print(f'Doğruluk: %{accuracy * 100:.5f}')
271
+ ```
272
+
273
+ ## Önyargı, Riskler ve Kısıtlamalar
274
+
275
+ **bai Modelleri;**
276
+
277
+ - _En büyük riski yanlış tahmin etmesidir :),_
278
+ - _Herhangi bir kısıtlama bulunmamaktadır (şimdilik),_
279
+ - _Beyin sinyallerinden elde edilen veriler kişisel bilgi içermez (çünkü bunlar sadece mV değerleridir). Bu nedenle, bai tarafından yapılan her tahmin sadece bir "TAHMİN" dir._
280
+
281
+ ### Öneriler
282
+
283
+ - _Çok fazla duygu durum değişikliği yaşamamaya çalışın,_
284
+ - _Çok fazla farklı nitelikte düşünce/karar almayın,_
285
+ - _Çok fazla hata yaptığında, yanlış cevap verdiğini düşünmeyin (doğru cevap verdiğini farz edin),_
286
+
287
+ **Not: Bu öğeler sadece modelin daha iyi çalışması için önerilerdir. Herhangi bir risk taşımazlar.**
288
+
289
+ ## Modele Nasıl Başlanır
290
+
291
+ - Modelin içeriğindeki gerekli modülleri kurmak için;
292
+ - ```bash
293
+ pip install -r requirements.txt
294
+ ```
295
+ - Örnek kullanımla modelin ve veritinin yolunu yerleştirin.
296
+ - Ve dosyayı çalıştırın.
297
+
298
+ ## Değerlendirme
299
+
300
+ - bai-2.0 (Doğruluk oranı çok yüksek = %97,93621013133208)(DUYGUSAL SINIFLANDIRMA) (OTONOM MODEL) (Overfitting ihtimali yüksek)
301
+ - bai-2.1 (Doğruluk oranı çok yüksek = %97,93621013133208)(DUYGUSAL SINIFLANDIRMA) (OTONOM MODEL) (Overfitting ihtimali düşük)
302
+ - bai-2.2 (Doğruluk oranı çok yüksek = %94,8874296435272)(DUYGUSAL SINIFLANDIRMA) (OTONOM MODEL) (Overfitting ihtimali düşük)
303
+
304
+ ### Sonuçlar
305
+
306
+ [![image](https://r.resimlink.com/O7GyMoQL.png)](https://resimlink.com/O7GyMoQL)
307
+
308
+ [![image](https://r.resimlink.com/gdyCW3RP.png)](https://resimlink.com/gdyCW3RP)
309
+
310
+ [![image](https://r.resimlink.com/MpH9XS_0E.png)](https://resimlink.com/MpH9XS_0E)
311
+
312
+ [![image](https://r.resimlink.com/vsyYqJnQ4k.png)](https://resimlink.com/vsyYqJnQ4k)
313
+
314
+ #### Özet
315
+
316
+ Özetle bai modelleri, kişinin düşüncelerini ve duygularını öğrenmek ve tahmin etmek için geliştirilmeye devam ediyor.
317
+
318
+ #### Donanım
319
+
320
+ Tek ihtiyacınız olan şey EEG!
321
+
322
+ #### Yazılım
323
+
324
+ Daha sonra bu EEG cihazını (şimdilik sadece ses girişi ile) yayınladığımız gerçek zamanlı veri izleme uygulamasıyla çalıştırabilirsiniz.
325
+
326
+ GitHub: https://github.com/neurazum/Realtime-EEG-Monitoring
327
+
328
+ ## Daha Fazla
329
+
330
+ LinkedIn: https://www.linkedin.com/company/neurazum
331
+
332
+ ### Yazar
333
+
334
+ Eyüp İpler - https://www.linkedin.com/in/eyupipler/
335
+
336
+ ### İletişim
337
+
338
+ neurazum@gmail.com
339
+
340
+ # ---------------------------------------
341
+
342
  # bai Models
343
 
344
  ## Model Details
 
350
  - **Developed by:** _Neurazum_
351
  - **Shared by:** _Eyüp İpler_
352
  - **Model type:** _EEG_
353
+ - **License:** _CC-BY-NC-SA-4.0_
354
 
355
  ## Uses
356
 
 
359
  - _To analyse the person's emotion instantly,_
360
  - _To warn dangerous patients such as epilepsy and MS early before the seizure and to take the necessary precautions,_
361
  - _Early diagnosis for Alzheimer's patients and the bai model helps the person by memorising forgotten words,_
 
362
  - _Development of a voice assistant that can be used in everyday life,_
363
  - _Reducing the margin of error in disease diagnosis thanks to the 12 cranial nerves in the human body._
364
 
 
503
  data = np.frombuffer(stream.read(CHUNK), dtype=np.int16)
504
  data = np.abs(data)
505
  voltage_data = data * (3.3 / 1024) # Voltage to "mV"
506
+ frequency = voltage_data / (RATE * 1000) # Calculate to frequency
507
 
508
  self.line1.set_ydata(data)
509
+ self.line2.set_ydata(frequency)
510
 
511
  for coll in self.ax1.collections:
512
  coll.remove()
 
518
  self.ax1.fill_between(self.x, data, where=((self.x >= 30) & (self.x <= 100)), color='purple', alpha=1)
519
 
520
  self.ax1.legend(handles=self.legend_elements, loc='upper right')
521
+ self.ax1.set_ylabel('Amplitude (uV)')
522
  self.ax1.set_xlabel('Frequency (Hz)')
523
  self.ax1.set_title('Frequency and mV')
524
 
 
613
 
614
  ## How to Get Started with the Model
615
 
616
+ - To install the necessary modules in the model;
617
  - ```bash
618
  pip install -r requirements.txt
619
  ```
 
622
 
623
  ## Evaluation
624
 
625
+ - bai-2.0 (Accuracy very high = %97,93621013133208)(EMOTIONAL CLASSIFICATION) (AUTONOMOUS MODEL) (High probability of OVERFITTING)
626
+ - bai-2.1 (Accuracy very high = %97,93621013133208)(EMOTIONAL CLASSIFICATION) (AUTONOMOUS MODEL) (Low probability of OVERFITTING)
627
+ - bai-2.2 (Accuracy very high = %94,8874296435272)(EMOTIONAL CLASSIFICATION) (AUTONOMOUS MODEL) (Low probability of OVERFITTING)
628
 
629
  ### Results
630
 
 
650
 
651
  GitHub: https://github.com/neurazum/Realtime-EEG-Monitoring
652
 
653
+ ## More
654
 
655
  LinkedIn: https://www.linkedin.com/company/neurazum
656
 
657
+ ### Author
658
 
659
  Eyüp İpler - https://www.linkedin.com/in/eyupipler/
660
 
661
+ ### Contact
662
 
663
+ neurazum@gmail.com