VikramSingh178 commited on
Commit
818d89d
β€’
1 Parent(s): 698092e
configs/tti_settings.py CHANGED
@@ -7,7 +7,7 @@ class TTI_SETTINGS(BaseSettings):
7
  ENABLE_COMPILE: bool = False
8
  DEVICE: str = "cuda"
9
  TRITON_MODEL_NAME: str = "PICPILOT_PRODUCTION_SERVER"
10
- MAX_BATCH_SIZE: int = 8
11
  MAX_QUEUE_DELAY_MICROSECONDS: int = 100
12
  TORCH_INDUCTOR_CONFIG: dict = {
13
  "conv_1x1_as_mm": True,
 
7
  ENABLE_COMPILE: bool = False
8
  DEVICE: str = "cuda"
9
  TRITON_MODEL_NAME: str = "PICPILOT_PRODUCTION_SERVER"
10
+ MAX_BATCH_SIZE: int = 32
11
  MAX_QUEUE_DELAY_MICROSECONDS: int = 100
12
  TORCH_INDUCTOR_CONFIG: dict = {
13
  "conv_1x1_as_mm": True,
scripts/s3_manager.py CHANGED
@@ -20,12 +20,21 @@ class S3ManagerService:
20
  region_name=settings.AWS_REGION,
21
  )
22
 
23
- def generate_signed_url(self, file_name: str, exp: int = 43200) -> str: # 43200 seconds = 12 hours
24
- return self.s3.generate_presigned_url(
25
- "get_object",
26
- Params={"Bucket": settings.AWS_BUCKET_NAME, "Key": file_name},
27
- ExpiresIn=exp,
28
- )
 
 
 
 
 
 
 
 
 
29
 
30
  def generate_unique_file_name(self, file_name: str) -> str:
31
  random_string = "".join(
 
20
  region_name=settings.AWS_REGION,
21
  )
22
 
23
+ def generate_signed_url(self, file_name: str, exp: int = 43200) -> str:
24
+ try:
25
+ url = self.s3.generate_presigned_url(
26
+ ClientMethod='get_object',
27
+ Params={
28
+ 'Bucket': settings.AWS_BUCKET_NAME,
29
+ 'Key': file_name
30
+ },
31
+ ExpiresIn=exp,
32
+ HttpMethod='GET'
33
+ )
34
+ return url
35
+ except Exception as e:
36
+ print(f"Error generating presigned URL: {e}")
37
+ return None
38
 
39
  def generate_unique_file_name(self, file_name: str) -> str:
40
  random_string = "".join(
triton-api/client.py CHANGED
@@ -128,7 +128,7 @@ async def generate_image(request: ImageGenerationRequest) -> Dict[str, Any]:
128
  inputs = _prepare_inference_inputs(request)
129
  result_dict = await triton_client.infer_sample(**inputs)
130
 
131
- output = result_dict["output"][0]
132
  return json.loads(output.decode("utf-8"))
133
  except Exception as e:
134
  logger.error(f"Error generating image: {e}")
 
128
  inputs = _prepare_inference_inputs(request)
129
  result_dict = await triton_client.infer_sample(**inputs)
130
 
131
+ output = result_dict["output"]
132
  return json.loads(output.decode("utf-8"))
133
  except Exception as e:
134
  logger.error(f"Error generating image: {e}")
triton-api/text-to-image.py CHANGED
@@ -130,18 +130,20 @@ class SDXLLoraInference:
130
  Raises:
131
  ValueError: If an invalid output mode is specified.
132
  """
133
- image = self.pipe(
134
  prompt=self.prompt,
135
  num_inference_steps=self.num_inference_steps,
136
  guidance_scale=self.guidance_scale,
137
  negative_prompt=self.negative_prompt,
138
  num_images_per_prompt=self.num_images,
139
- ).images[0]
140
 
141
  if self.mode == "s3_json":
142
- return pil_to_s3_json(image, "sdxl_image")
 
143
  elif self.mode == "b64_json":
144
- return pil_to_b64_json(image)
 
145
  else:
146
  raise ValueError(
147
  "Invalid mode. Supported modes are 'b64_json' and 's3_json'."
 
130
  Raises:
131
  ValueError: If an invalid output mode is specified.
132
  """
133
+ images = self.pipe(
134
  prompt=self.prompt,
135
  num_inference_steps=self.num_inference_steps,
136
  guidance_scale=self.guidance_scale,
137
  negative_prompt=self.negative_prompt,
138
  num_images_per_prompt=self.num_images,
139
+ ).images
140
 
141
  if self.mode == "s3_json":
142
+ for image in images:
143
+ return pil_to_s3_json(image, "sdxl_image")
144
  elif self.mode == "b64_json":
145
+ for image in images:
146
+ return pil_to_b64_json(image)
147
  else:
148
  raise ValueError(
149
  "Invalid mode. Supported modes are 'b64_json' and 's3_json'."