Spaces:
Sleeping
Sleeping
Siyun He
commited on
Commit
·
772889c
1
Parent(s):
ccf40ad
debug save function
Browse files
app.py
CHANGED
@@ -290,33 +290,33 @@ def refresh_interface():
|
|
290 |
# Return a message indicating the interface has been refreshed
|
291 |
return "Interface refreshed!"
|
292 |
|
293 |
-
|
294 |
-
#
|
295 |
-
|
296 |
|
297 |
-
#
|
298 |
-
|
299 |
|
300 |
-
#
|
301 |
-
|
302 |
|
303 |
-
#
|
304 |
-
|
305 |
|
306 |
-
|
307 |
|
308 |
-
def save_frame(frame):
|
309 |
-
|
310 |
-
|
311 |
|
312 |
-
|
313 |
-
|
314 |
|
315 |
-
|
316 |
-
|
317 |
|
318 |
-
|
319 |
-
|
320 |
|
321 |
def webcam_input(frame, transform, lip_color):
|
322 |
frame, face_shape, glass_shape = process_frame(frame)
|
@@ -346,7 +346,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple", secondary_hue="blue"))
|
|
346 |
|
347 |
input_img.stream(webcam_input, [input_img, transform, lip_color], [input_img, face_shape_output, glass_shape_output], stream_every=0.1)
|
348 |
with gr.Row():
|
349 |
-
next_button.click(
|
350 |
with gr.Row():
|
351 |
save_button.click(save_frame, [input_img], [download_link])
|
352 |
|
|
|
290 |
# Return a message indicating the interface has been refreshed
|
291 |
return "Interface refreshed!"
|
292 |
|
293 |
+
def save_frame(frame):
|
294 |
+
# Convert frame to RGB
|
295 |
+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
296 |
|
297 |
+
# Create a unique filename using the current timestamp
|
298 |
+
filename = f"saved_frame_{datetime.now().strftime('%Y%m%d_%H%M%S')}.png"
|
299 |
|
300 |
+
# Save the frame
|
301 |
+
cv2.imwrite(filename, frame)
|
302 |
|
303 |
+
# Refresh the interfaceq
|
304 |
+
refresh_interface()
|
305 |
|
306 |
+
return f"Frame saved as '{filename}'"
|
307 |
|
308 |
+
# def save_frame(frame):
|
309 |
+
# # Convert frame to RGB
|
310 |
+
# frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
311 |
|
312 |
+
# # Create a unique filename using the current timestamp
|
313 |
+
# filename = f"saved_frame_{datetime.now().strftime('%Y%m%d_%H%M%S')}.png"
|
314 |
|
315 |
+
# # Save the frame to a temporary file
|
316 |
+
# cv2.imwrite(filename, frame)
|
317 |
|
318 |
+
# # Return the filename for download
|
319 |
+
# return filename
|
320 |
|
321 |
def webcam_input(frame, transform, lip_color):
|
322 |
frame, face_shape, glass_shape = process_frame(frame)
|
|
|
346 |
|
347 |
input_img.stream(webcam_input, [input_img, transform, lip_color], [input_img, face_shape_output, glass_shape_output], stream_every=0.1)
|
348 |
with gr.Row():
|
349 |
+
next_button.click(change_glasses, [], [])
|
350 |
with gr.Row():
|
351 |
save_button.click(save_frame, [input_img], [download_link])
|
352 |
|