Arafath10 commited on
Commit
299d49b
·
verified ·
1 Parent(s): f6091d8

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +13 -15
main.py CHANGED
@@ -1,23 +1,10 @@
1
  from ultralytics import YOLO
2
- model = YOLO('best.pt') # load a custom model
3
-
4
- # Predict with the model
5
- results = model('test.jpg')
6
-
7
- # Extracting predictions with class names and confidence levels
8
- predictions = results.pandas().xyxy[0][['name', 'confidence']]
9
-
10
- # Sorting predictions from highest to lowest confidence
11
- sorted_predictions = predictions.sort_values(by='confidence', ascending=False)
12
-
13
- # Display sorted predictions
14
- print(sorted_predictions)# predict on an image
15
 
16
  import asyncio
17
  from fastapi import FastAPI
18
  from fastapi.middleware.cors import CORSMiddleware
19
  import requests
20
-
21
 
22
  app = FastAPI()
23
 
@@ -34,4 +21,15 @@ app.add_middleware(
34
 
35
  @app.get("/predict")
36
  async def get_prediction(page: str,paginate: str):
37
- return "done"
 
 
 
 
 
 
 
 
 
 
 
 
1
  from ultralytics import YOLO
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  import asyncio
4
  from fastapi import FastAPI
5
  from fastapi.middleware.cors import CORSMiddleware
6
  import requests
7
+ model = YOLO('best.pt') # load a custom model
8
 
9
  app = FastAPI()
10
 
 
21
 
22
  @app.get("/predict")
23
  async def get_prediction(page: str,paginate: str):
24
+ # Predict with the model
25
+ results = model('test.jpg')
26
+
27
+ # Extracting predictions with class names and confidence levels
28
+ predictions = results.pandas().xyxy[0][['name', 'confidence']]
29
+
30
+ # Sorting predictions from highest to lowest confidence
31
+ sorted_predictions = predictions.sort_values(by='confidence', ascending=False)
32
+
33
+ # Display sorted predictions
34
+ print(sorted_predictions)# predict on an image
35
+ return sorted_predictions