Update 1/model.py
This commit is contained in:
parent
9c072e629e
commit
9881ed59ce
33
1/model.py
33
1/model.py
@ -1,28 +1,35 @@
|
|||||||
# model.py - 최소한의 구현
|
|
||||||
import triton_python_backend_utils as pb_utils
|
import triton_python_backend_utils as pb_utils
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import json
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
|
||||||
class TritonPythonModel:
|
class TritonPythonModel:
|
||||||
def initialize(self, args):
|
def initialize(self, args):
|
||||||
print("Model initialized")
|
self.logger = pb_utils.Logger
|
||||||
|
self.model_name = args["model_name"]
|
||||||
|
self.logger.log_info(f"'{self.model_name}' 모델 초기화 완료")
|
||||||
|
|
||||||
|
|
||||||
def execute(self, requests):
|
def execute(self, requests):
|
||||||
print(f"Received {len(requests)} requests")
|
|
||||||
responses = []
|
responses = []
|
||||||
|
|
||||||
for i, request in enumerate(requests):
|
for request in requests:
|
||||||
print(f"Processing request {i}")
|
random_string = ''.join(
|
||||||
|
random.choice(string.ascii_letters + string.digits) for _ in range(16)
|
||||||
|
)
|
||||||
|
self.logger.log_info(f"OUTPUT 출력:\n{random_string}")
|
||||||
|
|
||||||
# 고정된 응답 생성
|
output_tensor = pb_utils.Tensor(
|
||||||
output_data = "Hello World"
|
"OUTPUT",
|
||||||
output_tensor = pb_utils.Tensor("OUTPUT", np.array([output_data]))
|
np.array([random_string.encode("utf-8")], dtype=np.object_)
|
||||||
|
)
|
||||||
|
|
||||||
response = pb_utils.InferenceResponse(output_tensors=[output_tensor])
|
responses.append(pb_utils.InferenceResponse(
|
||||||
responses.append(response)
|
output_tensors=[output_tensor]
|
||||||
print(f"Response {i} created")
|
))
|
||||||
|
|
||||||
print("All responses ready")
|
|
||||||
return responses
|
return responses
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
print("Model finalized")
|
pass
|
||||||
Loading…
Reference in New Issue
Block a user