Code Monkey home page Code Monkey logo

Comments (3)

Wovchena avatar Wovchena commented on June 2, 2024 1

Sorry, my bad. It should have been face-detection-0204

import numpy as np
import openvino as ov
import cv2

core = ov.runtime.ie_api.Core()
detection_model_xml = r"C:/Users/vzlobin/.cache/omz/intel/face-detection-0204/FP16/face-detection-0204.xml"
detection_model = core.read_model(model=detection_model_xml)
detection_input_layer = detection_model.input(0) 

new_shape = (-1, 3, 448, 448)
detection_model.reshape({detection_input_layer.any_name: new_shape})
detection_compiled_model = core.compile_model(model=detection_model, device_name="CPU")

# to run the model:
images = np.stack([
    cv2.resize(cv2.imread(r"C:/Users/vzlobin/OneDrive - Intel Corporation/a/test-data/coco128/images/train2017/000000000036.jpg"), (new_shape[3], new_shape[2])),
    cv2.resize(cv2.imread(r"C:/Users/vzlobin/OneDrive - Intel Corporation/a/test-data/coco128/images/train2017/000000000086.jpg"), (new_shape[3], new_shape[2]))
])
input_data = images.transpose(0, 3, 1, 2)
output = detection_compiled_model(input_data)
BLUE = (255, 0, 0)
for image_id, _, conf, x_min, y_min, x_max, y_max in output['detection_out'][0, 0]:
    if image_id < 0:
        break
    if conf < 0.5:
        continue
    cv2.rectangle(images[int(image_id)], [round(x_min * new_shape[3]), round(y_min * new_shape[2])], [round(x_max * new_shape[3]), round(y_max * new_shape[2])], BLUE, 2)
cv2.imshow('winname',  np.concatenate(images, 1))
cv2.waitKey(0)

from open_model_zoo.

Wovchena avatar Wovchena commented on June 2, 2024

Hi. Sorry, I missed this. Yes, face-detection-0206 isn't usable with batch. You can try other detectors, for example face-detection-0205

from open_model_zoo.

fgraffitti-cyberhawk avatar fgraffitti-cyberhawk commented on June 2, 2024

Hi. Sorry, I missed this. Yes, face-detection-0206 isn't usable with batch. You can try other detectors, for example face-detection-0205

@Wovchena thanks for your reply, it's unfortunate that the model is not usable with batch. Looks like face-detection-0205 also has the same problem, output layer is still dynamic..

from open_model_zoo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.