Update app.py
Browse files
app.py
CHANGED
|
@@ -1135,6 +1135,13 @@ class VoiceServicesModule(IModule):
|
|
| 1135 |
|
| 1136 |
class VideoService(IModule):
|
| 1137 |
"""Handles video capture from a webcam."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1138 |
def get_frame(self):
|
| 1139 |
if not self.cap: return None
|
| 1140 |
ret, frame = self.cap.read()
|
|
@@ -2084,7 +2091,13 @@ def launch_ui(bootstrap_instance: "Bootstrap"):
|
|
| 2084 |
test_btn.click(lambda: do_test(), [], [opt_out])
|
| 2085 |
apply_btn.click(do_apply, [role_state, mode_state], [opt_out])
|
| 2086 |
|
| 2087 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2088 |
|
| 2089 |
class Bootstrap:
|
| 2090 |
"""Handles the entire application startup sequence cleanly."""
|
|
|
|
| 1135 |
|
| 1136 |
class VideoService(IModule):
|
| 1137 |
"""Handles video capture from a webcam."""
|
| 1138 |
+
def __init__(self, hive_instance: "Hive"):
|
| 1139 |
+
super().__init__(hive_instance)
|
| 1140 |
+
self.cap = None
|
| 1141 |
+
if _HAVE_CV:
|
| 1142 |
+
# Initialize the camera capture
|
| 1143 |
+
self.cap = cv2.VideoCapture(0)
|
| 1144 |
+
|
| 1145 |
def get_frame(self):
|
| 1146 |
if not self.cap: return None
|
| 1147 |
ret, frame = self.cap.read()
|
|
|
|
| 2091 |
test_btn.click(lambda: do_test(), [], [opt_out])
|
| 2092 |
apply_btn.click(do_apply, [role_state, mode_state], [opt_out])
|
| 2093 |
|
| 2094 |
+
demo.launch(
|
| 2095 |
+
server_name="0.0.0.0",
|
| 2096 |
+
server_port=int(os.environ.get("PORT")) if os.environ.get("PORT") else None,
|
| 2097 |
+
share=os.getenv("GRADIO_SHARE", "false").lower() == "true",
|
| 2098 |
+
ssl_certfile="cert.pem",
|
| 2099 |
+
ssl_keyfile="key.pem"
|
| 2100 |
+
); return demo
|
| 2101 |
|
| 2102 |
class Bootstrap:
|
| 2103 |
"""Handles the entire application startup sequence cleanly."""
|