(venv) $ python
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2021-05-16 10:32:40.455671:
E tensorflow/core/platform/hadoop/hadoop_file_system.cc:132]
HadoopFileSystem load error: libhdfs.so:
cannot open shared object file: No such file or directory
>>> import cv2
>>> import sys
>>> from core.utils import load_class_names, load_image, draw_boxes, draw_boxes_frame
>>> from core.yolo_tiny import YOLOv3_tiny
>>> from core.yolo import YOLOv3
>>> class_names, n_classes = load_class_names()
>>> iou_threshold = 0.1
>>> confidence_threshold = 0.25
>>>
>>> model = YOLOv3_tiny(n_classes=n_classes,
... iou_threshold=iou_threshold,
... confidence_threshold=confidence_threshold)
>>> inputs = tf.placeholder(tf.float32, [1, *model.input_size, 3])
>>> detections = model(inputs)
WARNING:tensorflow:From /home/pi/Tensorflow-YOLOv3/core/yolo_tiny.py:76:
The name tf.variable_scope is deprecated.
Please use tf.compat.v1.variable_scope instead.
WARNING:tensorflow:From /home/pi/Tensorflow-YOLOv3/core/layers.py:25:
The name tf.layers.Conv2D is deprecated.
Please use tf.compat.v1.layers.Conv2D instead.
WARNING:tensorflow:From /home/pi/Tensorflow-YOLOv3/core/layers.py:34:
The name tf.layers.BatchNormalization is deprecated.
Please use tf.compat.v1.layers.BatchNormalization instead.
WARNING:tensorflow:From /home/pi/Tensorflow-YOLOv3/core/layers.py:41:
The name tf.layers.MaxPooling2D is deprecated.
Please use tf.compat.v1.layers.MaxPooling2D instead.
WARNING:tensorflow:From /home/pi/Tensorflow-YOLOv3/core/layers.py:97:
The name tf.image.resize_nearest_neighbor is deprecated.
Please use tf.compat.v1.image.resize_nearest_neighbor instead.
>>> saver = tf.train.Saver(tf.global_variables(scope=model.scope))
>>> with tf.Session() as sess:
... saver.restore(sess, './weights/model-tiny.ckpt')
... cap = cv2.VideoCapture(0)
... while True:
... ret, frame = cap.read()
... frame_size = (frame.shape[1], frame.shape[0])
... resized_frame = cv2.resize(frame, dsize=tuple((x) for x in model.input_size[::-1]),
... interpolation=cv2.INTER_NEAREST)
... result = sess.run(detections, feed_dict={inputs: [resized_frame]})
... draw_boxes_frame(frame, frame_size, result, class_names, model.input_size)
... cv2.imshow('frame', frame)
... if cv2.waitKey(1) & 0xFF == ord('q'):
... break
... cap.release()
... cv2.destroyAllWindows()
...
INFO:tensorflow:Restoring parameters from ./weights/model-tiny.ckpt
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
(カメラ映像の Xウィンドウが開く)
|