|
import gradio as gr |
|
import subprocess |
|
import os |
|
import time |
|
import datetime |
|
|
|
|
|
|
|
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(f"{BIN} -h") |
|
|
|
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() |