File size: 1,047 Bytes
2eef291
9879a31
 
f415467
6490051
40ea1e3
51e2294
61b2597
6f3480d
cf5669a
6f3480d
 
 
8f9057a
6f3480d
001ff47
6490051
6f91bae
e25f3ed
6f91bae
e25f3ed
6f91bae
9879a31
40ea1e3
001ff47
9879a31
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
import gradio as gr
import subprocess
import os
import time
import datetime

# 获取third_party文件夹的绝对路径
#third_party_path = os.path.abspath('./third_party/')
BIN = "./yolov5s-tt100k-debian12.bin"
os.environ['LD_LIBRARY_PATH'] = f"{os.environ.get('LD_LIBRARY_PATH', '')}:/usr/lib/x86_64-linux-gnu/"
os.system(f"chmod a+x {BIN}")
# os.system("find / -type f -name libopencv_imgcodecs*")
# print(os.environ.get('LD_LIBRARY_PATH'))
os.system(f"{BIN} -h")
# os.system("ldd ./yolov5s-tt100k-static.bin")
def run_yolov5s(image_filepath):
    print(datetime.datetime.utcnow())
    start_time = time.time()
    result = subprocess.run([BIN, "-m", "./yolov5s_tt100k_opt_fp32.tmfile", "-i", image_filepath], capture_output=True, text=True)
    elapsed_time = time.time() - start_time
    print(result.stdout)
    print("elapsed_time (s)", elapsed_time)
    return "yolov5s-tt100k.out.jpg", result.stdout

iface = gr.Interface(fn=run_yolov5s, inputs=gr.Image(type="filepath"), outputs=[gr.Image(type="filepath"), gr.Textbox()])
iface.launch()