Spaces:
Build error
Build error
File size: 828 Bytes
1865436 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from src.ss.signboard_detect import inference_signboard
import os
import numpy as np
import cv2
def handle_ss(input, output):
checkpoint = "./checkpoints/ss/ss.ckpt"
if input:
img = cv2.imread(input)
dimensions = img.shape
hei, wid = dimensions[0], dimensions[1]
segment_array = inference_signboard(input, checkpoint).astype(int)
h, w = segment_array.shape
if hei == h and wid == w:
segment_array = segment_array
else:
segment_array = cv2.rotate(
segment_array, cv2.ROTATE_90_CLOCKWISE)
txt_name = str(input.split("/")[-1].split(".")[0]) + '.txt'
if output:
output_path = os.path.join(output, txt_name)
np.savetxt(output_path, segment_array)
return output_path, segment_array
|