Spaces:
Runtime error
Runtime error
File size: 4,775 Bytes
e6dc665 97b3ea8 e6dc665 712d61e e6dc665 712d61e 97b3ea8 e6dc665 712d61e 97b3ea8 e6dc665 712d61e a9658cc 712d61e e6dc665 712d61e 97b3ea8 712d61e e6dc665 712d61e 78a22d9 b1f181a 712d61e a7848ca 712d61e e6dc665 712d61e e6dc665 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
import csv
import streamlit as st
import numpy as np
import cv2
from PIL import Image
import optic1
from functions import image_show
import pandas as pd
from data_func import make_new_data,update,save_and_push
import os
from huggingface_hub import Repository
def pull_read(DATASET_REPO_URL,HF_TOKEN,DATA_FILE):
repo = Repository(
local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
)
with open(DATA_FILE) as csvfile:
df = pd.read_csv(csvfile)
df = pd.DataFrame(df)
return repo, df
@st.cache
def convert_df_to_csv(df):
# IMPORTANT: Cache the conversion to prevent computation on every rerun
return df.to_csv().encode('utf-8')
def screen_scan_main():
col1,col2 = st.columns(2)
with col1:
teacher_code = st.text_input("Ogretmen kodu:",key=12)
with col2:
exam_code = st.text_input("Sınav Kodu:",key=13,value=10)
exam_code = int(exam_code)
teacher_code = str(teacher_code)
DATA_FILENAME = f"{teacher_code}.csv"
DATA_FILENAME = str(DATA_FILENAME)
image_file = st.file_uploader(
"Tarama Yapmak Icin Optigi Yukleyin", type=['jpeg', 'png', 'jpg', 'webp'])
if image_file != None:
col3,col4 = st.columns(2)
with col3:
if st.button("Tara ve Sonucu Goruntule"):
repo, repo_df = pull_read(DATASET_REPO_URL = "https://huggingface.co/datasets/mertbozkurt/school_data",
DATA_FILE = os.path.join("data", DATA_FILENAME),
HF_TOKEN = "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")
repo.git_pull()
image = Image.open(image_file)
image = np.array(image.convert('RGB'))
#(ans_txt,pathImage, save_images= True)
grading, wrong_ans, student_idFix, resim_list =optic1.optic1(ans_txt1="cevapanahtari/cevapanahtari_ders1.txt",
ans_txt2="cevapanahtari/cevapanahtari_ders2.txt",
ans_txt3="cevapanahtari/cevapanahtari_ders3.txt",
pathImage=image,save_images=False)
#image_show(resim_list)
if len(wrong_ans[0]) == 0:
wrong_ans[0] = "0"
wrong_ans_str = ','.join(wrong_ans[0])
st.write("Notu:",int(grading[0]))
st.write("Yanlis Yaptigi sorular:",wrong_ans_str)
st.write("Ogrenci Numarasi:",student_idFix)
with col4:
if st.button("Tara ve Sonucu Kaydet"):
repo, repo_df = pull_read(DATASET_REPO_URL = "https://huggingface.co/datasets/mertbozkurt/school_data",
DATA_FILE = os.path.join("data", DATA_FILENAME),
HF_TOKEN = "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")
repo.git_pull()
image = Image.open(image_file)
image = np.array(image.convert('RGB'))
#(ans_txt,pathImage, save_images= True)
grading, wrong_ans, student_idFix, resim_list =optic1.optic1(ans_txt1="cevapanahtari/cevapanahtari_ders1.txt",
ans_txt2="cevapanahtari/cevapanahtari_ders2.txt",
ans_txt3="cevapanahtari/cevapanahtari_ders3.txt",
pathImage=image,save_images=False)
#image_show(resim_list)
if len(wrong_ans[0]) == 0:
wrong_ans[0] = "0"
#
for i in wrong_ans:
wrong_ans_str = ','.join(str(wrong_ans[0]))
new_data = make_new_data(sinav_kodu=exam_code, ogrenci_no=int(student_idFix),
notu=int(grading[0]),yanlislar=str(wrong_ans_str))
#st.dataframe(new_data)
updated = update(new_data=new_data,ex_df=repo_df)
#st.dataframe(updated,use_container_width=True)
save_and_push(dataFrame=updated,repo=repo,fileName=f"data/{DATA_FILENAME}")
st.download_button(label="Tum verileri indirmek icin tiklayin",data=convert_df_to_csv(updated),
file_name=f'{teacher_code}.csv',mime='text/csv',)
#python -m streamlit run app.py
if __name__ == '__main__':
screen_scan_main() |