Update app.py
Browse files
app.py
CHANGED
|
@@ -14,20 +14,24 @@ model = YOLOv10(model_file)
|
|
| 14 |
|
| 15 |
account_sid = os.environ.get("TWILIO_ACCOUNT_SID")
|
| 16 |
auth_token = os.environ.get("TWILIO_AUTH_TOKEN")
|
| 17 |
-
client = Client(account_sid, auth_token)
|
| 18 |
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
def detection(image, conf_threshold=0.3):
|
| 28 |
image = cv2.resize(image, (model.input_width, model.input_height))
|
| 29 |
new_image = model.detect_objects(image, conf_threshold)
|
| 30 |
-
return new_image
|
| 31 |
|
| 32 |
|
| 33 |
css = """.my-group {max-width: 600px !important; max-height: 600 !important;}
|
|
@@ -60,9 +64,8 @@ with gr.Blocks(css=css) as demo:
|
|
| 60 |
value=0.30,
|
| 61 |
)
|
| 62 |
|
| 63 |
-
image.
|
| 64 |
-
fn=detection, inputs=[image, conf_threshold],
|
| 65 |
-
concurrency_limit=10
|
| 66 |
)
|
| 67 |
|
| 68 |
if __name__ == "__main__":
|
|
|
|
| 14 |
|
| 15 |
account_sid = os.environ.get("TWILIO_ACCOUNT_SID")
|
| 16 |
auth_token = os.environ.get("TWILIO_AUTH_TOKEN")
|
|
|
|
| 17 |
|
| 18 |
+
if account_sid and auth_token:
|
| 19 |
+
client = Client(account_sid, auth_token)
|
| 20 |
|
| 21 |
+
token = client.tokens.create()
|
| 22 |
+
|
| 23 |
+
rtc_configuration = {
|
| 24 |
+
"iceServers": token.ice_servers,
|
| 25 |
+
"iceTransportPolicy": "relay",
|
| 26 |
+
}
|
| 27 |
+
else:
|
| 28 |
+
rtc_configuration = None
|
| 29 |
|
| 30 |
|
| 31 |
def detection(image, conf_threshold=0.3):
|
| 32 |
image = cv2.resize(image, (model.input_width, model.input_height))
|
| 33 |
new_image = model.detect_objects(image, conf_threshold)
|
| 34 |
+
return cv2.resize(new_image, (500, 500))
|
| 35 |
|
| 36 |
|
| 37 |
css = """.my-group {max-width: 600px !important; max-height: 600 !important;}
|
|
|
|
| 64 |
value=0.30,
|
| 65 |
)
|
| 66 |
|
| 67 |
+
image.stream(
|
| 68 |
+
fn=detection, inputs=[image, conf_threshold], outputs=[image], time_limit=10
|
|
|
|
| 69 |
)
|
| 70 |
|
| 71 |
if __name__ == "__main__":
|