chandralegend commited on
Commit
9c6937e
·
0 Parent(s):

Duplicate from aieye/aieye_tutorial_template

Browse files
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
.sessions/.gitkeep ADDED
File without changes
.sessions/johndoe/level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 3
0_Introduction.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.levels import complete_level, initialize_level, render_page, get_level
3
+ from utils.login import initialize_login
4
+
5
+ initialize_login()
6
+ initialize_level()
7
+
8
+ LEVEL=0
9
+
10
+ def intro_page():
11
+ st.header("AI Eye Tutorial Template")
12
+ st.subheader("Level 0: Introduction")
13
+
14
+ st.write("""Welcome to the AI Eye Tutorial Template! This template is designed to help you create your own AI Eye tutorial.
15
+ The template is divided into levels, and each level has a set of tasks that you need to complete before you can move on to the next level.
16
+ You can use this template to create your own tutorial by completing the tasks in each level and adding your own content. You can also use
17
+ this template to learn how to use AI Eye by completing the tasks in each level.""")
18
+
19
+ st.info(f"Current Level: {get_level()}")
20
+
21
+ if st.button("Complete"):
22
+ complete_level(LEVEL)
23
+
24
+ render_page(intro_page, LEVEL)
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Aieye Tutorial Template
3
+ emoji: 🌍
4
+ colorFrom: green
5
+ colorTo: purple
6
+ sdk: streamlit
7
+ sdk_version: 1.21.0
8
+ app_file: 0_Introduction.py
9
+ pinned: false
10
+ license: openrail
11
+ duplicated_from: aieye/aieye_tutorial_template
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
assets/logo.png ADDED
assets/quiz.json ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "question": "Which of the following best describes emotion detection?",
4
+ "options": [
5
+ "Teaching computers to understand human emotions",
6
+ "Teaching humans to understand computer languages",
7
+ "Teaching computers to create video games",
8
+ "Teaching humans to recognize facial features"
9
+ ],
10
+ "answer": "Teaching computers to understand human emotions"
11
+ },
12
+ {
13
+ "question": "What programming language is commonly used in developing emotion detection applications?",
14
+ "options": [
15
+ "Python",
16
+ "Java",
17
+ "C++",
18
+ "Ruby"
19
+ ],
20
+ "answer": "Python"
21
+ },
22
+ {
23
+ "question": "What is the purpose of OpenCV in an emotion detection application?",
24
+ "options": [
25
+ "To analyze and manipulate images and videos",
26
+ "To recognize and understand human emotions",
27
+ "To create graphical user interfaces",
28
+ "To generate statistical reports"
29
+ ],
30
+ "answer": "To analyze and manipulate images and videos"
31
+ },
32
+ {
33
+ "question": "Why is it important to have a diverse dataset when training an emotion detection model?",
34
+ "options": [
35
+ "It helps the model better understand different facial expressions",
36
+ "It improves the performance of the computer's processor",
37
+ "It makes the application run faster",
38
+ "It reduces the training time for the model"
39
+ ],
40
+ "answer": "It helps the model better understand different facial expressions"
41
+ },
42
+ {
43
+ "question": "What is the final step after training the model in an emotion detection application?",
44
+ "options": [
45
+ "Collect more data for training",
46
+ "Test the model's accuracy and performance",
47
+ "Install additional software plugins",
48
+ "Optimize the application's user interface"
49
+ ],
50
+ "answer": "Test the model's accuracy and performance"
51
+ },
52
+ {
53
+ "question": "How does the inference process work in an emotion detection application?",
54
+ "options": [
55
+ "It analyzes facial features and predicts the associated emotion",
56
+ "It collects user feedback and improves the model's accuracy",
57
+ "It converts emotions into numerical values for analysis",
58
+ "It adjusts the application's settings based on user preferences"
59
+ ],
60
+ "answer": "It analyzes facial features and predicts the associated emotion"
61
+ },
62
+ {
63
+ "question": "What is an example of a real-world application of emotion detection technology?",
64
+ "options": [
65
+ "Virtual reality gaming",
66
+ "Weather forecasting",
67
+ "Online shopping",
68
+ "Recipe suggestions"
69
+ ],
70
+ "answer": "Virtual reality gaming"
71
+ },
72
+ {
73
+ "question": "What is the importance of ethical considerations in emotion detection applications?",
74
+ "options": [
75
+ "Ensuring privacy and consent when collecting data",
76
+ "Optimizing the application's performance",
77
+ "Reducing the complexity of the model",
78
+ "Enhancing the visual appearance of the application"
79
+ ],
80
+ "answer": "Ensuring privacy and consent when collecting data"
81
+ },
82
+ {
83
+ "question": "What can students do to further explore and improve their emotion detection application?",
84
+ "options": [
85
+ "Experiment with different image preprocessing techniques",
86
+ "Rewrite the entire code from scratch",
87
+ "Avoid using real-time video feeds for testing",
88
+ "Skip the testing phase and move directly to deployment"
89
+ ],
90
+ "answer": "Experiment with different image preprocessing techniques"
91
+ }
92
+ ]
pages/1_Step_1.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.levels import complete_level, render_page, initialize_level
3
+ LEVEL = 1
4
+
5
+ initialize_level()
6
+
7
+ def step1_page():
8
+ st.header("Step 1")
9
+ st.subheader("Level 1: Introduction")
10
+ st.write("This is the first step of the tutorial. You can add your own content here.")
11
+
12
+ if st.button("Complete"):
13
+ complete_level(LEVEL)
14
+
15
+ render_page(step1_page, LEVEL)
pages/2_Step_2.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.levels import complete_level, render_page, initialize_level
3
+
4
+ initialize_level()
5
+
6
+ LEVEL = 2
7
+
8
+ def step2_page():
9
+ st.header("Step 2")
10
+ st.subheader("Level 2: Introduction")
11
+ st.write("This is the second step of the tutorial. You can add your own content here.")
12
+
13
+ if st.button("Complete"):
14
+ complete_level(LEVEL)
15
+
16
+ render_page(step2_page, LEVEL)
pages/3_Quiz.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.levels import complete_level, render_page, initialize_level
3
+ from utils.login import initialize_login
4
+ import random
5
+ import json
6
+
7
+ LEVEL = 3
8
+
9
+ initialize_login()
10
+ initialize_level()
11
+
12
+
13
+ if "questions" not in st.session_state:
14
+ with open("assets/quiz.json") as f:
15
+ questions = json.load(f)
16
+
17
+ for i in range(len(questions)):
18
+ random.shuffle(questions[i]["options"])
19
+ random.shuffle(questions)
20
+
21
+ st.session_state["questions"] = questions
22
+
23
+
24
+ def step_page():
25
+ st.header("Quiz")
26
+ st.markdown(
27
+ """Now that you've learned about how Face Recognition work, let's test your knowledge with a quiz!"""
28
+ )
29
+
30
+ for i in range(len(st.session_state["questions"])):
31
+ st.subheader(f"Question {i + 1}")
32
+ question = st.session_state["questions"][i]
33
+ st.markdown(question["question"])
34
+ answer = st.radio("Select an answer:", question["options"], key=f"radio{i}")
35
+
36
+ if st.session_state.get("EVALUATE", False):
37
+ if answer == question["answer"]:
38
+ st.success("Correct!")
39
+ else:
40
+ st.error("Incorrect! Try Again")
41
+
42
+ if st.button("Evaluate"):
43
+ st.session_state["EVALUATE"] = True
44
+ st.experimental_rerun()
45
+
46
+ st.info("Click on the button below to complete the tutorial!")
47
+ if st.button("Complete"):
48
+ complete_level(LEVEL)
49
+
50
+
51
+ render_page(step_page, LEVEL)
pages/4_Congratulations.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.levels import complete_level, render_page, initialize_level
3
+
4
+ initialize_level()
5
+
6
+ LEVEL = 4
7
+
8
+ def step1_page():
9
+ st.header("Congratulations!")
10
+ st.subheader("You have completed the tutorial!")
11
+ st.write("You can now use this template to create your own tutorial.")
12
+ st.balloons()
13
+
14
+ render_page(step1_page, LEVEL)
requirements.txt ADDED
File without changes
utils/__init__.py ADDED
File without changes
utils/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (161 Bytes). View file
 
utils/__pycache__/levels.cpython-310.pyc ADDED
Binary file (1.59 kB). View file
 
utils/__pycache__/login.cpython-310.pyc ADDED
Binary file (1.05 kB). View file
 
utils/levels.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.login import get_login
3
+ import os
4
+
5
+ def initialize_level():
6
+ if 'level' not in st.session_state:
7
+ if get_login()["status"]:
8
+ if not os.path.exists(f".sessions/{get_login()['username']}/level.txt"):
9
+ with open(f".sessions/{get_login()['username']}/level.txt", "w") as f:
10
+ f.write("0")
11
+ st.session_state['level'] = 0
12
+ else:
13
+ with open(f".sessions/{get_login()['username']}/level.txt", "r") as f:
14
+ st.session_state['level'] = int(f.read())
15
+
16
+ def get_level():
17
+ return st.session_state['level']
18
+
19
+ def render_page(page, level):
20
+ if get_login()["status"]:
21
+ if st.session_state['level'] < level:
22
+ st.error(f"You need to complete Level {st.session_state['level']} first!")
23
+ else:
24
+ page()
25
+ else:
26
+ st.error("You need to login first!")
27
+
28
+ def complete_level(level):
29
+ if st.session_state['level'] > level:
30
+ st.info(f'You have Already completed Level {level}!')
31
+ else:
32
+ st.session_state['level'] = level + 1
33
+ with open(f".sessions/{get_login()['username']}/level.txt", "w") as f:
34
+ f.write(str(st.session_state['level']))
35
+ st.balloons()
36
+ st.success(f'You have completed Level {level}! You can now move on to the next level.')
utils/login.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+
4
+
5
+ def initialize_login():
6
+ if "login" not in st.session_state:
7
+ st.columns(3)[1].image("assets/logo.png")
8
+ username = st.text_input("Username")
9
+ password = st.text_input("Password", type="password")
10
+ if st.button("Login"):
11
+ # TODO: replace with actual authorization check
12
+ authorized = {"status": True, "Name": "John Doe", "username": "johndoe"}
13
+ if authorized["status"]:
14
+ st.session_state["login"] = authorized
15
+ os.makedirs(
16
+ os.path.join(".sessions", st.session_state["login"]["username"]),
17
+ exist_ok=True,
18
+ )
19
+ st.success("Login Successful!")
20
+ st.experimental_rerun()
21
+ else:
22
+ st.error("Invalid username or password")
23
+ else:
24
+ st.sidebar.success(f'Hello, {st.session_state["login"]["Name"]}!')
25
+
26
+
27
+ def get_login():
28
+ return st.session_state.get("login", {"status": False})