Spaces:
Running
on
L40S
Running
on
L40S
Commit
β’
c2ac436
1
Parent(s):
733113f
we have to many requests per seconds in the logs, so let's make them light
Browse files
app.py
CHANGED
@@ -56,7 +56,7 @@ async def websocket_handler(request: web.Request) -> web.WebSocketResponse:
|
|
56 |
ws = web.WebSocketResponse()
|
57 |
await ws.prepare(request)
|
58 |
try:
|
59 |
-
logger.info("New WebSocket connection established")
|
60 |
|
61 |
while True:
|
62 |
msg = await ws.receive()
|
@@ -76,7 +76,7 @@ async def websocket_handler(request: web.Request) -> web.WebSocketResponse:
|
|
76 |
|
77 |
|
78 |
elif msg.type in (WSMsgType.CLOSE, WSMsgType.ERROR):
|
79 |
-
logger.warning(f"WebSocket connection closed: {msg.type}")
|
80 |
break
|
81 |
|
82 |
except Exception as e:
|
@@ -94,7 +94,7 @@ async def handle_modify_image(request: web.Request, ws: web.WebSocketResponse, m
|
|
94 |
msg (Dict[str, Any]): The message containing the image or image_hash and modification parameters.
|
95 |
uuid: A unique identifier for the request.
|
96 |
"""
|
97 |
-
logger.info("Received modify_image request")
|
98 |
try:
|
99 |
engine = request.app['engine']
|
100 |
image_hash = msg.get('image_hash')
|
@@ -114,9 +114,9 @@ async def handle_modify_image(request: web.Request, ws: web.WebSocketResponse, m
|
|
114 |
"success": True,
|
115 |
"uuid": uuid # Include the UUID in the response
|
116 |
})
|
117 |
-
logger.info("Successfully sent modified image")
|
118 |
except Exception as e:
|
119 |
-
logger.error(f"Error in modify_image: {str(e)}")
|
120 |
await ws.send_json({
|
121 |
"type": "modified_image",
|
122 |
"success": False,
|
|
|
56 |
ws = web.WebSocketResponse()
|
57 |
await ws.prepare(request)
|
58 |
try:
|
59 |
+
#logger.info("New WebSocket connection established")
|
60 |
|
61 |
while True:
|
62 |
msg = await ws.receive()
|
|
|
76 |
|
77 |
|
78 |
elif msg.type in (WSMsgType.CLOSE, WSMsgType.ERROR):
|
79 |
+
#logger.warning(f"WebSocket connection closed: {msg.type}")
|
80 |
break
|
81 |
|
82 |
except Exception as e:
|
|
|
94 |
msg (Dict[str, Any]): The message containing the image or image_hash and modification parameters.
|
95 |
uuid: A unique identifier for the request.
|
96 |
"""
|
97 |
+
#logger.info("Received modify_image request")
|
98 |
try:
|
99 |
engine = request.app['engine']
|
100 |
image_hash = msg.get('image_hash')
|
|
|
114 |
"success": True,
|
115 |
"uuid": uuid # Include the UUID in the response
|
116 |
})
|
117 |
+
#logger.info("Successfully sent modified image")
|
118 |
except Exception as e:
|
119 |
+
#logger.error(f"Error in modify_image: {str(e)}")
|
120 |
await ws.send_json({
|
121 |
"type": "modified_image",
|
122 |
"success": False,
|
engine.py
CHANGED
@@ -97,7 +97,9 @@ class Engine:
|
|
97 |
Returns:
|
98 |
Dict[str, Any]: Processed image data.
|
99 |
"""
|
100 |
-
|
|
|
|
|
101 |
if image_hash not in self.image_cache:
|
102 |
raise ValueError(f"Image with hash {image_hash} not found in cache")
|
103 |
|
@@ -143,8 +145,9 @@ class Engine:
|
|
143 |
Raises:
|
144 |
ValueError: If there's an error modifying the image or WebP is not supported.
|
145 |
"""
|
146 |
-
|
147 |
-
logger.
|
|
|
148 |
|
149 |
try:
|
150 |
image_hash = self.get_image_hash(image_or_hash)
|
@@ -203,12 +206,12 @@ class Engine:
|
|
203 |
result_image.save(buffered, format="WebP", quality=85) # Adjust quality as needed
|
204 |
modified_image_base64 = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
205 |
|
206 |
-
logger.info("Image modification completed successfully")
|
207 |
return f"data:image/webp;base64,{modified_image_base64}"
|
208 |
|
209 |
except Exception as e:
|
210 |
-
logger.error(f"Error in modify_image: {str(e)}")
|
211 |
-
logger.exception("Full traceback:")
|
212 |
raise ValueError(f"Failed to modify image: {str(e)}")
|
213 |
|
214 |
async def _apply_facial_modifications(self, x_d_new: torch.Tensor, params: Dict[str, float]) -> None:
|
|
|
97 |
Returns:
|
98 |
Dict[str, Any]: Processed image data.
|
99 |
"""
|
100 |
+
# let's hide the logs as there are thousands of message slike this
|
101 |
+
#logger.info(f"Processing image with hash: {image_hash}")
|
102 |
+
|
103 |
if image_hash not in self.image_cache:
|
104 |
raise ValueError(f"Image with hash {image_hash} not found in cache")
|
105 |
|
|
|
145 |
Raises:
|
146 |
ValueError: If there's an error modifying the image or WebP is not supported.
|
147 |
"""
|
148 |
+
# let's disable those logs completely as there are thousands of message slike this
|
149 |
+
#logger.info("Starting image modification")
|
150 |
+
#logger.debug(f"Modification parameters: {params}")
|
151 |
|
152 |
try:
|
153 |
image_hash = self.get_image_hash(image_or_hash)
|
|
|
206 |
result_image.save(buffered, format="WebP", quality=85) # Adjust quality as needed
|
207 |
modified_image_base64 = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
208 |
|
209 |
+
#logger.info("Image modification completed successfully")
|
210 |
return f"data:image/webp;base64,{modified_image_base64}"
|
211 |
|
212 |
except Exception as e:
|
213 |
+
#logger.error(f"Error in modify_image: {str(e)}")
|
214 |
+
#logger.exception("Full traceback:")
|
215 |
raise ValueError(f"Failed to modify image: {str(e)}")
|
216 |
|
217 |
async def _apply_facial_modifications(self, x_d_new: torch.Tensor, params: Dict[str, float]) -> None:
|