Skip to content

Commit cc73dfb

Browse files
authored
Merge pull request #42 from johnolafenwa/johnolafenwa/custommodels
Johnolafenwa/custommodels
2 parents d68ef5f + 1a0eefd commit cc73dfb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+186
-32
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,6 @@ dmypy.json
136136
.pytype/
137137

138138
# Cython debug symbols
139-
cython_debug/
139+
cython_debug/
140+
141+
*.out

Dockerfile.cpu

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM deepquestai/deepstack-base:cpu as cpu
1+
FROM deepquestai/deepstack-base:cpu-412378893 as cpu
22

33
ENV SLEEP_TIME 0.01
44
ENV CUDA_MODE False
@@ -8,11 +8,10 @@ RUN mkdir /deeptemp
88
RUN mkdir /datastore
99

1010
ENV DATA_DIR /datastore
11-
ENV TEMP_PATH /deeptemp
11+
ENV TEMP_PATH /deeptemp/
1212
ENV PROFILE desktop_cpu
1313

1414
WORKDIR /app
15-
RUN pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
1615
RUN pip install onnxruntime==0.4.0
1716

1817
RUN pip3 install redis

Dockerfile.gpu

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM deepquestai/deepstack-base:gpu as gpu
1+
FROM deepquestai/deepstack-base:gpu-412378893 as gpu
22

33
ENV SLEEP_TIME 0.01
44
ENV CUDA_MODE True
@@ -8,11 +8,10 @@ RUN mkdir /deeptemp
88
RUN mkdir /datastore
99

1010
ENV DATA_DIR /datastore
11-
ENV TEMP_PATH /deeptemp
11+
ENV TEMP_PATH /deeptemp/
1212
ENV PROFILE desktop_gpu
1313

1414
WORKDIR /app
15-
RUN pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
1615
RUN pip install onnxruntime==0.5.0
1716

1817
RUN pip3 install redis

deepstack/intelligencelayer/shared/detection.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io
66
import _thread as thread
77
from multiprocessing import Process
8-
from PIL import Image
8+
from PIL import Image,UnidentifiedImageError
99
import torch.nn.functional as F
1010
import ast
1111
import sqlite3
@@ -21,7 +21,13 @@
2121
import torchvision.transforms as transforms
2222
import traceback
2323
from PIL import UnidentifiedImageError
24+
import argparse
2425

26+
parser = argparse.ArgumentParser()
27+
parser.add_argument("--model",type=str,default=None)
28+
parser.add_argument("--name",type=str,default=None)
29+
30+
opt = parser.parse_args()
2531

2632
def objectdetection(thread_name: str, delay: float):
2733

@@ -31,9 +37,15 @@ def objectdetection(thread_name: str, delay: float):
3137
db = SharedOptions.db
3238
TEMP_PATH = SharedOptions.TEMP_PATH
3339

34-
IMAGE_QUEUE = "detection_queue"
40+
if opt.name == None:
41+
IMAGE_QUEUE = "detection_queue"
42+
else:
43+
IMAGE_QUEUE = opt.name+"_queue"
3544

36-
model_name = SharedOptions.SETTINGS.DETECTION_MODEL
45+
if opt.model == None:
46+
model_path = os.path.join(SHARED_APP_DIR,SharedOptions.SETTINGS.DETECTION_MODEL)
47+
else:
48+
model_path = opt.model
3749

3850
if MODE == "High":
3951

@@ -47,7 +59,7 @@ def objectdetection(thread_name: str, delay: float):
4759

4860
reso = SharedOptions.SETTINGS.DETECTION_LOW
4961

50-
detector = YOLODetector(os.path.join(SHARED_APP_DIR,model_name),reso,cuda=CUDA_MODE)
62+
detector = YOLODetector(model_path,reso,cuda=CUDA_MODE)
5163
while True:
5264
queue = db.lrange(IMAGE_QUEUE,0,0)
5365

@@ -86,8 +98,8 @@ def objectdetection(thread_name: str, delay: float):
8698

8799
outputs.append(detection)
88100

89-
response = {"success":True,"predictions":outputs}
90-
101+
output = {"success":True,"predictions":outputs}
102+
91103
except UnidentifiedImageError:
92104
err_trace = traceback.format_exc()
93105
print(err_trace,file=sys.stderr,flush=True)

deepstack/intelligencelayer/shared/face.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ def face(thread_name,delay):
388388

389389
output = {"success":False, "error":"error occured on the server","code":500}
390390

391-
finally:
392-
SharedOptions.db.set(req_id,json.dumps(output))
391+
finally:
392+
SharedOptions.db.set(req_id,json.dumps(output))
393393

394394
if os.path.exists(SharedOptions.TEMP_PATH+img_id):
395395
os.remove(SharedOptions.TEMP_PATH+img_id)

deepstack/intelligencelayer/shared/scene.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io
66
import _thread as thread
77
from multiprocessing import Process
8-
from PIL import Image
8+
from PIL import Image,UnidentifiedImageError
99
import torch.nn.functional as F
1010
import ast
1111
import sqlite3
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)