File size: 1,317 Bytes
8c881da
 
 
 
 
 
84ce883
 
8c881da
 
 
2383f2b
 
1a33c90
 
 
 
69a894f
84ce883
30371fc
2222c48
30371fc
8c881da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from FootDetection import FootDetection

# Initialize model (first run will auto-download weights)
foot_detection = FootDetection("cpu")  # "cuda" for GPU  or "mps" for App

def detect(img, threshold):
    results = foot_detection.detect(img, threshold=threshold)
    img_with_boxes = foot_detection.draw_boxes(img)
    return img_with_boxes

demo = gr.Interface(fn=detect,
                    title='Foot Detection',
                    description="""by [Tony Assi](https://www.tonyassi.com/)
                    
                    [Model](https://huggingface.co/tonyassi/foot-detection) [Github](https://github.com/TonyAssi/foot-detection)
                    
                    A lightweight Python module for detecting feet or shoes in images using a fine-tuned Faster R-CNN model (PyTorch + Torchvision). [email protected] for inquiries. """,
                    inputs=[gr.Image(label='Input', type='pil'), gr.Slider(label='Threshold', minimum=0.0, maximum=1.0, value=0.3)], 
                    outputs=gr.Image(label='Result', type='pil'),
                    cache_examples=True,
                    examples=[['examples/1.jpg', 0.3], ['examples/2.jpg', 0.3], ['examples/3.jpg', 0.3], ['examples/4.jpg', 0.3], ['examples/5.jpg', 0.3], ['examples/6.jpg', 0.3]])
demo.launch()