Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -30,25 +30,25 @@ image_paths = glob(os.path.join(data_path, '*.jpg'))
|
|
30 |
app = FaceAnalysis(name="buffalo_l") # ArcFace model
|
31 |
app.prepare(ctx_id=0 if torch.cuda.is_available() else -1, det_size=(IMAGE_SHAPE, IMAGE_SHAPE))
|
32 |
|
33 |
-
# Check if roll exists
|
34 |
-
def roll_exists(rno):
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
# Register new student
|
40 |
-
def register_student(rno, sname, sclass, image):
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
# Load all registered images
|
49 |
-
def load_registered_images():
|
50 |
-
|
51 |
-
return [row[3] for row in conn.execute("SELECT * FROM students")]
|
52 |
|
53 |
# Define function to match face embeddings
|
54 |
def prod_function(app, prod_path, webcam_img_pil):
|
@@ -170,28 +170,28 @@ with register_tab:
|
|
170 |
if st.button("Register"):
|
171 |
if not (rno and sname and sclass):
|
172 |
st.warning("Fill all details.")
|
173 |
-
# Save locally in employees folder
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
30 |
app = FaceAnalysis(name="buffalo_l") # ArcFace model
|
31 |
app.prepare(ctx_id=0 if torch.cuda.is_available() else -1, det_size=(IMAGE_SHAPE, IMAGE_SHAPE))
|
32 |
|
33 |
+
# # Check if roll exists
|
34 |
+
# def roll_exists(rno):
|
35 |
+
# with sqlite3.connect(STUDENT_DB) as conn:
|
36 |
+
# cur = conn.execute("SELECT * FROM students WHERE rno=?", (rno,))
|
37 |
+
# return cur.fetchone()
|
38 |
+
|
39 |
+
# # Register new student
|
40 |
+
# def register_student(rno, sname, sclass, image):
|
41 |
+
# image_path = os.path.join(data_path, f"{rno}.jpg")
|
42 |
+
# image.save(image_path)
|
43 |
+
# with sqlite3.connect(STUDENT_DB) as conn:
|
44 |
+
# conn.execute("INSERT INTO students (rno, sname, sclass, image_path) VALUES (?, ?, ?, ?)",
|
45 |
+
# (rno, sname, sclass, image_path))
|
46 |
+
|
47 |
+
|
48 |
+
# # Load all registered images
|
49 |
+
# def load_registered_images():
|
50 |
+
# with sqlite3.connect(STUDENT_DB) as conn:
|
51 |
+
# return [row[3] for row in conn.execute("SELECT * FROM students")]
|
52 |
|
53 |
# Define function to match face embeddings
|
54 |
def prod_function(app, prod_path, webcam_img_pil):
|
|
|
170 |
if st.button("Register"):
|
171 |
if not (rno and sname and sclass):
|
172 |
st.warning("Fill all details.")
|
173 |
+
# # Save locally in employees folder
|
174 |
+
# local_path = os.path.join("employees", f"{sname}.jpg")
|
175 |
+
# image_pil.save(local_path)
|
176 |
+
|
177 |
+
# # Convert image to base64 for sending to Glitch
|
178 |
+
# buffered = BytesIO()
|
179 |
+
# image_pil.save(buffered, format="JPEG")
|
180 |
+
# img_str = base64.b64encode(buffered.getvalue()).decode()
|
181 |
+
|
182 |
+
# # Prepare data for POST request
|
183 |
+
# glitch_url = "https://your-glitch-app.glitch.me/register" # Replace this
|
184 |
+
# data = {
|
185 |
+
# "rno": rno,
|
186 |
+
# "sname": sname,
|
187 |
+
# "sclass": sclass,
|
188 |
+
# "image_base64": img_str,
|
189 |
+
# }
|
190 |
+
|
191 |
+
# response = requests.post(glitch_url, json=data)
|
192 |
+
# result = response.json()
|
193 |
+
|
194 |
+
# if result["status"] == "success":
|
195 |
+
# st.success(result["message"])
|
196 |
+
# else:
|
197 |
+
# st.error(result["message"])
|