Spaces:
Running
on
L40S
Running
on
L40S
Commit
β’
8aafe2e
1
Parent(s):
2f0ade7
sorry
Browse files
app.py
CHANGED
@@ -79,7 +79,7 @@ async def websocket_handler(request: web.Request) -> web.WebSocketResponse:
|
|
79 |
|
80 |
elif msg.type == WSMsgType.TEXT:
|
81 |
data = json.loads(msg.data)
|
82 |
-
webp_bytes = await engine.transform_image(data.get('
|
83 |
await ws.send_bytes(webp_bytes)
|
84 |
|
85 |
except Exception as e:
|
|
|
79 |
|
80 |
elif msg.type == WSMsgType.TEXT:
|
81 |
data = json.loads(msg.data)
|
82 |
+
webp_bytes = await engine.transform_image(data.get('uuid'), data.get('params'))
|
83 |
await ws.send_bytes(webp_bytes)
|
84 |
|
85 |
except Exception as e:
|
engine.py
CHANGED
@@ -103,12 +103,12 @@ class Engine:
|
|
103 |
# 'bbox_rot': bbox_info['bbox_rot'].toList(), # 4x2
|
104 |
}
|
105 |
|
106 |
-
async def transform_image(self,
|
107 |
# If we don't have the image in cache yet, add it
|
108 |
-
if
|
109 |
raise ValueError("cache miss")
|
110 |
|
111 |
-
processed_data = self.processed_cache[
|
112 |
|
113 |
try:
|
114 |
# Apply modifications based on params
|
|
|
103 |
# 'bbox_rot': bbox_info['bbox_rot'].toList(), # 4x2
|
104 |
}
|
105 |
|
106 |
+
async def transform_image(self, uid: str, params: Dict[str, float]) -> bytes:
|
107 |
# If we don't have the image in cache yet, add it
|
108 |
+
if uid not in self.processed_cache:
|
109 |
raise ValueError("cache miss")
|
110 |
|
111 |
+
processed_data = self.processed_cache[uid]
|
112 |
|
113 |
try:
|
114 |
# Apply modifications based on params
|