cvjtbz / app.py
cxeep's picture
Update app.py
6490051 verified
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()