Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from fastapi import FastAPI, UploadFile, File
|
|
|
2 |
from transformers import pipeline
|
3 |
from PIL import Image
|
4 |
import io
|
@@ -7,7 +8,7 @@ import io
|
|
7 |
app = FastAPI()
|
8 |
|
9 |
# Load the YOLOv5 model for object detection
|
10 |
-
|
11 |
|
12 |
@app.post("/detect_objects/")
|
13 |
async def detect_objects(file: UploadFile = File(...)):
|
@@ -16,7 +17,7 @@ async def detect_objects(file: UploadFile = File(...)):
|
|
16 |
image = Image.open(io.BytesIO(image_bytes))
|
17 |
|
18 |
# Perform object detection
|
19 |
-
results =
|
20 |
|
21 |
# Extract bounding box coordinates and labels
|
22 |
bounding_boxes = []
|
|
|
1 |
from fastapi import FastAPI, UploadFile, File
|
2 |
+
from ultralytics import YOLO
|
3 |
from transformers import pipeline
|
4 |
from PIL import Image
|
5 |
import io
|
|
|
8 |
app = FastAPI()
|
9 |
|
10 |
# Load the YOLOv5 model for object detection
|
11 |
+
model = YOLO("yolov8n.pt")
|
12 |
|
13 |
@app.post("/detect_objects/")
|
14 |
async def detect_objects(file: UploadFile = File(...)):
|
|
|
17 |
image = Image.open(io.BytesIO(image_bytes))
|
18 |
|
19 |
# Perform object detection
|
20 |
+
results = model(image)
|
21 |
|
22 |
# Extract bounding box coordinates and labels
|
23 |
bounding_boxes = []
|