jbilcke-hf HF staff commited on
Commit
8aafe2e
β€’
1 Parent(s): 2f0ade7
Files changed (2) hide show
  1. app.py +1 -1
  2. engine.py +3 -3
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('hash'), data.get('params'))
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, uuid: str, params: Dict[str, float]) -> bytes:
107
  # If we don't have the image in cache yet, add it
108
- if uuid not in self.processed_cache:
109
  raise ValueError("cache miss")
110
 
111
- processed_data = self.processed_cache[uuid]
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