Spaces:
Runtime error
Runtime error
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() |