Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,11 +40,16 @@ async def process_webcam_stream_async(image):
|
|
| 40 |
image (PIL.Image or None): Image captured from webcam or uploaded.
|
| 41 |
|
| 42 |
Returns:
|
| 43 |
-
tuple: (description, human, objects_str,
|
| 44 |
-
description (str):
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
"""
|
| 49 |
if image is None:
|
| 50 |
return "", "", "", ""
|
|
@@ -121,15 +126,28 @@ with gr.Blocks() as demo:
|
|
| 121 |
with gr.Column():
|
| 122 |
# Output fields for MCP response
|
| 123 |
description_out = gr.Textbox(label="Description", lines=5)
|
| 124 |
-
human_out = gr.Textbox(label="Human", lines=3)
|
| 125 |
-
objects_out = gr.Textbox(label="Objects", lines=2)
|
| 126 |
environment_out = gr.Textbox(label="Environment", lines=3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
# Stream webcam input to server every 0.5 seconds
|
| 129 |
webcam_input.stream(
|
| 130 |
process_webcam_stream_async,
|
| 131 |
inputs=[webcam_input],
|
| 132 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
stream_every=0.5
|
| 134 |
)
|
| 135 |
|
|
|
|
| 40 |
image (PIL.Image or None): Image captured from webcam or uploaded.
|
| 41 |
|
| 42 |
Returns:
|
| 43 |
+
tuple: (description, environment, indoor_or_outdoor, lighting_condition, human, animals_str, objects_str, hazards_str)
|
| 44 |
+
description (str): General description of the scene.
|
| 45 |
+
environment (str): Description of the surrounding environment.
|
| 46 |
+
indoor_or_outdoor (str): Whether the scene appears to be indoors or outdoors.
|
| 47 |
+
lighting_condition (str): Lighting condition (e.g., bright, dim, natural, artificial).
|
| 48 |
+
human (str): Information about any humans detected.
|
| 49 |
+
animals_str (str): Information about any animals detected, or "none".
|
| 50 |
+
objects_str (str): Comma-separated list of detected objects.
|
| 51 |
+
hazards_str (str): Comma-separated list of hazards, or "none".
|
| 52 |
+
|
| 53 |
"""
|
| 54 |
if image is None:
|
| 55 |
return "", "", "", ""
|
|
|
|
| 126 |
with gr.Column():
|
| 127 |
# Output fields for MCP response
|
| 128 |
description_out = gr.Textbox(label="Description", lines=5)
|
|
|
|
|
|
|
| 129 |
environment_out = gr.Textbox(label="Environment", lines=3)
|
| 130 |
+
indoor_outdoor_out = gr.Textbox(label="Indoor/Outdoor", lines=1)
|
| 131 |
+
lighting_out = gr.Textbox(label="Lighting Condition", lines=1)
|
| 132 |
+
human_out = gr.Textbox(label="Human Detected", lines=3)
|
| 133 |
+
animals_out = gr.Textbox(label="Animals Detected", lines=2)
|
| 134 |
+
objects_out = gr.Textbox(label="Objects Detected", lines=2)
|
| 135 |
+
hazards_out = gr.Textbox(label="Hazards Identified", lines=2)
|
| 136 |
|
| 137 |
# Stream webcam input to server every 0.5 seconds
|
| 138 |
webcam_input.stream(
|
| 139 |
process_webcam_stream_async,
|
| 140 |
inputs=[webcam_input],
|
| 141 |
+
outputs=[
|
| 142 |
+
description_out,
|
| 143 |
+
objects_out,
|
| 144 |
+
environment_out,
|
| 145 |
+
indoor_outdoor_out,
|
| 146 |
+
lighting_condition_out,
|
| 147 |
+
human_out,
|
| 148 |
+
animals_out,
|
| 149 |
+
hazards_out
|
| 150 |
+
]
|
| 151 |
stream_every=0.5
|
| 152 |
)
|
| 153 |
|