Spaces:
Runtime error
Runtime error
Commit
·
c352470
1
Parent(s):
9fe30ba
First Demo
Browse files- .gitattributes +0 -34
- app.py +59 -0
- cevapanahtari.txt +20 -0
- data +1 -0
- data_func.py +43 -0
- denemeler/100luk_numarali.jpg +0 -0
- denemeler/bossikli.jpg +0 -0
- functions.py +193 -0
- optic1.py +103 -0
- requirements.txt +9 -0
- screen_add_note.py +34 -0
- screen_note.py +19 -0
- screen_scan.py +31 -0
- style.css +4 -0
.gitattributes
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from screen_add_note import screen_add_main
|
3 |
+
from screen_scan import screen_scan_main
|
4 |
+
from screen_note import screen_note_main
|
5 |
+
from streamlit_option_menu import option_menu
|
6 |
+
|
7 |
+
def local_css(file_name):
|
8 |
+
with open(file_name) as f:
|
9 |
+
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
10 |
+
|
11 |
+
local_css("style.css")
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
def streamlit_menu(example=3):
|
16 |
+
|
17 |
+
if example == 3:
|
18 |
+
# 2. horizontal menu with custom style
|
19 |
+
selected = option_menu(
|
20 |
+
menu_title=None, # required
|
21 |
+
options=["Optik Okuma", "Yeni Not Girisi", "Not Goruntuleme"], # required
|
22 |
+
icons=["house", "book", "envelope"],
|
23 |
+
default_index=0, # optional
|
24 |
+
orientation="horizontal",
|
25 |
+
styles={
|
26 |
+
"container": {"padding": "0!important", "background-color": "#b2d8d8"},
|
27 |
+
"icon": {"color": "orange", "font-size": "0px"},
|
28 |
+
"nav-link": {
|
29 |
+
"font-size": "15px",
|
30 |
+
"text-align": "left",
|
31 |
+
"margin": "0px",
|
32 |
+
"--hover-color": "#eee",
|
33 |
+
},
|
34 |
+
"nav-link-selected": {"background-color": "#008080"},
|
35 |
+
},
|
36 |
+
)
|
37 |
+
return selected
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
def main():
|
43 |
+
|
44 |
+
|
45 |
+
selected = streamlit_menu(example=3)
|
46 |
+
|
47 |
+
if selected == "Optik Okuma":
|
48 |
+
screen_scan_main()
|
49 |
+
if selected == "Yeni Not Girisi":
|
50 |
+
screen_add_main()
|
51 |
+
if selected == "Not Goruntuleme":
|
52 |
+
screen_note_main()
|
53 |
+
|
54 |
+
|
55 |
+
if __name__ == "__main__":
|
56 |
+
main()
|
57 |
+
|
58 |
+
|
59 |
+
|
cevapanahtari.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1 a
|
2 |
+
2 c
|
3 |
+
3 a
|
4 |
+
4 b
|
5 |
+
5 d
|
6 |
+
6 e
|
7 |
+
7 d
|
8 |
+
8 d
|
9 |
+
9 e
|
10 |
+
10 d
|
11 |
+
11 d
|
12 |
+
12 b
|
13 |
+
13 b
|
14 |
+
14 c
|
15 |
+
15 a
|
16 |
+
16 a
|
17 |
+
17 d
|
18 |
+
18 e
|
19 |
+
19 a
|
20 |
+
20 b
|
data
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Subproject commit ac8c215821138cfcb2bad83a69cb3c1fece7b936
|
data_func.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from huggingface_hub import Repository
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
DATASET_REPO_URL = "https://huggingface.co/datasets/mertbozkurt/school_data"
|
6 |
+
DATA_FILENAME = "untitled.csv"
|
7 |
+
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
8 |
+
HF_TOKEN = "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"
|
9 |
+
|
10 |
+
def pull_read():
|
11 |
+
|
12 |
+
repo = Repository(
|
13 |
+
local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
14 |
+
)
|
15 |
+
|
16 |
+
with open(DATA_FILE) as csvfile:
|
17 |
+
df = pd.read_csv(csvfile)
|
18 |
+
df = pd.DataFrame(df)
|
19 |
+
|
20 |
+
return repo, df
|
21 |
+
|
22 |
+
def make_new_data(sinif_kodu,ogrenci_no,ders_kodu,notu,yanlislar):
|
23 |
+
yeni_satir = {"sinif_kodu": sinif_kodu,
|
24 |
+
"ogrenci_no": ogrenci_no,
|
25 |
+
"ders_kodu": ders_kodu,
|
26 |
+
"notu": notu,
|
27 |
+
"yanlis_sorulari": yanlislar}
|
28 |
+
new_data = pd.DataFrame([yeni_satir])
|
29 |
+
return new_data
|
30 |
+
|
31 |
+
def update(new_data, repo_df):
|
32 |
+
updated_df = pd.concat([repo_df, new_data])
|
33 |
+
return updated_df
|
34 |
+
|
35 |
+
def save_and_push(dataFrame,repo):
|
36 |
+
dataFrame.to_csv("data/untitled.csv",index=False)
|
37 |
+
commit_url = repo.push_to_hub()
|
38 |
+
return commit_url
|
39 |
+
|
40 |
+
"""repo, repo_df = pull_read()
|
41 |
+
new_data = make_new_data(12,151718,56,80,"2,3,5")
|
42 |
+
updated_df = update(new_data,repo_df)
|
43 |
+
save_and_push(updated_df,repo)"""
|
denemeler/100luk_numarali.jpg
ADDED
![]() |
denemeler/bossikli.jpg
ADDED
![]() |
functions.py
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cv2
|
2 |
+
import numpy as np
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
+
def rectContour(contours):
|
6 |
+
rectCon = []
|
7 |
+
max_area = 0
|
8 |
+
for i in contours:
|
9 |
+
area = cv2.contourArea(i) #alan hesabi
|
10 |
+
#piksel alani 50den byukse gecerlidir
|
11 |
+
if area > 30:
|
12 |
+
peri = cv2.arcLength(i, True)
|
13 |
+
approx = cv2.approxPolyDP(i, 0.02 * peri, True) #kac tane koseye sahip oldugu
|
14 |
+
if len(approx) == 4: #4 ise dortgendir
|
15 |
+
rectCon.append(i)
|
16 |
+
rectCon = sorted(rectCon, key=cv2.contourArea,reverse=True) #alanlari hesaplicak ve siralicak ki ona gore alanlari belirleyelim
|
17 |
+
#print(len(rectCon))
|
18 |
+
return rectCon
|
19 |
+
|
20 |
+
def getCornerPoints(cont):
|
21 |
+
peri = cv2.arcLength(cont, True)
|
22 |
+
approx = cv2.approxPolyDP(cont, 0.02 * peri, True) #kose degerleri
|
23 |
+
return approx
|
24 |
+
|
25 |
+
|
26 |
+
def reorder(myPoints):
|
27 |
+
|
28 |
+
myPoints = myPoints.reshape((4, 2)) #fazla koseliyi kaldiralim
|
29 |
+
#print(myPoints)
|
30 |
+
myPointsNew = np.zeros((4, 1, 2), np.int32)
|
31 |
+
add = myPoints.sum(1)
|
32 |
+
#print(add)
|
33 |
+
#print(np.argmax(add))
|
34 |
+
myPointsNew[0] = myPoints[np.argmin(add)] #[0,0]
|
35 |
+
myPointsNew[3] =myPoints[np.argmax(add)] #[w,h]
|
36 |
+
diff = np.diff(myPoints, axis=1)
|
37 |
+
myPointsNew[1] =myPoints[np.argmin(diff)] #[w,0]
|
38 |
+
myPointsNew[2] = myPoints[np.argmax(diff)] #[h,0]
|
39 |
+
|
40 |
+
return myPointsNew
|
41 |
+
|
42 |
+
#siklari bolmek icin 20 tane soru vertical/ 5 tane isaret alani +1 tane soru sayisi yazan yer
|
43 |
+
#6 horizatanl bolmek
|
44 |
+
def splitBoxes(img):
|
45 |
+
rows = np.vsplit(img,20) #vertical
|
46 |
+
boxes=[]
|
47 |
+
for r in rows:
|
48 |
+
cols= np.hsplit(r,6) #horizantal
|
49 |
+
for box in cols:
|
50 |
+
boxes.append(box)
|
51 |
+
return boxes
|
52 |
+
|
53 |
+
#ogrenci numarasi alani icin ayni fonksiyonu kullandik
|
54 |
+
#yuakrdakisini silip sadece bu da kullanilabilir dogru degerler ile
|
55 |
+
#ogrenci numarasi alani 0-9 arasi sayilardan 10 tane isaretleme yeri iceriyor
|
56 |
+
#10x10seklinde boleriz
|
57 |
+
def split_num(img,vertical, horizantal):
|
58 |
+
rows = np.vsplit(img,vertical) #vertical
|
59 |
+
boxes=[]
|
60 |
+
for r in rows:
|
61 |
+
cols= np.hsplit(r,horizantal) #horizantal
|
62 |
+
for box in cols:
|
63 |
+
boxes.append(box)
|
64 |
+
return boxes
|
65 |
+
|
66 |
+
#yan yana 3 tane birlesik ders alani oldugu icin onlari 3 ayri
|
67 |
+
#sekle getiriyor
|
68 |
+
def splitColumn(img):
|
69 |
+
column = np.hsplit(img,3)
|
70 |
+
|
71 |
+
return column
|
72 |
+
|
73 |
+
|
74 |
+
#puan hesaplama alani
|
75 |
+
#soru sayisi dogru cevaplari ve ogrenci cevaplarini aliyor
|
76 |
+
#bunlari karsilastirip yeni bir listeye 1/0 seklinde kodluyor
|
77 |
+
#1ler toplanip puan hesaplanmis oluyor
|
78 |
+
def grading(answers,num_questions,myAnswers):
|
79 |
+
grading=[]
|
80 |
+
wrong_ans = []
|
81 |
+
for x in range(0,num_questions):
|
82 |
+
if answers[x] == myAnswers[x]:
|
83 |
+
grading.append(1)
|
84 |
+
else:
|
85 |
+
grading.append(0)
|
86 |
+
wrong_ans.append(x+1)
|
87 |
+
score = (sum(grading)/num_questions)*100
|
88 |
+
return score ,wrong_ans
|
89 |
+
|
90 |
+
#piksel degerlerinde kullanici cevaplarini
|
91 |
+
#okuyupu index seklinde listeye kaydediyor
|
92 |
+
def user_answers(num_questions,myPixelVal):
|
93 |
+
myIndex=[]
|
94 |
+
for x in range (0,num_questions):
|
95 |
+
arr = myPixelVal[x]
|
96 |
+
myIndexVal = np.where(arr == np.amax(arr))
|
97 |
+
myIndex.append(myIndexVal[0][0])
|
98 |
+
return myIndex
|
99 |
+
|
100 |
+
#student id kismi yukardan asagiya dogru karsilastirma yaparak
|
101 |
+
#isretli alan tespit edilecegi icin satir ve sutunlari tekrar duzenlemiz gerekti
|
102 |
+
#[[1,2,3],[4,5,6],[7,8,9]] ----> [[1,4,7],[2,5,8],[3,6,9]]
|
103 |
+
def id_reorder(myPixelVal):
|
104 |
+
duz_liste = []
|
105 |
+
for sutun in range(len(myPixelVal[0])):
|
106 |
+
for satir in range(len(myPixelVal)):
|
107 |
+
duz_liste.append(myPixelVal[satir][sutun])
|
108 |
+
yeni_liste = []
|
109 |
+
satir = []
|
110 |
+
for eleman in duz_liste:
|
111 |
+
satir.append(eleman)
|
112 |
+
if len(satir) == len(myPixelVal):
|
113 |
+
yeni_liste.append(satir)
|
114 |
+
satir = []
|
115 |
+
return yeni_liste
|
116 |
+
|
117 |
+
#ogrenci numarasi kisminin piksel degerine gore hangisinin iseretli
|
118 |
+
#oldugunun tespiti
|
119 |
+
def id_answers(vertical_num,myPixelVal):
|
120 |
+
myIndex=[]
|
121 |
+
for x in range (0,vertical_num):
|
122 |
+
arr = myPixelVal[x]
|
123 |
+
myIndexVal = np.where(arr == np.amax(arr))
|
124 |
+
myIndex.append(myIndexVal[0][0])
|
125 |
+
return myIndex
|
126 |
+
|
127 |
+
def pixelVal(num_questions,choices,box):
|
128 |
+
countR=0 #rows
|
129 |
+
countC=0 #column
|
130 |
+
myPixelVal = np.zeros((num_questions,choices))
|
131 |
+
for image in box:
|
132 |
+
totalPixels = cv2.countNonZero(image)
|
133 |
+
myPixelVal[countR][countC]= totalPixels
|
134 |
+
countC += 1
|
135 |
+
if (countC==choices):countC=0;countR +=1
|
136 |
+
return myPixelVal
|
137 |
+
|
138 |
+
#dosyadan cevap anahtarinin okunmasi
|
139 |
+
def read_answers(dosya_adi):
|
140 |
+
with open(dosya_adi, 'r') as f:
|
141 |
+
satirlar = f.readlines()
|
142 |
+
|
143 |
+
okunan_veriler = []
|
144 |
+
for satir in satirlar:
|
145 |
+
sutunlar = satir.split()
|
146 |
+
okunan_veriler.append(sutunlar[1])
|
147 |
+
|
148 |
+
return okunan_veriler
|
149 |
+
|
150 |
+
|
151 |
+
#dosyadan okunan cevaplarin numerik hale getirilmesi
|
152 |
+
def answers2numbers(answers):
|
153 |
+
num_answers = []
|
154 |
+
for i in answers:
|
155 |
+
if i == "a":
|
156 |
+
num_answers.append(1)
|
157 |
+
elif i == "b":
|
158 |
+
num_answers.append(2)
|
159 |
+
elif i == "c":
|
160 |
+
num_answers.append(3)
|
161 |
+
elif i == "d":
|
162 |
+
num_answers.append(4)
|
163 |
+
elif i == "e":
|
164 |
+
num_answers.append(5)
|
165 |
+
else:
|
166 |
+
print("Oppss Check Txt file")
|
167 |
+
return num_answers
|
168 |
+
|
169 |
+
|
170 |
+
def image_show(images):
|
171 |
+
col1, col2, col3 = st.columns(3)
|
172 |
+
with col1:
|
173 |
+
st.header("0")
|
174 |
+
st.image(images[0],width=200)
|
175 |
+
with col2:
|
176 |
+
st.header("1")
|
177 |
+
st.image(images[1],width=200)
|
178 |
+
with col3:
|
179 |
+
st.header("2")
|
180 |
+
st.image(images[2],width=200)
|
181 |
+
|
182 |
+
col4, col5, col6 = st.columns(3)
|
183 |
+
|
184 |
+
with col4:
|
185 |
+
st.header("3")
|
186 |
+
st.image(images[4],width=200)
|
187 |
+
with col5:
|
188 |
+
st.header("4")
|
189 |
+
st.image(images[5],width=200)
|
190 |
+
with col6:
|
191 |
+
st.header("5")
|
192 |
+
st.image(images[6],width=200)
|
193 |
+
|
optic1.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cv2
|
2 |
+
import numpy as np
|
3 |
+
import functions
|
4 |
+
|
5 |
+
#fotograf ozellikleri
|
6 |
+
heightImg = 300*4
|
7 |
+
widthImg = 210*4
|
8 |
+
#pathImage = "denemeler/100luk_numarali.jpg"
|
9 |
+
questions=20
|
10 |
+
choices=6
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
def optic1(ans_txt,pathImage, save_images= True):
|
15 |
+
#cevap anahtarini dosyadan okuma ve sayiya cevirme
|
16 |
+
ans_abc = functions.read_answers(ans_txt)
|
17 |
+
ans = functions.answers2numbers(ans_abc)
|
18 |
+
|
19 |
+
#perspektif islemleri icin cozunurluk
|
20 |
+
wrap_h = 18*20
|
21 |
+
wrap_v = 18*20
|
22 |
+
img = pathImage #eger girdi dogrudan np arrayse
|
23 |
+
#fotonun okunmasi ------------------------------------------------------------------------------------------------
|
24 |
+
#img = cv2.imread(pathImage)
|
25 |
+
img = cv2.resize(img, (widthImg, heightImg)) # RESIZE IMAGE
|
26 |
+
imgBiggestContour = img.copy()
|
27 |
+
imgFinal = img.copy()
|
28 |
+
imgContours = img.copy()
|
29 |
+
imgBlank = np.zeros((heightImg,widthImg, 3), np.uint8)
|
30 |
+
|
31 |
+
#donusumler---------------------------------------------------------------------------------
|
32 |
+
imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # CONVERT IMAGE TO GRAY SCALE
|
33 |
+
imgBlur = cv2.GaussianBlur(imgGray, (5, 5), 1) # ADD GAUSSIAN BLUR
|
34 |
+
imgCanny = cv2.Canny(imgBlur,10,70) # APPLY CANNY
|
35 |
+
|
36 |
+
#CONTOURS-------------------------------------------------------
|
37 |
+
contours, hierarchy = cv2.findContours(imgCanny, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
|
38 |
+
cv2.drawContours(imgContours, contours, -1, (0, 255, 0), 10) # DRAW ALL DETECTED CONTOURS
|
39 |
+
|
40 |
+
#dortgen bulma--------------------------------------------------
|
41 |
+
rectCon = functions.rectContour(contours)
|
42 |
+
biggestContour = functions.getCornerPoints(rectCon[0])
|
43 |
+
secondContour = functions.getCornerPoints(rectCon[1])
|
44 |
+
thirdContour = functions.getCornerPoints(rectCon[2])
|
45 |
+
fourthContour = functions.getCornerPoints(rectCon[3])
|
46 |
+
|
47 |
+
#main
|
48 |
+
if biggestContour.size != 0 and secondContour.size != 0:
|
49 |
+
|
50 |
+
cv2.drawContours(imgBiggestContour, biggestContour,-1,(0,255,0),20)
|
51 |
+
cv2.drawContours(imgBiggestContour, secondContour,-1,(255,0,0),20) #sondk' kalinlik ortada renk
|
52 |
+
cv2.drawContours(imgBiggestContour, thirdContour,-1,(0,0,255),20) #sondk' kalinlik ortada renk
|
53 |
+
cv2.drawContours(imgBiggestContour, fourthContour,-1,(0,0,20),20) #sondk' kalinlik ortada renk
|
54 |
+
|
55 |
+
biggestContour=functions.reorder(biggestContour)
|
56 |
+
#cevap siklari icin -************************************************************
|
57 |
+
pts1 = np.float32(biggestContour)
|
58 |
+
pts2 = np.float32([[0, 0],[wrap_v, 0], [0, wrap_h],[wrap_v, wrap_h]])
|
59 |
+
matrix = cv2.getPerspectiveTransform(pts1, pts2)
|
60 |
+
|
61 |
+
imgWarpColored_1 = cv2.warpPerspective(img, matrix, (wrap_v, wrap_h))
|
62 |
+
imgWarpGray_1 = cv2.cvtColor(imgWarpColored_1,cv2.COLOR_BGR2GRAY)
|
63 |
+
imgThresh_1 = cv2.threshold(imgWarpGray_1, 170, 255,cv2.THRESH_BINARY_INV )[1]
|
64 |
+
|
65 |
+
#second buyuk icin perspektif
|
66 |
+
secondContour=functions.reorder(secondContour)
|
67 |
+
pts1_2 = np.float32(secondContour)
|
68 |
+
pts2_2 = np.float32([[0, 0],[wrap_v, 0], [0, wrap_h],[wrap_v, wrap_h]])
|
69 |
+
matrix_2 = cv2.getPerspectiveTransform(pts1_2, pts2_2)
|
70 |
+
imgWarpColored_2 = cv2.warpPerspective(img, matrix_2, (wrap_v, wrap_h))
|
71 |
+
imgWarpGray_2 = cv2.cvtColor(imgWarpColored_2,cv2.COLOR_BGR2GRAY)
|
72 |
+
imgThresh_2 = cv2.threshold(imgWarpGray_2, 170, 255,cv2.THRESH_BINARY_INV )[1]
|
73 |
+
|
74 |
+
|
75 |
+
#student id
|
76 |
+
bubbles = functions.split_num(imgThresh_2, 10, 10)
|
77 |
+
myPixelVal_2 = functions.pixelVal(10,10,bubbles)
|
78 |
+
myPixelVal_2 = functions.id_reorder(myPixelVal_2)
|
79 |
+
student_id = functions.id_answers(10,myPixelVal_2)
|
80 |
+
#print(student_id)
|
81 |
+
|
82 |
+
#soru kisimi
|
83 |
+
column_3 = functions.splitColumn(imgThresh_1)
|
84 |
+
boxes_1 = functions.splitBoxes(column_3[0])
|
85 |
+
boxes_2 = functions.splitBoxes(column_3[1])
|
86 |
+
boxes_3 = functions.splitBoxes(column_3[2])
|
87 |
+
myPixelVal = functions.pixelVal(questions,choices,boxes_1)
|
88 |
+
myIndex = functions.user_answers(questions,myPixelVal)
|
89 |
+
grading, wrong_ans = functions.grading(ans,questions,myIndex)
|
90 |
+
student_idFix = ""
|
91 |
+
for number in student_id:
|
92 |
+
|
93 |
+
student_idFix += str(number)
|
94 |
+
if save_images:
|
95 |
+
for i in range(0,len(resim_listesi)):
|
96 |
+
cv2.imwrite(f"images/{student_idFix}___{i}.jpg",resim_listesi[i])
|
97 |
+
|
98 |
+
resim_listesi = [img,imgGray,imgBlur,imgCanny,imgContours,imgBiggestContour,imgThresh_1,imgThresh_2]
|
99 |
+
|
100 |
+
return grading, wrong_ans, student_idFix, resim_listesi
|
101 |
+
|
102 |
+
#sonuc = optic1(ans_txt="cevapanahtari.txt",pathImage= "denemeler/100luk_numarali.jpg")
|
103 |
+
#print(sonuc)
|
requirements.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit == 1.11.0
|
2 |
+
pandas == 1.4.3
|
3 |
+
numpy == 1.23.1
|
4 |
+
Pillow== 9.2.0
|
5 |
+
huggingface_hub
|
6 |
+
opencv-python-headless==4.4.0.42
|
7 |
+
pickleshare == 0.7.5
|
8 |
+
requests == 2.24.0
|
9 |
+
scikit-image == 0.19.3
|
screen_add_note.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import data_func
|
4 |
+
from data_func import DATASET_REPO_URL,DATA_FILENAME,DATA_FILE,HF_TOKEN
|
5 |
+
|
6 |
+
repo, repo_df = data_func.pull_read()
|
7 |
+
|
8 |
+
|
9 |
+
def screen_add_main():
|
10 |
+
st.title("Not Giris")
|
11 |
+
|
12 |
+
# Kullanıcıdan verileri alma
|
13 |
+
sinif_kodu = st.text_input("Sınıf Kodu")
|
14 |
+
ogrenci_no = st.text_input("Öğrenci No")
|
15 |
+
ders_kodu = st.text_input("Ders Kodu")
|
16 |
+
notu = st.slider("Notu", 0, 100)
|
17 |
+
yanlislar = st.text_input("Yanlış Sorulari (virgul ile ayirin)")
|
18 |
+
yanlislar = str(yanlislar)
|
19 |
+
|
20 |
+
if st.button("Veriyi Yukle"):
|
21 |
+
new_data = data_func.make_new_data(sinif_kodu=sinif_kodu,
|
22 |
+
ogrenci_no= ogrenci_no,
|
23 |
+
ders_kodu= ders_kodu,
|
24 |
+
notu=notu,
|
25 |
+
yanlislar= yanlislar)
|
26 |
+
updated_df = data_func.update(new_data,repo_df)
|
27 |
+
data_func.save_and_push(updated_df,repo)
|
28 |
+
st.subheader("Girilen Veriler")
|
29 |
+
st.write(new_data)
|
30 |
+
|
31 |
+
|
32 |
+
if __name__ == "__main__":
|
33 |
+
screen_add_main()
|
34 |
+
|
screen_note.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import data_func
|
4 |
+
from data_func import DATASET_REPO_URL,DATA_FILENAME,DATA_FILE,HF_TOKEN
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
repo, repo_df = data_func.pull_read()
|
10 |
+
|
11 |
+
def screen_note_main():
|
12 |
+
|
13 |
+
|
14 |
+
st.subheader("Girilen Veriler")
|
15 |
+
st.write(repo_df)
|
16 |
+
|
17 |
+
|
18 |
+
if __name__ == "__main__":
|
19 |
+
screen_note_main()
|
screen_scan.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
import cv2
|
4 |
+
from PIL import Image
|
5 |
+
import optic1
|
6 |
+
from functions import image_show
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
def screen_scan_main():
|
12 |
+
st.title("Optik Okuma")
|
13 |
+
|
14 |
+
image_file = st.file_uploader(
|
15 |
+
"Upload image for testing", type=['jpeg', 'png', 'jpg', 'webp'])
|
16 |
+
if image_file != None:
|
17 |
+
image = Image.open(image_file)
|
18 |
+
image = np.array(image.convert('RGB'))
|
19 |
+
if st.button("Process"):
|
20 |
+
#(ans_txt,pathImage, save_images= True)
|
21 |
+
grading, wrong_ans, student_idFix, resim_list =optic1.optic1(ans_txt="cevapanahtari.txt",pathImage=image,save_images=False)
|
22 |
+
|
23 |
+
image_show(resim_list)
|
24 |
+
|
25 |
+
st.subheader("Notu:",grading)
|
26 |
+
st.subheader("Yanlis Yaptigi sorular:",wrong_ans)
|
27 |
+
st.subheader("Ogrenci Numarasi:",student_idFix)
|
28 |
+
|
29 |
+
#python -m streamlit run app.py
|
30 |
+
if __name__ == '__main__':
|
31 |
+
screen_scan_main()
|
style.css
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
section[data-testid="stSidebar"] div.stButton button {
|
2 |
+
background-color: rgb(95, 197, 228);
|
3 |
+
width: 200px;
|
4 |
+
}
|