awacke1 commited on
Commit
4c3762f
·
verified ·
1 Parent(s): 2c1404b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -13
app.py CHANGED
@@ -18,7 +18,6 @@ import random
18
  import logging
19
  import numpy as np
20
  import cv2
21
- import sounddevice as sd
22
 
23
  logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
24
  logger = logging.getLogger(__name__)
@@ -332,16 +331,14 @@ def update_gallery():
332
  st.image(Image.open(file), caption=file, use_container_width=True)
333
  st.markdown(get_download_link(file, "image/png", "Download Image"), unsafe_allow_html=True)
334
 
335
- def get_available_devices():
336
  video_devices = []
337
  for i in range(10):
338
  cap = cv2.VideoCapture(i)
339
  if cap.isOpened():
340
  video_devices.append(f"Camera {i}")
341
  cap.release()
342
- audio_devices = sd.query_devices()
343
- audio_list = [f"{device['name']} (ID: {i})" for i, device in enumerate(audio_devices) if device['max_input_channels'] > 0]
344
- return video_devices, audio_list
345
 
346
  def mock_search(query: str) -> str:
347
  if "superhero" in query.lower():
@@ -537,26 +534,21 @@ with tab1:
537
 
538
  with tab2:
539
  st.header("Camera Snap 📷 (Dual Capture!)")
540
- video_devices, audio_devices = get_available_devices()
541
  st.subheader("Device Settings ⚙️")
542
  if not video_devices:
543
  st.warning("No video devices detected! 📷 Please connect a camera.")
544
  else:
545
  st.write(f"Detected Video Devices: {', '.join(video_devices)}")
546
- if not audio_devices:
547
- st.warning("No audio input devices detected! 🎙️ Please connect a microphone.")
548
- else:
549
- st.write(f"Detected Audio Devices: {', '.join(audio_devices)}")
550
  default_cam0 = video_devices[0] if video_devices else None
551
  default_cam1 = video_devices[1] if len(video_devices) > 1 else default_cam0
552
  selected_cam0 = st.selectbox("Select Camera 0", video_devices, index=0 if video_devices else -1, key="cam0_select")
553
  selected_cam1 = st.selectbox("Select Camera 1", video_devices, index=1 if len(video_devices) > 1 else 0, key="cam1_select")
554
- selected_audio = st.selectbox("Select Audio Device", audio_devices, key="audio_select") if audio_devices else st.write("No audio devices available.")
555
  slice_count = st.number_input("Image Slice Count 🎞️", min_value=1, max_value=20, value=10, help="How many snaps to dream of? (Automation’s on vacation! 😜)")
556
  video_length = st.number_input("Video Dream Length (seconds) 🎥", min_value=1, max_value=30, value=10, help="Imagine a vid this long—sadly, we’re stuck with pics for now! 😂")
557
  cols = st.columns(2)
558
  with cols[0]:
559
- st.subheader(f"Camera 0 ({selected_cam0}) 🎬")
560
  cam0_img = st.camera_input("Snap a Shot - Cam 0 📸", key="cam0", help="Click to capture a heroic moment! 🦸‍♂️")
561
  if cam0_img:
562
  filename = generate_filename(0)
@@ -568,7 +560,7 @@ with tab2:
568
  update_gallery()
569
  st.info("🚨 Multi-frame capture’s on strike! Snap one at a time—your Titan’s too cool for automation glitches! 😎")
570
  with cols[1]:
571
- st.subheader(f"Camera 1 ({selected_cam1}) 🎥")
572
  cam1_img = st.camera_input("Snap a Shot - Cam 1 📸", key="cam1", help="Grab another epic frame! 🌟")
573
  if cam1_img:
574
  filename = generate_filename(1)
 
18
  import logging
19
  import numpy as np
20
  import cv2
 
21
 
22
  logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
23
  logger = logging.getLogger(__name__)
 
331
  st.image(Image.open(file), caption=file, use_container_width=True)
332
  st.markdown(get_download_link(file, "image/png", "Download Image"), unsafe_allow_html=True)
333
 
334
+ def get_available_video_devices():
335
  video_devices = []
336
  for i in range(10):
337
  cap = cv2.VideoCapture(i)
338
  if cap.isOpened():
339
  video_devices.append(f"Camera {i}")
340
  cap.release()
341
+ return video_devices
 
 
342
 
343
  def mock_search(query: str) -> str:
344
  if "superhero" in query.lower():
 
534
 
535
  with tab2:
536
  st.header("Camera Snap 📷 (Dual Capture!)")
537
+ video_devices = get_available_video_devices()
538
  st.subheader("Device Settings ⚙️")
539
  if not video_devices:
540
  st.warning("No video devices detected! 📷 Please connect a camera.")
541
  else:
542
  st.write(f"Detected Video Devices: {', '.join(video_devices)}")
 
 
 
 
543
  default_cam0 = video_devices[0] if video_devices else None
544
  default_cam1 = video_devices[1] if len(video_devices) > 1 else default_cam0
545
  selected_cam0 = st.selectbox("Select Camera 0", video_devices, index=0 if video_devices else -1, key="cam0_select")
546
  selected_cam1 = st.selectbox("Select Camera 1", video_devices, index=1 if len(video_devices) > 1 else 0, key="cam1_select")
 
547
  slice_count = st.number_input("Image Slice Count 🎞️", min_value=1, max_value=20, value=10, help="How many snaps to dream of? (Automation’s on vacation! 😜)")
548
  video_length = st.number_input("Video Dream Length (seconds) 🎥", min_value=1, max_value=30, value=10, help="Imagine a vid this long—sadly, we’re stuck with pics for now! 😂")
549
  cols = st.columns(2)
550
  with cols[0]:
551
+ st.subheader(f"Camera 0 ({selected_cam0}) 🎬" if selected_cam0 else "Camera 0 (None Detected)")
552
  cam0_img = st.camera_input("Snap a Shot - Cam 0 📸", key="cam0", help="Click to capture a heroic moment! 🦸‍♂️")
553
  if cam0_img:
554
  filename = generate_filename(0)
 
560
  update_gallery()
561
  st.info("🚨 Multi-frame capture’s on strike! Snap one at a time—your Titan’s too cool for automation glitches! 😎")
562
  with cols[1]:
563
+ st.subheader(f"Camera 1 ({selected_cam1}) 🎥" if selected_cam1 else "Camera 1 (None Detected)")
564
  cam1_img = st.camera_input("Snap a Shot - Cam 1 📸", key="cam1", help="Grab another epic frame! 🌟")
565
  if cam1_img:
566
  filename = generate_filename(1)