File size: 654 Bytes
7435539
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
import torch
from transformers import AutoModel, AutoTokenizer

# Load the model and tokenizer
model = AutoModel.from_pretrained("detectron2/faster_rcnn_R_50_FPN_3x")
tokenizer = AutoTokenizer.from_pretrained("detectron2/faster_rcnn_R_50_FPN_3x")

# Define a function that takes an image as input and returns the output of the model
def detect_faces(image):
    inputs = {"image": image}
    output = model(**inputs)
    boxes = output[0]["boxes"]
    return boxes

# Create the Gradio interface
interface = gr.Interface(fn=detect_faces, inputs=gr.inputs.Image(), outputs=gr.outputs.Boxes())

# Launch the interface
interface.launch()