Spaces:
Runtime error
Runtime error
VikramSingh178
commited on
Commit
β’
818d89d
1
Parent(s):
698092e
bug fixes
Browse files- configs/tti_settings.py +1 -1
- scripts/s3_manager.py +15 -6
- triton-api/client.py +1 -1
- triton-api/text-to-image.py +6 -4
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 =
|
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:
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
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"]
|
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 |
-
|
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 |
-
|
|
|
143 |
elif self.mode == "b64_json":
|
144 |
-
|
|
|
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'."
|