|
import gradio as gr |
|
|
|
from typing import List |
|
from shapely.geometry import Point |
|
from physical_checkbox import * |
|
from physical_boxes_define import gdf |
|
from utils_visible import set_visible |
|
from dotenv import load_dotenv |
|
import os |
|
load_dotenv() |
|
PATH_ASSETS = os.getenv('PATH_ASSETS') |
|
|
|
|
|
def find_bounding_box(evt: gr.SelectData, img, section: str): |
|
x, y = evt.index[0], evt.index[1] |
|
point = Point(x, y) |
|
match = gdf[gdf.contains(point)] |
|
if not match.empty: |
|
matched_box = match.iloc[0]['name'] |
|
checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts(section, matched_box) |
|
else: |
|
matched_box = None |
|
checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs = process_body_parts(section, matched_box) |
|
return checkbox_beak, text_beak, checkbox_body, text_body, checkbox_feathers, text_feathers, checkbox_head, text_head, checkbox_legs, text_legs |
|
|
|
|
|
|
|
|
|
def create_bird_anatomy(visible, section: str): |
|
|
|
print |
|
img_with_boxes = gr.Image(value=PATH_ASSETS+'images/bird_boxed.png', |
|
show_label=False, |
|
height="600px", |
|
elem_id=section, |
|
visible=visible) |
|
return img_with_boxes |
|
|
|
def show_physical(choice, section: str): |
|
visible = set_visible(choice) |
|
physical_boxes = create_bird_anatomy(visible, section) |
|
return physical_boxes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|