Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,14 @@ import numpy as np
|
|
| 5 |
import cv2
|
| 6 |
from PIL import Image
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def draw_detections(image, detections):
|
| 9 |
# Convert PIL image to a numpy array
|
| 10 |
np_image = np.array(image)
|
|
|
|
| 5 |
import cv2
|
| 6 |
from PIL import Image
|
| 7 |
|
| 8 |
+
# Initialize the model
|
| 9 |
+
config = DetrConfig.from_pretrained("facebook/detr-resnet-50")
|
| 10 |
+
model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50", config=config)
|
| 11 |
+
image_processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
|
| 12 |
+
|
| 13 |
+
# Initialize the pipeline
|
| 14 |
+
od_pipe = pipeline(task='object-detection', model=model, image_processor=image_processor)
|
| 15 |
+
|
| 16 |
def draw_detections(image, detections):
|
| 17 |
# Convert PIL image to a numpy array
|
| 18 |
np_image = np.array(image)
|