feat
fix 超分异常
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import minio.error
|
import minio.error
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import redis
|
import redis
|
||||||
import torch
|
import torch
|
||||||
import tritonclient.grpc as grpcclient
|
import tritonclient.grpc as grpcclient
|
||||||
|
|
||||||
from app.core.config import *
|
from app.core.config import *
|
||||||
from app.schemas.super_resolution import SuperResolutionModel
|
from app.schemas.super_resolution import SuperResolutionModel
|
||||||
from app.service.utils.oss_client import oss_get_image, oss_upload_image
|
from app.service.utils.oss_client import oss_get_image, oss_upload_image
|
||||||
@@ -32,6 +34,7 @@ class SuperResolution:
|
|||||||
def read_image(self):
|
def read_image(self):
|
||||||
try:
|
try:
|
||||||
img = oss_get_image(bucket=self.sr_image_url.split("/", 1)[0], object_name=self.sr_image_url.split("/", 1)[1], data_type="cv2")
|
img = oss_get_image(bucket=self.sr_image_url.split("/", 1)[0], object_name=self.sr_image_url.split("/", 1)[1], data_type="cv2")
|
||||||
|
img = img.astype(np.float32) / 255. # 解码
|
||||||
except minio.error.S3Error as e:
|
except minio.error.S3Error as e:
|
||||||
sr_data = json.dumps({'tasks_id': self.tasks_id, 'status': 'ERROR', 'message': f'{e}'})
|
sr_data = json.dumps({'tasks_id': self.tasks_id, 'status': 'ERROR', 'message': f'{e}'})
|
||||||
self.channel.basic_publish(exchange='', routing_key=SR_RABBITMQ_QUEUES, body=sr_data)
|
self.channel.basic_publish(exchange='', routing_key=SR_RABBITMQ_QUEUES, body=sr_data)
|
||||||
@@ -144,6 +147,6 @@ def infer_cancel(tasks_id):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
request_data = SuperResolutionModel(sr_image_url="test/512_image/15.png", sr_xn=2, sr_tasks_id="123")
|
request_data = SuperResolutionModel(sr_image_url="test/512_image/15.png", sr_xn=2, sr_tasks_id="12341556")
|
||||||
service = SuperResolution(request_data)
|
service = SuperResolution(request_data)
|
||||||
result_url = service.sr_result()
|
result_url = service.sr_result()
|
||||||
|
|||||||
Reference in New Issue
Block a user