2
2
from rest_framework import views , status
3
3
from rest_framework .response import Response
4
4
from corelib .facenet .utils import (getnewuniquefilename )
5
- from .main_api import (facerecogniseinimage , facerecogniseinvideo ,
5
+ from corelib .main_api import (facerecogniseinimage , facerecogniseinvideo ,
6
6
createembedding , process_streaming_video ,
7
7
nsfwclassifier , similarface , object_detect ,
8
8
text_detect , object_detect_video , scene_detect ,
@@ -47,50 +47,51 @@ def post(self, request):
47
47
return Response (result , status = status .HTTP_400_BAD_REQUEST )
48
48
49
49
50
- class SceneDetect (views .APIView ):
51
- """ To classify scene in an image
50
+ class SceneTextVideo (views .APIView ):
51
+ """ To localize and recognise text in a video
52
52
Workflow
53
53
* if POST method request is made, then initially a random
54
- filename is generated and then scene_detect method is
55
- called which process the image and outputs the result
56
- containing the dictionary of probability of type of
57
- scene in the image
54
+ filename is generated and then text_detect_video method
55
+ is called which process the video and outputs the result
56
+ containing the dictionary of detected text and bounding
57
+ boxes of the text for each frame
58
58
Returns:
59
- * output dictionary of detected scenes and probabilities
60
- of scenes in image
59
+ * output dictionary of detected text and bounding
60
+ boxes of the text for each frame of the video
61
61
"""
62
62
63
63
def post (self , request ):
64
64
65
- logger .info (msg = "POST Request for Scene Detection made" )
65
+ logger .info (msg = "POST Request for Scene Text Extraction in video made" )
66
66
filename = getnewuniquefilename (request )
67
67
input_file = request .FILES ['file' ]
68
- result = scene_detect (input_file , filename )
68
+ result = text_detect_video (input_file , filename )
69
69
if "Error" not in result :
70
70
return Response (result , status = status .HTTP_200_OK )
71
71
else :
72
72
return Response (result , status = status .HTTP_400_BAD_REQUEST )
73
73
74
74
75
- class SceneTextVideo (views .APIView ):
76
- """ To localize and recognise text in a video
75
+ class NsfwRecognise (views .APIView ):
76
+ """ To recognise whether a image is nsfw or not
77
+
77
78
Workflow
78
79
* if POST method request is made, then initially a random
79
- filename is generated and then text_detect_video method
80
- is called which process the video and outputs the result
81
- containing the dictionary of detected text and bounding
82
- boxes of the text for each frame
80
+ filename is generated and then nsfwclassifier method is
81
+ called which process the image and outputs the result
82
+ containing the dictionary of probability of type of content
83
+ in the image
84
+
83
85
Returns:
84
- * output dictionary of detected text and bounding
85
- boxes of the text for each frame of the video
86
+ * output dictionary of probability content in the image
86
87
"""
87
88
88
89
def post (self , request ):
89
90
90
- logger .info (msg = "POST Request for Scene Text Extraction in video made" )
91
+ logger .info (msg = "POST Request for NSFW Classification made" )
91
92
filename = getnewuniquefilename (request )
92
93
input_file = request .FILES ['file' ]
93
- result = text_detect_video (input_file , filename )
94
+ result = nsfwclassifier (input_file , filename )
94
95
if "Error" not in result :
95
96
return Response (result , status = status .HTTP_200_OK )
96
97
else :
@@ -122,6 +123,31 @@ def post(self, request):
122
123
return Response (result , status = status .HTTP_400_BAD_REQUEST )
123
124
124
125
126
+ class SceneDetect (views .APIView ):
127
+ """ To classify scene in an image
128
+ Workflow
129
+ * if POST method request is made, then initially a random
130
+ filename is generated and then scene_detect method is
131
+ called which process the image and outputs the result
132
+ containing the dictionary of probability of type of
133
+ scene in the image
134
+ Returns:
135
+ * output dictionary of detected scenes and probabilities
136
+ of scenes in image
137
+ """
138
+
139
+ def post (self , request ):
140
+
141
+ logger .info (msg = "POST Request for Scene Detection made" )
142
+ filename = getnewuniquefilename (request )
143
+ input_file = request .FILES ['file' ]
144
+ result = scene_detect (input_file , filename )
145
+ if "Error" not in result :
146
+ return Response (result , status = status .HTTP_200_OK )
147
+ else :
148
+ return Response (result , status = status .HTTP_400_BAD_REQUEST )
149
+
150
+
125
151
class SceneVideo (views .APIView ):
126
152
""" To classify scenes video
127
153
Workflow
@@ -188,32 +214,6 @@ def post(self, request):
188
214
status = status .HTTP_400_BAD_REQUEST )
189
215
190
216
191
- class NsfwRecognise (views .APIView ):
192
- """ To recognise whether a image is nsfw or not
193
-
194
- Workflow
195
- * if POST method request is made, then initially a random
196
- filename is generated and then nsfwclassifier method is
197
- called which process the image and outputs the result
198
- containing the dictionary of probability of type of content
199
- in the image
200
-
201
- Returns:
202
- * output dictionary of probability content in the image
203
- """
204
-
205
- def post (self , request ):
206
-
207
- logger .info (msg = "POST Request for NSFW Classification made" )
208
- filename = getnewuniquefilename (request )
209
- input_file = request .FILES ['file' ]
210
- result = nsfwclassifier (input_file , filename )
211
- if "Error" not in result :
212
- return Response (result , status = status .HTTP_200_OK )
213
- else :
214
- return Response (result , status = status .HTTP_400_BAD_REQUEST )
215
-
216
-
217
217
class VideoFr (views .APIView ):
218
218
""" To recognise faces in video
219
219
@@ -523,4 +523,4 @@ def post(self, request):
523
523
if "Error" not in result :
524
524
return Response (result , status = status .HTTP_200_OK )
525
525
else :
526
- return Response (result , status = status .HTTP_400_BAD_REQUEST )
526
+ return Response (result , status = status .HTTP_400_BAD_REQUEST )
0 commit comments