Closed kecaiwu closed 6 years ago
I have this problem when running demo for my own image. The error message is the same as yours. I change the IMAGE_MIN_DIM IMAGE_MAX_DIM in config.py to make your image size between the two variables. Maybe you can have a try.
Better solution is definitely to use Python3.4+ (see requirements) :wink:
Got the same issue using Python2.7 instead of Python3. It's due to the behavior of the round()
function. In Python2.7 it's returning a floating number. You need to change line 394 in utils.py by " image, (int(round(h scale)), int(round(w scale)))) "
You should also have an issue when dividing 2 integers line385 and 390. You need to force Python2.7 to cast your integers to float before dividing (ex. scale = max(1, float(min_dim) / float(min(h, w)))
. Since this kind of issue is most of the time silent, I don't know how to chase them in the code.
Thanks @Caunil . Closing the issue.
@kecaiwu,
To have the code run on Python2.7:
1) In utils.py
, change resize_image
as indicated by @Caunil;
2) In model.py
, change lines: https://github.com/matterport/Mask_RCNN/blob/cbc21f65c25ffd8e5fea753f58d74d2faede7d64/model.py#L2281-L2282 to
h_scale = float(image_shape[0]) / (window[2] - window[0])
w_scale = float(image_shape[1]) / (window[3] - window[1])
w.addch(tail[0], tail[0], '')
TypeError: integer argument expected, got float
What To Do????
create_database.py import cv2, sys, numpy, os, time
count = 0 size = 4 fn_haar = 'haarcascade_frontalface_default.xml' fn_dir = 'database' fn_name = sys.argv[0]
path = os.path.join(fn_dir, fn_name) if not os.path.isdir('C:/Users/Abrar Haider Rajput/Documents/faces/user'): os.mkdir(path) (im_width, im_height) = (112, 92) haar_cascade = cv2.CascadeClassifier(fn_haar) webcam = cv2.VideoCapture(0)
print "-----------------------Taking pictures----------------------" print "--------------------Give some expressions---------------------"
while count < 45: (rval, im) = webcam.read() im = cv2.flip(im, 1, 0) gray: None = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) mini = (cv2.resize(gray, (gray.shape[1] / size, gray.shape[0] / size))) faces = haar_cascade.detectMultiScale(mini) faces = sorted(faces, key=lambda x: x[3]) if faces: face_i = faces[0] (x, y, w, h) = [v * size for v in face_i] face = gray[y:y + h, x:x + w] face_resize = cv2.resize(face, (im_width, im_height)) pin = sorted([int(n[:n.find('.')]) for n in os.listdir(path) if n[0] != '.'] + [0])[-1] + 1 cv2.imwrite('%s/%s.png' % (path, pin), face_resize) cv2.rectangle(im, (x, y), (x + w, y + h), (0, 255, 0), 3) cv2.putText(im, fn_name, (x - 10, y - 10), cv2.FONT_HERSHEY_PLAIN, 1, (0, 255, 0)) time.sleep(0.38) count += 1
cv2.imshow('OpenCV', im)
key = cv2.waitKey(10)
if key == 27:
break
print str(count) + " images taken and saved to " + fn_name + " folder in database "
Traceback (most recent call last):
File "C:/Users/Abrar Haider Rajput/.PyCharmCE2019.2/config/scratches/scratch.py", line 27, in
I read the image from the images folder, and everything is ok. However, when read the '12283150_12d37e6389_z.jpg', I get the error, can you provide some advice?
Processing 1 images image shape: (375, 500, 3) min: 0.00000 max: 255.00000
TypeError Traceback (most recent call last)