Spaces:
Runtime error
Runtime error
Upload webapp.py
Browse files
webapp.py
CHANGED
@@ -49,7 +49,7 @@ class DemoCase:
|
|
49 |
self.FRAME_WIDTH: int = FRAME_WIDTH
|
50 |
self.FRAME_HEIGHT: int = FRAME_HEIGHT
|
51 |
self.YOLO_VERBOSE: bool = YOLO_VERBOSE
|
52 |
-
self.STREAM_RESOLUTION: str = "
|
53 |
# predefined yolov8 model references
|
54 |
self.model_dict: dict = {
|
55 |
"y8nano": "./data/models/yolov8n.pt",
|
@@ -527,8 +527,10 @@ class DemoCase:
|
|
527 |
|
528 |
# reducer frames size for performance, int percentage
|
529 |
frame_tagged = await reducer(
|
530 |
-
frame_tagged,
|
|
|
531 |
)
|
|
|
532 |
# handle JPEG encoding & yield frame in byte format
|
533 |
img_encoded = \
|
534 |
cv2.imencode(".jpg", frame_tagged)[1].tobytes()
|
@@ -1203,7 +1205,7 @@ class DemoCase:
|
|
1203 |
|
1204 |
# is_huggingface = False
|
1205 |
# define the host url and port for webgear server
|
1206 |
-
# HOST_WEBGEAR, PORT_WEBGEAR = "localhost",
|
1207 |
|
1208 |
# instantiate a demo case
|
1209 |
demo_case = DemoCase(YOLO_VERBOSE=False)
|
@@ -1226,8 +1228,8 @@ options = {
|
|
1226 |
"custom_data_location": "./",
|
1227 |
"enable_infinite_frames": True,
|
1228 |
# "jpeg_compression_quality": 90,
|
1229 |
-
"jpeg_compression_fastdct": True,
|
1230 |
-
"jpeg_compression_fastupsample": True,
|
1231 |
}
|
1232 |
|
1233 |
web = WebGear(
|
@@ -1270,7 +1272,7 @@ web.routes.append(Route(
|
|
1270 |
))
|
1271 |
|
1272 |
# if is_huggingface is False:
|
1273 |
-
# # run this app on Uvicorn server at address http://localhost:
|
1274 |
# uvicorn.run(
|
1275 |
# web(), host=HOST_WEBGEAR, port=PORT_WEBGEAR, log_level="info"
|
1276 |
# )
|
@@ -1278,4 +1280,4 @@ web.routes.append(Route(
|
|
1278 |
# web.shutdown()
|
1279 |
#
|
1280 |
# or launch it using cli --
|
1281 |
-
# uvicorn webapp:web --host "localhost" --port
|
|
|
49 |
self.FRAME_WIDTH: int = FRAME_WIDTH
|
50 |
self.FRAME_HEIGHT: int = FRAME_HEIGHT
|
51 |
self.YOLO_VERBOSE: bool = YOLO_VERBOSE
|
52 |
+
self.STREAM_RESOLUTION: str = "720p"
|
53 |
# predefined yolov8 model references
|
54 |
self.model_dict: dict = {
|
55 |
"y8nano": "./data/models/yolov8n.pt",
|
|
|
527 |
|
528 |
# reducer frames size for performance, int percentage
|
529 |
frame_tagged = await reducer(
|
530 |
+
frame=frame_tagged,
|
531 |
+
percentage=self.frame_reduction * (frame_tagged.shape[0] / 720) # noqa
|
532 |
)
|
533 |
+
|
534 |
# handle JPEG encoding & yield frame in byte format
|
535 |
img_encoded = \
|
536 |
cv2.imencode(".jpg", frame_tagged)[1].tobytes()
|
|
|
1205 |
|
1206 |
# is_huggingface = False
|
1207 |
# define the host url and port for webgear server
|
1208 |
+
# HOST_WEBGEAR, PORT_WEBGEAR = "localhost", 8080
|
1209 |
|
1210 |
# instantiate a demo case
|
1211 |
demo_case = DemoCase(YOLO_VERBOSE=False)
|
|
|
1228 |
"custom_data_location": "./",
|
1229 |
"enable_infinite_frames": True,
|
1230 |
# "jpeg_compression_quality": 90,
|
1231 |
+
# "jpeg_compression_fastdct": True,
|
1232 |
+
# "jpeg_compression_fastupsample": True,
|
1233 |
}
|
1234 |
|
1235 |
web = WebGear(
|
|
|
1272 |
))
|
1273 |
|
1274 |
# if is_huggingface is False:
|
1275 |
+
# # run this app on Uvicorn server at address http://localhost:8080/
|
1276 |
# uvicorn.run(
|
1277 |
# web(), host=HOST_WEBGEAR, port=PORT_WEBGEAR, log_level="info"
|
1278 |
# )
|
|
|
1280 |
# web.shutdown()
|
1281 |
#
|
1282 |
# or launch it using cli --
|
1283 |
+
# uvicorn webapp:web --host "localhost" --port 8080 --reload
|