kccistc / intel-04

6 stars 0 forks source link

[Class01 HW#5] Perceptron & ANN 실습 #4

Open J-WBaek opened 3 months ago

J-WBaek commented 3 months ago

1. 실습 폴더 구성

./class01
└── homework
   └── HongGilDong
       └── hw4_xxxxxx
       └── hw5_Perceptron_ANN
              └── xxxxx.ipynb

2. 새로운 Issue 생성

* Title / Comment
* Assignees - assign yourself
* Milestone - [[Class01 HW#5] Perceptrion & ANN 실습](https://github.com/kccistc/intel-04/milestone/4)
* issue  제목: Class[xx]_hw[y]_<본인이니셜>

3. 작업한 내용으로 Commit 생성 후, 하기 branch 이름 규칙으로 class repo에 PR생성

* class[xx]-hw[y]-[github id]
* branch name은 모두 소문자
  예제) GitHub ID `abcdef` 제출하는 Class01 HW2 일 경우 - `class01-hw2-abcdef`
* PR 제목: Class[xx]_hw[y]_<본인이니셜>

4. Push 후 생성한 Issue에 Development에 생성한 PR 등록

reviewer를 J-WBaek로 설정 예제) image

5. Reviewer의 feedback에 의거 재작업 혹은 conflict 발생시 재작업 후 re-push

6. Reviewer의 승인 후에 하기와 같이 Merge

image

참고) https://github.com/pskcci/intel-01/issues/3#issue-2122172755

troubleshooting.

J-WBaek commented 3 months ago

medical image prediction 코드 입니다.


import numpy as np # forlinear algebra
import matplotlib.pyplot as plt #for plotting things
import os
from PIL import Image # for reading images
from tensorflow import keras
from tensorflow.keras.preprocessing.image import ImageDataGenerator, load_img

#from sklearn.metrics import classification_report, confusion_matrix # <- define evaluation metrics
test_datagen = ImageDataGenerator(rescale = 1./255)  #Image normalization.
test_set = test_datagen.flow_from_directory('./chest_xray/test',
                                            target_size = (64, 64),
                                            batch_size = 32,
                                            class_mode = 'binary')
model_fin = keras.models.load_model('./medical_ann.h5')
test_accu = model_fin.evaluate(test_set, steps=624)
print('The testing accuracy is :',test_accu[1]*100, '%')

# label 얻기 
labels = test_set.labels

Y_pred = model_fin.predict(test_set)
#y_pred = np.argmax(Y_pred)
y_pred = []
for yy in Y_pred:
    if yy >= 0.5:
        y_pred.append(1)
    else:
        y_pred.append(0)
class_name = ["NORMAL", "PNEUMONIA"]
print("actual || predict")
for i in range(624):
    if i%10 == 0:
        print(class_name[labels[i]], end=" || ")
        print(class_name[y_pred[i]], end='\n')