# data[].attributes.headline
1. (수요일1-4교시) 모둠별 탐구활동 산출물 업로드

# data[].attributes.subject
1. (수요일1-4교시) 모둠별 탐구활동 산출물 업로드

# data[].attributes.body
계정 로그인하여 실명으로 산출물 업로드 해주세요

# data[].attributes.headline
2. (수요일5-7교시) 모둠별 발표를 들으며 별점과 댓글 남기기

# data[].attributes.subject
2. (수요일5-7교시) 모둠별 발표를 들으며 별점과 댓글 남기기

# data[].attributes.body
반드시 로그인하여 실명으로 댓글과 별점을 남겨주세요

# data[].attributes.attachment_link.description
Artificial organ Team : Artificial Bio Technology CASE 1 Strengths CASE 1 : CASE 2 CASE 2 : quiz

# data[].attributes.attachment_caption
각 분야와 관련된 환경운동(G반 7조 PPT)

# data[].attributes.body
https://www.canva.com/design/DAFoSrbqZOA/n3_EVeKzX0GjZSs0B5wdqA/view?utm_content=DAFoSrbqZOA&utm_campaign=designshare&utm_medium=link&utm_source=publishsharelink

# data[].attributes.attachment_link.title
White Purple Green Aesthetic Minimalist Gradient Company Profile Creative Presentation

# data[].attributes.attachment_link.description
Check out this Presentation designed by 20714안예슬.

# data[].attributes.attachment_link.description
디자인 전문가가 아니어도 무료 템플릿으로 손쉽게 원하는 디자인을 할 수 있어요.

# data[].attributes.attachment_link.title
제목을-입력해주세요_ (5)

# data[].attributes.headline
6조(우주 개척 기술)

# data[].attributes.subject
6조(우주 개척 기술)

# data[].attributes.attachment_link.title
자율교육과정-교과융합탐구-프로젝트

# data[].attributes.attachment_caption
H반 2조 (GAC / Green Advanced materials City)

# data[].attributes.headline
2조 (GAC / Green Advanced materials City)

# data[].attributes.subject
2조 (GAC / Green Advanced materials City)

# data[].attributes.body
https://www.canva.com/design/DAFoSUvTPGc/lIm8yx2FbcZOB31QvgyOKg/edit?utm_content=DAFoSUvTPGc&utm_campaign=designshare&utm_medium=link2&utm_source=sharebutton

# data[].attributes.attachment_link.title
22세기-교육과정-개편-최종

# data[].attributes.body
https://www.miricanvas.com/v/1287nwk

# data[].attributes.attachment_link.description
디자인 전문가가 아니어도 무료 템플릿으로 손쉽게 원하는 디자인을 할 수 있어요.

# data[].attributes.attachment_link.description
Check out this Presentation designed by 다원.

# data[].attributes.attachment_link.title
Project Proposal Business Presentation in Dark Blue Pink Abstract Tech Style (1)

# data[].attributes.attachment_link.title
제목을-입력해주세요_ (1)

# data[].attributes.body
https://www.canva.com/design/DAFoTjeOYg0/MSnzjTzqzMAMQcL0y115nA/view?utm_content=DAFoTjeOYg0&utm_campaign=designshare&utm_medium=link&utm_source=publishsharelink

# data[].attributes.headline
3조 ( 개발도상국 조)

# data[].attributes.subject
3조 ( 개발도상국 조)

# data[].attributes.attachment_link.title
사회 복지 이데올로기

# data[].attributes.attachment_link.title
제목을-입력해주세요_ (8)

# data[].attributes.headline
[금피구]-금강산도 피자먹고 구경

# data[].attributes.subject
[금피구]-금강산도 피자먹고 구경

# data[].attributes.body
남북 이념대립의 역사
https://youtu.be/Q51EtMpsx8o

# data[].attributes.attachment_link.title
남북 이념의 대립 [금피구]

# data[].attributes.headline
조의준과 아이들(1조) 프로그램 코드

# data[].attributes.subject
조의준과 아이들(1조) 프로그램 코드

# data[].attributes.attachment_link.readable_text
from tensorflow.keras.models import load_model, Sequential
from tensorflow.keras.layers import Dense, Activation
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.datasets import mnist
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from PIL import ImageGrab
from PIL import Image as im
from tkinter import *

global image_data
class DrawingApp:
    def __init__(self, root):
        self.root = root
        self.canvas_width = 280  # MNIST 해상도와 동일하게 조정
        self.canvas_height = 280  # MNIST 해상도와 동일하게 조정
        self.canvas = Canvas(root, width=self.canvas_width, height=self.canvas_height)
        self.canvas.pack()
        self.canvas.bind("<B1-Motion>", self.draw)
        self.save_button1 = Button(root, text="Evaluate", command=self.save_image)
        self.save_button1.pack()
        self.save_button2 = Button(root, text="Exit", command=quit)
        self.save_button2.pack()
        
    def draw(self, event):
        x, y = event.x, event.y
        self.canvas.create_oval(x-10, y-10, x+10, y+10, fill='black')  # 그림 그리는 크기를 더 크게 조정
        
    def save_image(self):
        global image_data
        x = self.root.winfo_rootx() + self.canvas.winfo_x()
        y = self.root.winfo_rooty() + self.canvas.winfo_y()
        x1 = x + self.canvas_width
        y1 = y + self.canvas_height
        image = ImageGrab.grab().crop((x, y, x1, y1)).resize((28, 28), im.ANTIALIAS)  # 이미지 크기를 MNIST 해상도로 조정
        image = image.convert('L')  # 그레이스케일로 변환
        image_data = np.array(image)
        image_data = 255 - image_data  # 흑백 반전
        image_data = image_data.astype('float32') / 255.0
        self.root.destroy ()
        # 이제 image_data를 사용하여 원하는 저장 방식에 맞게 처리하면 됩니다

(x_train, y_train), (x_test, y_test) = mnist.load_data() # mnist 데이타 받아오기(ai 학습의 기초 데이타)
print("x_train shape", x_train.shape)
print("y_train shape", y_train.shape)
print("x_test shape", x_test.shape)
print("y_test shape", y_test.shape)


print("----------------------------------------")
X_train = x_train.reshape(60000, 784)
X_test = x_test.reshape(10000, 784)
X_train = X_train.astype('float32')
X_test = X_test.astype('float32')
X_train /= 255
X_test /= 255
print("X Training matrix shape", X_train.shape)
print("X Testing matrix shape", X_test.shape)
print("----------------------------------------")
Y_train = to_categorical(y_train, 10)
Y_test = to_categorical(y_test, 10)
print("Y Training matrix shape", Y_train.shape)
print("Y Testing matrix shape", Y_test.shape)

model = Sequential()
model.add(Dense(512, input_shape=(784,)))
model.add(Activation('relu'))
model.add(Dense(256))
model.add(Activation('relu'))
model.add(Dense(10))
model.add(Activation('softmax'))
model.summary()

model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(X_train, Y_train, batch_size=128, epochs=10, verbose=1)

score = model.evaluate(X_test, Y_test)
print('Test score:', score[0])
print('Test accuracy:', score[1])

predicted_classes = np.argmax(model.predict(X_test), axis=1)
correct_indices = np.nonzero(predicted_classes == y_test)[0]
incorrect_indices = np.nonzero(predicted_classes != y_test)[0]

print(X_test[0])
plt.figure()
for i in range(9):
    plt.subplot(3,3,i+1)
    correct = correct_indices[i]
    plt.imshow(X_test[correct].reshape(28,28), cmap='gray')
    plt.title("Predicted {}, Class {}".format(predicted_classes[correct], y_test[correct]))
plt.tight_layout()
plt.show()
while(TRUE):
    root = Tk()
    app = DrawingApp(root)
    root.mainloop()
    prediction = model.predict(image_data.flatten().reshape(1,784))
    predicted_label = np.argmax(prediction)
    print(f"Predicted label: {predicted_label}")
    plt.figure()
    plt.imshow(image_data, cmap='gray')
    plt.title("Predicted {}".format(predicted_label))
    plt.tight_layout()
    plt.show()

# data[].attributes.headline
조의준과 아이들(1조) 발표자료

# data[].attributes.subject
조의준과 아이들(1조) 발표자료

# data[].attributes.attachment_link.title
신경망 기술을 접목한 비정형데이터 모델링 환경 구축

# data[].attributes.attachment_link.title
제목을-입력해주세요_ (3)

# data[].attributes.attachment_link.title
Ai 정신 수선공 실험 보고서

# data[].attributes.attachment_link.description
디자인 전문가가 아니어도 무료 템플릿으로 손쉽게 원하는 디자인을 할 수 있어요.

# data[].attributes.body
https://youtu.be/nh9yt1ZKMQo

# data[].attributes.headline
D조 인공지능과 컴퓨터

# data[].attributes.subject
D조 인공지능과 컴퓨터

# data[].attributes.body
https://docs.google.com/presentation/d/1bN9Y5H3myWNJCfjl3Q2iQhW80tqWWgt6/edit?usp=drivesdk&ouid=102489538642725927947&rtpof=true&sd=true

# data[].attributes.body
https://drive.google.com/file/d/1P_7C-TAKyqba4IDiERZreND-SFby5ubB/view?usp=drivesdk

# data[].attributes.attachment_link.title
프레젠테이션 4

# data[].attributes.body
뉴럴란젤로 - 미리캔버스 (miricanvas.com)

# data[].attributes.body
https://www.miricanvas.com/v/1287hjg

# data[].attributes.attachment_link.title
교과융합탐구_뉴럴란젤로