import gradio as gr
import cv2
from pyAAMED import pyAAMED
title = """
Arc Adjacency Matrix based Fast Ellipse Detection
Gitub
"""
def detect_ellipses(img_path):
imgC = cv2.imread(img_path)
imgG = cv2.cvtColor(imgC, cv2.COLOR_BGR2GRAY)
aamed = pyAAMED(600, 600)
aamed.setParameters(3.1415926/3, 3.4, 0.77)
result = aamed.run_AAMED(imgG)
print(result)
return [img_path, result]
examples = [
["./AAMED/python/002_0038.jpg"]
]
gr.Interface(
fn=detect_ellipses,
inputs=gr.Image(label="Upload image with ellipses", type="filepath"),
outputs=[
gr.Image(type="filepath", label="Detected ellipses"),
gr.Text(label="Detected data")
]
title=title,
examples=examples,
allow_flagging='never'
).launch(server_name="0.0.0.0", server_port=7860)