Your Name commited on
Commit
b1b9f82
1 Parent(s): b3e9026

forced lora

Browse files
Files changed (1) hide show
  1. handler.py +13 -9
handler.py CHANGED
@@ -88,7 +88,7 @@ class EndpointHandler:
88
  self.inference_progress = {} # Dictionary to store progress of each request
89
  self.inference_images = {} # Dictionary to store latest image of each request
90
  self.total_steps = {}
91
- self.active_request_ids = set()
92
  self.inference_in_progress = False
93
 
94
  self.executor = ThreadPoolExecutor(
@@ -260,20 +260,20 @@ class EndpointHandler:
260
 
261
  return negative_prompt
262
 
263
- def clean_request_data(self, request_id: str):
264
  """Clean up the data related to a specific request ID."""
265
 
266
  # Remove the request ID from the progress dictionary
267
- self.inference_progress.pop(request_id, None)
268
 
269
  # Remove the request ID from the images dictionary
270
- self.inference_images.pop(request_id, None)
271
 
272
  # Remove the request ID from the total_steps dictionary
273
- self.total_steps.pop(request_id, None)
274
 
275
  # Delete request id
276
- self.active_request_ids.discard(request_id)
277
 
278
  # Set inference to False
279
  self.inference_in_progress = False
@@ -294,7 +294,11 @@ class EndpointHandler:
294
  img = Image.fromarray(img_data, "RGB")
295
 
296
  # Apply a blur to the image
297
- img = img.filter(ImageFilter.GaussianBlur(radius=5))
 
 
 
 
298
 
299
  # print(img_data)
300
  else:
@@ -462,11 +466,11 @@ class EndpointHandler:
462
  }
463
 
464
  # Set the inference state to in progress
465
- self.clean_request_data(request_id)
466
  self.inference_in_progress = True
467
  self.inference_progress[request_id] = 0
468
  self.inference_images[request_id] = None
469
- self.active_request_ids.add(request_id)
470
 
471
  self.executor.submit(self.start_inference, data)
472
 
 
88
  self.inference_progress = {} # Dictionary to store progress of each request
89
  self.inference_images = {} # Dictionary to store latest image of each request
90
  self.total_steps = {}
91
+ self.active_request_ids = list()
92
  self.inference_in_progress = False
93
 
94
  self.executor = ThreadPoolExecutor(
 
260
 
261
  return negative_prompt
262
 
263
+ def clean_request_data(self):
264
  """Clean up the data related to a specific request ID."""
265
 
266
  # Remove the request ID from the progress dictionary
267
+ self.inference_progress.clear()
268
 
269
  # Remove the request ID from the images dictionary
270
+ self.inference_images.clear()
271
 
272
  # Remove the request ID from the total_steps dictionary
273
+ self.total_steps.clear()
274
 
275
  # Delete request id
276
+ self.active_request_ids.clear()
277
 
278
  # Set inference to False
279
  self.inference_in_progress = False
 
294
  img = Image.fromarray(img_data, "RGB")
295
 
296
  # Apply a blur to the image
297
+ # more intense at the beginning
298
+ if step < int(self.total_steps[self.active_request_ids[0]] / 1.5):
299
+ img = img.filter(ImageFilter.GaussianBlur(radius=30))
300
+ else:
301
+ img = img.filter(ImageFilter.GaussianBlur(radius=10))
302
 
303
  # print(img_data)
304
  else:
 
466
  }
467
 
468
  # Set the inference state to in progress
469
+ self.clean_request_data()
470
  self.inference_in_progress = True
471
  self.inference_progress[request_id] = 0
472
  self.inference_images[request_id] = None
473
+ self.active_request_ids.append(request_id)
474
 
475
  self.executor.submit(self.start_inference, data)
476