sonobit commited on
Commit
7435539
·
1 Parent(s): 96cac27

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from transformers import AutoModel, AutoTokenizer
4
+
5
+ # Load the model and tokenizer
6
+ model = AutoModel.from_pretrained("detectron2/faster_rcnn_R_50_FPN_3x")
7
+ tokenizer = AutoTokenizer.from_pretrained("detectron2/faster_rcnn_R_50_FPN_3x")
8
+
9
+ # Define a function that takes an image as input and returns the output of the model
10
+ def detect_faces(image):
11
+ inputs = {"image": image}
12
+ output = model(**inputs)
13
+ boxes = output[0]["boxes"]
14
+ return boxes
15
+
16
+ # Create the Gradio interface
17
+ interface = gr.Interface(fn=detect_faces, inputs=gr.inputs.Image(), outputs=gr.outputs.Boxes())
18
+
19
+ # Launch the interface
20
+ interface.launch()