Update handler.py
Browse files- handler.py +7 -7
handler.py
CHANGED
@@ -8,20 +8,20 @@ import os
|
|
8 |
import gdown
|
9 |
from PIL import Image
|
10 |
import io
|
11 |
-
import http.client
|
12 |
|
13 |
-
http.client.HTTPConnection._http_vsn = 10
|
14 |
-
http.client.HTTPConnection._http_vsn_str = 'HTTP/1.0'
|
15 |
|
16 |
class EndpointHandler:
|
17 |
def __init__(self, path='.'): # pass api key to model
|
18 |
# current_directory = os.getcwd()
|
19 |
# print("Current working directory:", current_directory)
|
20 |
|
21 |
-
url = "https://drive.google.com/file/d/1jB8sDYYOTfuF7B1PMcDjkm5R7huv97Wm"
|
22 |
-
gdown.download(url, 'best.pt', quiet=False)
|
23 |
|
24 |
-
self.model = YOLO("best.pt")
|
25 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
26 |
inputs = data.get("inputs")
|
27 |
print("in call")
|
@@ -32,7 +32,7 @@ class EndpointHandler:
|
|
32 |
path = inputs.get("path")
|
33 |
print("is path")
|
34 |
print(path)
|
35 |
-
|
36 |
model = self.model
|
37 |
########################### Load Image #################################
|
38 |
if(isurl): # for url set isurl = 1
|
|
|
8 |
import gdown
|
9 |
from PIL import Image
|
10 |
import io
|
11 |
+
# import http.client
|
12 |
|
13 |
+
# http.client.HTTPConnection._http_vsn = 10
|
14 |
+
# http.client.HTTPConnection._http_vsn_str = 'HTTP/1.0'
|
15 |
|
16 |
class EndpointHandler:
|
17 |
def __init__(self, path='.'): # pass api key to model
|
18 |
# current_directory = os.getcwd()
|
19 |
# print("Current working directory:", current_directory)
|
20 |
|
21 |
+
url = "https://drive.google.com/file/d/1jB8sDYYOTfuF7B1PMcDjkm5R7huv97Wm/view?usp=sharing"
|
22 |
+
gdown.download(url, './best.pt', quiet=False)
|
23 |
|
24 |
+
self.model = YOLO("./best.pt")
|
25 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
26 |
inputs = data.get("inputs")
|
27 |
print("in call")
|
|
|
32 |
path = inputs.get("path")
|
33 |
print("is path")
|
34 |
print(path)
|
35 |
+
path = "http://10.10.2.100/cam-lo.jpg"
|
36 |
model = self.model
|
37 |
########################### Load Image #################################
|
38 |
if(isurl): # for url set isurl = 1
|