|
27 | 27 | [170, 0, 255], [255, 0, 255], [255, 0, 170], [255, 0, 85]]
|
28 | 28 |
|
29 | 29 |
|
30 |
| -def process (input_image, params): |
31 |
| - oriImg = cv2.imread(input_image) # B,G,R order |
32 |
| - print (oriImg.shape[0], params.width) |
| 30 | + |
| 31 | + |
| 32 | +def process (input_image, params, model): |
| 33 | + |
| 34 | + oriImg = input_image |
| 35 | + if isinstance(input_image, str): |
| 36 | + oriImg = cv2.imread(input_image) # B,G,R order |
| 37 | + |
33 | 38 | multiplier = [x * params.width / oriImg.shape[0] for x in params.scale_search]
|
34 | 39 |
|
35 | 40 | heatmap_avg = np.zeros((oriImg.shape[0], oriImg.shape[1], 19))
|
@@ -201,11 +206,9 @@ def process (input_image, params):
|
201 | 206 | subset = np.delete(subset, deleteIdx, axis=0)
|
202 | 207 | flat = [0.0 for i in range(36)]
|
203 | 208 | dc = {"people":[]}
|
204 |
| - canvas = cv2.imread(input_image) # B,G,R order |
| 209 | + canvas = oriImg # B,G,R order |
205 | 210 | for i in range(18):
|
206 | 211 | for j in range(len(all_peaks[i])):
|
207 |
| - print (all_peaks[i][j][0:2]) |
208 |
| - |
209 | 212 | flat[i*2] = int(all_peaks[i][j][0:2][0])
|
210 | 213 | flat[i*2+1] = int(all_peaks[i][j][0:2][1])
|
211 | 214 | cv2.circle(canvas, all_peaks[i][j][0:2], 4, colors[i], thickness=-1)
|
@@ -248,12 +251,12 @@ def process (input_image, params):
|
248 | 251 | # load model
|
249 | 252 | # authors of original model don't use
|
250 | 253 | # vgg normalization (subtracting mean) on input images
|
| 254 | + |
251 | 255 | model = get_testing_model(38,19)
|
252 | 256 | model.load_weights(keras_weights_file)
|
253 |
| - |
254 | 257 | # load config
|
255 | 258 | _config = config.GetConfig("Canonical")
|
256 |
| - canvas, pose_keypoints = process(input_image, _config) |
| 259 | + canvas, pose_keypoints = process(input_image, _config, model) |
257 | 260 |
|
258 | 261 | toc = time.time()
|
259 | 262 | print ('processing time is %.5f' % (toc - tic))
|
|
0 commit comments