mertbozkurt commited on
Commit
473ad58
1 Parent(s): 8329b3b

cevap anahatari atama

Browse files
__pycache__/data_func.cpython-310.pyc CHANGED
Binary files a/__pycache__/data_func.cpython-310.pyc and b/__pycache__/data_func.cpython-310.pyc differ
 
__pycache__/functions.cpython-310.pyc CHANGED
Binary files a/__pycache__/functions.cpython-310.pyc and b/__pycache__/functions.cpython-310.pyc differ
 
__pycache__/optic1.cpython-310.pyc CHANGED
Binary files a/__pycache__/optic1.cpython-310.pyc and b/__pycache__/optic1.cpython-310.pyc differ
 
__pycache__/reader.cpython-310.pyc ADDED
Binary file (2.37 kB). View file
 
data CHANGED
@@ -1 +1 @@
1
- Subproject commit b733259fe70abefb6c892ca9617793f81ab0b2dd
 
1
+ Subproject commit 1f0e28cc7a1ff84a41de050ba6f3f831c63182ef
db/temp.csv DELETED
@@ -1,26 +0,0 @@
1
- sinif_kodu,ogrenci_no,ders_kodu,notu,yanlis_sorulari
2
- 10,19060365,13,65.0,"1,2,3,4"
3
- 10,19060365,56,80.0,"1,2,3"
4
- 10,19060322,5622,80.0,"1,2,3"
5
- 10,19060322,5622,70.0,"1,2,3"
6
- 10,15170018,56,30.0,"2,3,5"
7
- 10,15001718,56,50.0,"2,3,5"
8
- 10,15001718,56,60.0,"2,3,5"
9
- 11,15000000,15,40.0,"1,2,3"
10
- 11,15000001,15,30.0,"1,2,3"
11
- 11,12000002,22,36.0,"2,5,6"
12
- 15,19060365,15,100.0,[]
13
- 15,19060365,15,100.0,[]
14
- 10,19060365,10,100.0,[]
15
- 10,19060365,10,100.0,[]
16
- 10,19060365,10,100.0,[]
17
- 10,19060365,10,100.0,[]
18
- 10,19060365,10,100.0,[]
19
- 10,19060365,10,100.0,[]
20
- 10,19060365,10,100.0,[]
21
- 10,19060365,10,100.0,[]
22
- 10,19060365,10,100.0,[]
23
- 10,19060365,10,100.0,[]
24
- 10,19060365,10,100.0,[]
25
- 10,19060365,10,100.0,[]
26
- 10,19060365,10,100.0,[]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
db/untitled.csv DELETED
@@ -1,11 +0,0 @@
1
- sinif_kodu,ogrenci_no,ders_kodu,notu,yanlis_sorulari
2
- 11,19060365,13,65,"1,2,3,4"
3
- 15,190603654,56,80,"1, 2, 3"
4
- 135,190603222654,5622,81,"1, 2, 3"
5
- 135,190603222654,5622,81,"1, 2, 3"
6
- 12,151718,56,80,"2,3,5"
7
- [12],[151718],[56],[80],"['2,3,5']"
8
- [12],[151718],[56],[80],"['2,3,5']"
9
- 15,15,15,89,"1,2,3"
10
- 15,15,15,30,"1,2,3"
11
- 111,12,22,36,2
 
 
 
 
 
 
 
 
 
 
 
 
functions.py CHANGED
@@ -78,25 +78,48 @@ def splitColumn(img):
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
 
88
 
89
  score = (sum(grading)/num_questions)*100
90
- return score ,wrong_ans
91
 
92
  #piksel degerlerinde kullanici cevaplarini
93
  #okuyupu index seklinde listeye kaydediyor
94
  def user_answers(num_questions,myPixelVal):
95
  myIndex=[]
 
96
  for x in range (0,num_questions):
97
  arr = myPixelVal[x]
98
- myIndexVal = np.where(arr == np.amax(arr))
99
- myIndex.append(myIndexVal[0][0])
 
 
 
 
 
 
 
 
 
 
 
 
100
  return myIndex
101
 
102
  #student id kismi yukardan asagiya dogru karsilastirma yaparak
@@ -197,4 +220,5 @@ def image_show(images):
197
  with col7:
198
  st.header("6")
199
  st.image(images[7],width=150)
 
200
 
 
78
  def grading(answers,num_questions,myAnswers):
79
  grading=[]
80
  wrong_ans = []
81
+ empty = []
82
+
83
  for x in range(0,num_questions):
84
  if answers[x] == myAnswers[x]:
85
  grading.append(1)
86
+
87
+ elif answers[x] == -1:
88
+ grading.append(0)
89
+ wrong_ans.append(x+1)
90
+
91
+ elif answers[x] == 0:
92
+ empty.append(x+1)
93
+
94
  else:
95
  grading.append(0)
96
  wrong_ans.append(x+1)
97
 
98
 
99
  score = (sum(grading)/num_questions)*100
100
+ return score ,wrong_ans,empty
101
 
102
  #piksel degerlerinde kullanici cevaplarini
103
  #okuyupu index seklinde listeye kaydediyor
104
  def user_answers(num_questions,myPixelVal):
105
  myIndex=[]
106
+
107
  for x in range (0,num_questions):
108
  arr = myPixelVal[x]
109
+
110
+ #empty answers
111
+ if arr[1] < 150.0 and arr[2] < 150.0 and arr[3] < 150.0 and arr[4] < 150.0 and arr[5] < 150.0:
112
+
113
+ myIndex.append(0)
114
+
115
+ #2 or more answers
116
+ elif arr[1]+arr[2]>375 or arr[1]+arr[3]>375 or arr[1]+arr[4]>375 or arr[1]+arr[5]>375 or arr[2]+arr[3]>375 or arr[2]+arr[4]>375 or arr[2]+arr[5]>375 or arr[3]+arr[4]>375 or arr[3]+arr[5]>375 or arr[4]+arr[5]>375:
117
+ myIndex.append(-1)
118
+
119
+ else :
120
+ myIndexVal = np.where(arr == np.amax(arr))
121
+ myIndex.append(myIndexVal[0][0])
122
+ print(myIndex)
123
  return myIndex
124
 
125
  #student id kismi yukardan asagiya dogru karsilastirma yaparak
 
220
  with col7:
221
  st.header("6")
222
  st.image(images[7],width=150)
223
+
224
 
myindexs.txt ADDED
File without changes
optic1.py CHANGED
@@ -13,16 +13,10 @@ choices=6
13
 
14
  def optic1(ans_txt1,ans_txt2,ans_txt3,pathImage, save_images= True):
15
  #cevap anahtarini dosyadan okuma ve sayiya cevirme
16
- ans_abc_1 = functions.read_answers(ans_txt1)
17
- ans_1 = functions.answers2numbers(ans_abc_1)
18
-
19
- ans_abc_2 = functions.read_answers(ans_txt2)
20
- ans_2 = functions.answers2numbers(ans_abc_2)
21
 
22
- ans_abc_3 = functions.read_answers(ans_txt3)
23
- ans_3 = functions.answers2numbers(ans_abc_3)
24
-
25
-
26
 
27
  #perspektif islemleri icin cozunurluk
28
  wrap_h = 18*20
@@ -96,17 +90,17 @@ def optic1(ans_txt1,ans_txt2,ans_txt3,pathImage, save_images= True):
96
  #boxes_1
97
  myPixelVal_1 = functions.pixelVal(questions,choices,boxes_1)
98
  myIndex_1 = functions.user_answers(questions,myPixelVal_1)
99
- grading_1, wrong_ans_1 = functions.grading(ans_1,questions,myIndex_1)
100
 
101
  #boxes_2
102
  myPixelVal_2 = functions.pixelVal(questions,choices,boxes_2)
103
  myIndex_2 = functions.user_answers(questions,myPixelVal_2)
104
- grading_2, wrong_ans_2 = functions.grading(ans_2,questions,myIndex_2)
105
 
106
  #boxes_3
107
  myPixelVal_3 = functions.pixelVal(questions,choices,boxes_3)
108
  myIndex_3 = functions.user_answers(questions,myPixelVal_3)
109
- grading_3, wrong_ans_3 = functions.grading(ans_3,questions,myIndex_3)
110
 
111
 
112
  student_idFix = ""
@@ -120,7 +114,9 @@ def optic1(ans_txt1,ans_txt2,ans_txt3,pathImage, save_images= True):
120
  resim_listesi = [img,imgGray,imgBlur,imgCanny,imgContours,imgBiggestContour,imgThresh_1,imgThresh_2]
121
  grading = [grading_1,grading_2,grading_3]
122
  wrong_ans = [wrong_ans_1,wrong_ans_2,wrong_ans_3]
123
- return grading, wrong_ans, student_idFix, resim_listesi
 
 
124
 
125
  #sonuc = optic1(ans_txt="cevapanahtari.txt",pathImage= "denemeler/100luk_numarali.jpg")
126
  #print(sonuc)
 
13
 
14
  def optic1(ans_txt1,ans_txt2,ans_txt3,pathImage, save_images= True):
15
  #cevap anahtarini dosyadan okuma ve sayiya cevirme
 
 
 
 
 
16
 
17
+ ans_1 = ans_txt1
18
+ ans_2 = ans_txt2
19
+ ans_3 = ans_txt3
 
20
 
21
  #perspektif islemleri icin cozunurluk
22
  wrap_h = 18*20
 
90
  #boxes_1
91
  myPixelVal_1 = functions.pixelVal(questions,choices,boxes_1)
92
  myIndex_1 = functions.user_answers(questions,myPixelVal_1)
93
+ grading_1, wrong_ans_1, empty_1 = functions.grading(ans_1,questions,myIndex_1)
94
 
95
  #boxes_2
96
  myPixelVal_2 = functions.pixelVal(questions,choices,boxes_2)
97
  myIndex_2 = functions.user_answers(questions,myPixelVal_2)
98
+ grading_2, wrong_ans_2, empty_2 = functions.grading(ans_2,questions,myIndex_2)
99
 
100
  #boxes_3
101
  myPixelVal_3 = functions.pixelVal(questions,choices,boxes_3)
102
  myIndex_3 = functions.user_answers(questions,myPixelVal_3)
103
+ grading_3, wrong_ans_3 ,empty_3 = functions.grading(ans_3,questions,myIndex_3)
104
 
105
 
106
  student_idFix = ""
 
114
  resim_listesi = [img,imgGray,imgBlur,imgCanny,imgContours,imgBiggestContour,imgThresh_1,imgThresh_2]
115
  grading = [grading_1,grading_2,grading_3]
116
  wrong_ans = [wrong_ans_1,wrong_ans_2,wrong_ans_3]
117
+ empty = [empty_1,empty_2,empty_3]
118
+ myIndexs = [myIndex_1,myIndex_2,myIndex_3]
119
+ return grading, wrong_ans, student_idFix, resim_listesi,empty
120
 
121
  #sonuc = optic1(ans_txt="cevapanahtari.txt",pathImage= "denemeler/100luk_numarali.jpg")
122
  #print(sonuc)
optic2.py ADDED
File without changes
optic_pixel_value.txt ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [ 92. 201. 91. 93. 85. 70.]
2
+ [ 49. 181. 43. 55. 57. 42.]
3
+ [ 56. 57. 45. 185. 63. 48.]
4
+ [ 69. 50. 53. 61. 190. 46.]
5
+ [ 61. 57. 64. 198. 64. 40.]
6
+ [ 59. 59. 194. 59. 48. 32.]
7
+ [ 63. 60. 65. 60. 59. 176.]
8
+ [ 74. 197. 56. 57. 60. 55.]
9
+ [ 71. 59. 193. 62. 61. 63.]
10
+ [ 77. 55. 56. 195. 61. 56.]
11
+ [ 74. 61. 59. 61. 187. 56.]
12
+ [ 87. 54. 61. 61. 191. 58.]
13
+ [ 95. 69. 77. 204. 74. 76.]
14
+ [101. 72. 195. 78. 70. 69.]
15
+ [103. 73. 202. 71. 74. 75.]
16
+ [105. 75. 72. 77. 76. 200.]
17
+ [ 92. 78. 82. 202. 71. 65.]
18
+ [101. 77. 205. 71. 73. 71.]
19
+ [ 91. 210. 68. 74. 74. 59.]
20
+ [130. 244. 117. 111. 105. 91.]
21
+ [ 54. 74. 188. 84. 79. 62.]
22
+ [ 24. 47. 65. 173. 50. 38.]
23
+ [ 21. 49. 174. 66. 54. 35.]
24
+ [ 31. 185. 73. 54. 52. 48.]
25
+ [ 33. 198. 59. 58. 64. 43.]
26
+ [ 28. 63. 60. 61. 68. 165.]
27
+ [ 26. 57. 53. 64. 188. 44.]
28
+ [ 33. 190. 55. 55. 54. 37.]
29
+ [ 33. 61. 196. 62. 60. 51.]
30
+ [ 35. 59. 53. 195. 48. 45.]
31
+ [ 30. 56. 192. 57. 51. 35.]
32
+ [ 32. 51. 193. 57. 50. 67.]
33
+ [ 23. 53. 49. 56. 47. 212.]
34
+ [ 32. 54. 47. 52. 182. 67.]
35
+ [ 31. 61. 60. 194. 50. 76.]
36
+ [ 33. 60. 196. 58. 55. 62.]
37
+ [ 36. 59. 60. 191. 47. 51.]
38
+ [ 30. 185. 52. 55. 47. 58.]
39
+ [ 23. 59. 191. 62. 55. 58.]
40
+ [ 32. 51. 50. 63. 190. 60.]
41
+ [ 24. 48. 47. 192. 53. 60.]
42
+ [ 55. 78. 212. 78. 76. 97.]
reader.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 reader(pathImage, save_images= True):
15
+ #cevap anahtarini dosyadan okuma ve sayiya cevirme
16
+
17
+
18
+ #perspektif islemleri icin cozunurluk
19
+ wrap_h = 18*20
20
+ wrap_v = 18*20
21
+ img = pathImage #eger girdi dogrudan np arrayse
22
+ #fotonun okunmasi ------------------------------------------------------------------------------------------------
23
+ #img = cv2.imread(pathImage)
24
+ img = cv2.rotate(img, cv2.ROTATE_90_CLOCKWISE)
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,0,255,cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[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
+ imgThresh_2 = cv2.threshold(imgWarpGray_2,0,255,cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
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
+ #boxes_1
88
+ myPixelVal_1 = functions.pixelVal(questions,choices,boxes_1)
89
+ myIndex_1 = functions.user_answers(questions,myPixelVal_1)
90
+
91
+ #boxes_2
92
+ myPixelVal_2 = functions.pixelVal(questions,choices,boxes_2)
93
+ myIndex_2 = functions.user_answers(questions,myPixelVal_2)
94
+
95
+ #boxes_3
96
+ myPixelVal_3 = functions.pixelVal(questions,choices,boxes_3)
97
+ myIndex_3 = functions.user_answers(questions,myPixelVal_3)
98
+
99
+
100
+
101
+ student_idFix = ""
102
+ for number in student_id:
103
+ student_idFix += str(number)
104
+
105
+
106
+
107
+ myIndexs = [myIndex_1,myIndex_2,myIndex_3]
108
+ return student_idFix, myIndexs
109
+
110
+ #sonuc = optic1(ans_txt="cevapanahtari.txt",pathImage= "denemeler/100luk_numarali.jpg")
111
+ #print(sonuc)
screen/__pycache__/screen_scan.cpython-310.pyc CHANGED
Binary files a/screen/__pycache__/screen_scan.cpython-310.pyc and b/screen/__pycache__/screen_scan.cpython-310.pyc differ
 
screen/screen_add_note.py DELETED
@@ -1,34 +0,0 @@
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
- def screen_add_main():
10
- st.title("Not Giris")
11
- repo, repo_df = data_func.pull_read()
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/screen_scan.py CHANGED
@@ -9,7 +9,7 @@ import pandas as pd
9
  from data_func import make_new_data,update,save_and_push
10
  import os
11
  from huggingface_hub import Repository
12
-
13
 
14
  def pull_read(DATASET_REPO_URL,HF_TOKEN,DATA_FILE):
15
 
@@ -28,81 +28,98 @@ def convert_df_to_csv(df):
28
  # IMPORTANT: Cache the conversion to prevent computation on every rerun
29
  return df.to_csv().encode('utf-8')
30
 
 
31
  def screen_scan_main():
 
 
32
 
33
- col1,col2 = st.columns(2)
34
- with col1:
35
- teacher_code = st.text_input("Ogretmen kodu:",key=12)
36
- with col2:
37
- exam_code = st.text_input("Sınav Kodu:",key=13,value=10)
38
-
39
- exam_code = int(exam_code)
40
  teacher_code = str(teacher_code)
 
 
41
  DATA_FILENAME = f"{teacher_code}.csv"
42
  DATA_FILENAME = str(DATA_FILENAME)
43
 
44
  image_file = st.file_uploader(
45
  "Tarama Yapmak Icin Optigi Yukleyin", type=['jpeg', 'png', 'jpg', 'webp'])
46
-
47
-
48
  if image_file != None:
49
- col3,col4 = st.columns(2)
50
- with col3:
51
-
52
- if st.button("Tara ve Sonucu Goruntule"):
53
- repo, repo_df = pull_read(DATASET_REPO_URL = "https://huggingface.co/datasets/mertbozkurt/school_data",
54
  DATA_FILE = os.path.join("data", DATA_FILENAME),
55
  HF_TOKEN = "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")
56
- repo.git_pull()
 
 
 
 
 
 
 
 
 
 
 
57
  image = Image.open(image_file)
58
  image = np.array(image.convert('RGB'))
 
 
 
 
 
 
 
 
 
 
 
59
  #(ans_txt,pathImage, save_images= True)
60
- grading, wrong_ans, student_idFix, resim_list =optic1.optic1(ans_txt1="cevapanahtari/cevapanahtari_ders1.txt",
61
- ans_txt2="cevapanahtari/cevapanahtari_ders2.txt",
62
- ans_txt3="cevapanahtari/cevapanahtari_ders3.txt",
63
  pathImage=image,save_images=False)
64
 
65
  #image_show(resim_list)
66
- if len(wrong_ans[0]) == 0:
67
- wrong_ans[0] = "0"
68
- wrong_ans_str = (str(wrong_ans[0]))
69
- st.write("Ogrenci Numarasi:",student_idFix)
70
- st.write("Ders1 Yanlis Yaptigi sorular:",(str(wrong_ans[0])))
71
- st.write("Ders1 Notu:",int(grading[0]))
72
- st.write("Ders1 Yanlis Yaptigi sorular:",(str(wrong_ans[1])))
73
- st.write("Ders1 Notu:",int(grading[1]))
74
- st.write("Ders1 Yanlis Yaptigi sorular:",(str(wrong_ans[2])))
75
- st.write("Ders1 Notu:",int(grading[2]))
76
 
77
- with col4:
78
- if st.button("Tara ve Sonucu Kaydet"):
79
- repo, repo_df = pull_read(DATASET_REPO_URL = "https://huggingface.co/datasets/mertbozkurt/school_data",
80
  DATA_FILE = os.path.join("data", DATA_FILENAME),
81
  HF_TOKEN = "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")
82
- repo.git_pull()
83
- image = Image.open(image_file)
84
- image = np.array(image.convert('RGB'))
 
85
  #(ans_txt,pathImage, save_images= True)
86
- grading, wrong_ans, student_idFix, resim_list =optic1.optic1(ans_txt1="cevapanahtari/cevapanahtari_ders1.txt",
87
  ans_txt2="cevapanahtari/cevapanahtari_ders2.txt",
88
  ans_txt3="cevapanahtari/cevapanahtari_ders3.txt",
89
  pathImage=image,save_images=False)
90
 
91
  #image_show(resim_list)
92
- if len(wrong_ans[0]) == 0:
93
- wrong_ans[0] = "0"
94
  #
95
- wrong_ans_str = (str(wrong_ans[0]))
96
- new_data = make_new_data(sinav_kodu=exam_code, ogrenci_no=int(student_idFix),
97
- notu=int(grading[0]),yanlislar=str(wrong_ans_str))
98
 
99
  #st.dataframe(new_data)
100
- updated = update(new_data=new_data,ex_df=repo_df)
101
  #st.dataframe(updated,use_container_width=True)
102
- save_and_push(dataFrame=updated,repo=repo,fileName=f"data/{DATA_FILENAME}")
103
 
104
- st.download_button(label="Tum verileri indirmek icin tiklayin",data=convert_df_to_csv(updated),
105
- file_name=f'{teacher_code}.csv',mime='text/csv',)
 
 
106
 
107
  #python -m streamlit run app.py
108
  if __name__ == '__main__':
 
9
  from data_func import make_new_data,update,save_and_push
10
  import os
11
  from huggingface_hub import Repository
12
+ import reader
13
 
14
  def pull_read(DATASET_REPO_URL,HF_TOKEN,DATA_FILE):
15
 
 
28
  # IMPORTANT: Cache the conversion to prevent computation on every rerun
29
  return df.to_csv().encode('utf-8')
30
 
31
+
32
  def screen_scan_main():
33
+ teacher_code = st.text_input("Ogretmen kodu:",key=12)
34
+ password = st.text_input("Sıfre:",key=17,type="password")
35
 
 
 
 
 
 
 
 
36
  teacher_code = str(teacher_code)
37
+ password = str(password)
38
+
39
  DATA_FILENAME = f"{teacher_code}.csv"
40
  DATA_FILENAME = str(DATA_FILENAME)
41
 
42
  image_file = st.file_uploader(
43
  "Tarama Yapmak Icin Optigi Yukleyin", type=['jpeg', 'png', 'jpg', 'webp'])
 
 
44
  if image_file != None:
45
+ repo, repo_df = pull_read(DATASET_REPO_URL = "https://huggingface.co/datasets/mertbozkurt/school_data",
 
 
 
 
46
  DATA_FILE = os.path.join("data", DATA_FILENAME),
47
  HF_TOKEN = "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")
48
+ repo.git_pull()
49
+
50
+ if str(repo_df["ogrenci_no"][0]) == password:
51
+ st.write("Giris basarili")
52
+
53
+ exam_code = st.text_input("Sınav Kodu:",key=13,value=10)
54
+
55
+ exam_code = int(exam_code)
56
+
57
+ global myIndexs
58
+
59
+ if st.button("Cevap Anahtari Sec",key=51):
60
  image = Image.open(image_file)
61
  image = np.array(image.convert('RGB'))
62
+ #(ans_txt,pathImage, save_images= True)
63
+ resim_list,myIndexs =reader.reader(pathImage=image,save_images=False)
64
+
65
+
66
+ col3,col4 = st.columns(2)
67
+ with col3:
68
+
69
+ if st.button("Tara ve Sonucu Goruntule",key=52):
70
+
71
+ image = Image.open(image_file)
72
+ image = np.array(image.convert('RGB'))
73
  #(ans_txt,pathImage, save_images= True)
74
+ grading, wrong_ans, student_idFix, resim_list,empty_ans =optic1.optic1(ans_txt1=myIndexs[0],
75
+ ans_txt2=myIndexs[1],
76
+ ans_txt3=myIndexs[2],
77
  pathImage=image,save_images=False)
78
 
79
  #image_show(resim_list)
80
+ if len(wrong_ans[0]) == 0:
81
+ wrong_ans[0] = "0"
82
+ wrong_ans_str = (str(wrong_ans[0]))
83
+ st.write("Ogrenci Numarasi:",student_idFix)
84
+ st.write("Ders1 Yanlis Yaptigi sorular:",(str(wrong_ans[0])))
85
+ st.write("Ders1 Notu:",int(grading[0]))
86
+ st.write("Ders2 Yanlis Yaptigi sorular:",(str(wrong_ans[1])))
87
+ st.write("Ders2 Notu:",int(grading[1]))
88
+ st.write("Ders3 Yanlis Yaptigi sorular:",(str(wrong_ans[2])))
89
+ st.write("Ders4 Notu:",int(grading[2]))
90
 
91
+ with col4:
92
+ if st.button("Tara ve Sonucu Kaydet"):
93
+ repo, repo_df = pull_read(DATASET_REPO_URL = "https://huggingface.co/datasets/mertbozkurt/school_data",
94
  DATA_FILE = os.path.join("data", DATA_FILENAME),
95
  HF_TOKEN = "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")
96
+ repo.git_pull()
97
+
98
+ image = Image.open(image_file)
99
+ image = np.array(image.convert('RGB'))
100
  #(ans_txt,pathImage, save_images= True)
101
+ grading, wrong_ans, student_idFix, resim_list =optic1.optic1(ans_txt1="cevapanahtari/cevapanahtari_ders1.txt",
102
  ans_txt2="cevapanahtari/cevapanahtari_ders2.txt",
103
  ans_txt3="cevapanahtari/cevapanahtari_ders3.txt",
104
  pathImage=image,save_images=False)
105
 
106
  #image_show(resim_list)
107
+ if len(wrong_ans[0]) == 0:
108
+ wrong_ans[0] = "0"
109
  #
110
+ wrong_ans_str = (str(wrong_ans[0]))
111
+ new_data = make_new_data(sinav_kodu=exam_code, ogrenci_no=int(student_idFix),
112
+ notu=int(grading[0]),yanlislar=str(wrong_ans_str))
113
 
114
  #st.dataframe(new_data)
115
+ updated = update(new_data=new_data,ex_df=repo_df)
116
  #st.dataframe(updated,use_container_width=True)
117
+ save_and_push(dataFrame=updated,repo=repo,fileName=f"data/{DATA_FILENAME}")
118
 
119
+ st.download_button(label="Tum verileri indirmek icin tiklayin",data=convert_df_to_csv(updated),
120
+ file_name=f'{teacher_code}.csv',mime='text/csv',)
121
+ else:
122
+ st.write("Giris basarisiz kontrol ediniz.")
123
 
124
  #python -m streamlit run app.py
125
  if __name__ == '__main__':
toDo.txt DELETED
@@ -1,11 +0,0 @@
1
- wrong_ans gibi yaninda siklarinida kaydetsin
2
- scan ettikten sonra verileri son kez sorsun ve veri tabanina kaydetsin
3
- analiz sayfasi
4
- ornek optikler icin sayfa ki kullanmak isteyen cikartsin
5
-
6
- #-------------------------------------------
7
- dersin hangi ders hanagi sinavi oldugu konusu
8
- scan sayfasindan etiket secilip o sekilde kaydedilebilir
9
- optikten okumak gerekmez optik uzerinde elle yazilmasi yeterli olur
10
- o elle yazilan yerde buyutulur veya sayi olarak kodlanabilir bunlar kodlamaya gore sayisal
11
- degerine gore hangi ders hangi sinav oldugu belli olur