Spaces:
Build error
Build error
Regino commited on
Commit ·
9ef5697
1
Parent(s): 6f5fce0
sbdhf
Browse filesFiles changed (2)
- requirements.txt+4-4
- src/streamlit_app.py+28-15
1234567# requirements.txtstreamlitopencv-pythontensorflow # or tensorflow-cpunumpystreamlit-webrtc # <-- NEW# Add any other libraries your app uses1234567streamlitopencv-pythontensorflow-cpu # <-- Use this if your Hugging Face Space is CPU-only. Otherwise, keep 'tensorflow'.numpystreamlit-webrtcavPillow
79 unmodified lines8081828384858610 unmodified lines97989910010110210345 unmodified lines14915015115215315415515615715815916016116216316416516616779 unmodified linesdef transform(self, frame: av.VideoFrame) -> np.ndarray:# Convert av.VideoFrame to NumPy array.# Requesting "bgr24" format directly from `av` to align with OpenCV's default.img_bgr = frame.to_ndarray(format="bgr24") # <--- MODIFIED TO BGR24# Convert to grayscale for face detection and emotion predictiongray_frame = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2GRAY)10 unmodified linesx_orig = int(x / FACE_DETECTION_DOWNSCALE)y_orig = int(y / FACE_DETECTION_DOWNSCALE)w_orig = int(w / FACE_DETECTION_DOWNSCALE)h_orig = int(h / FACE_DETECTION_DOWNSCALE) # Corrected potential typo here if original was h_orig / h_origoriginal_faces.append((x_orig, y_orig, w_orig, h_orig))# Process each detected face45 unmodified linesmode=WebRtcMode.SENDRECV, # Send video from client, receive processed video from servervideo_processor_factory=lambda: EmotionDetector(model, face_detector),media_stream_constraints={"video": True, "audio": False}, # Only video, no audioasync_processing=True, # Process frames asynchronously# desired_playing_state={"playing": True}, # Optional: tries to auto-start. Can comment out.# --- ADD THIS LINE HERE ---rtc_configuration={"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]},# You can add more STUN servers for redundancy if needed, like:# rtc_configuration={# "iceServers": [# {"urls": ["stun:stun.l.google.com:19302"]},# {"urls": ["stun:stun1.l.google.com:19302"]},# {"urls": ["stun:stun.services.mozilla.com"]}# ]# },)# Provide feedback based on the stream state79 unmodified lines8081828384858610 unmodified lines97989910010110210345 unmodified lines14915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918079 unmodified linesdef transform(self, frame: av.VideoFrame) -> np.ndarray:# Convert av.VideoFrame to NumPy array.# Requesting "bgr24" format directly from `av` to align with OpenCV's default.img_bgr = frame.to_ndarray(format="bgr24")# Convert to grayscale for face detection and emotion predictiongray_frame = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2GRAY)10 unmodified linesx_orig = int(x / FACE_DETECTION_DOWNSCALE)y_orig = int(y / FACE_DETECTION_DOWNSCALE)w_orig = int(w / FACE_DETECTION_DOWNSCALE)h_orig = int(h / FACE_DETECTION_DOWNSCALE)original_faces.append((x_orig, y_orig, w_orig, h_orig))# Process each detected face45 unmodified linesmode=WebRtcMode.SENDRECV, # Send video from client, receive processed video from servervideo_processor_factory=lambda: EmotionDetector(model, face_detector),media_stream_constraints={"video": True, "audio": False}, # Only video, no audio# Temporarily set async_processing to False for debugging.# If this works, it points to an asyncio interaction issue. For better performance,# you'd ideally re-enable async_processing=True later.async_processing=False,# Optional: tries to auto-start. Can comment out if you prefer manual start.# desired_playing_state={"playing": True},# --- ENHANCED RTC CONFIGURATION ---# Providing a robust list of public STUN servers for better NAT traversalrtc_configuration={"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]},{"urls": ["stun:stun1.l.google.com:19302"]},{"urls": ["stun:stun2.l.google.com:19302"]},{"urls": ["stun:stun3.l.google.com:19302"]},{"urls": ["stun:stun4.l.google.com:19302"]},{"urls": ["stun:stun.services.mozilla.com"]},{"urls": ["stun:global.stun.twilio.com:3478"]},{"urls": ["stun:stun.nextcloud.com:3478"]}, # Added another{"urls": ["stun:stun.schlund.de"]}, # Added another]},# For more detailed debugging in the browser console, uncomment the line below.# log_level="debug",)# Provide feedback based on the stream state
requirements.txt+4-4
src/streamlit_app.py+28-15