Closed YanqingWu closed 4 years ago
I am not very familiar with tensorflow, maybe there are some redundancy code, if then, please @me. thanks.
Thx, Your code is very useful.
Thanks @YanqingWu
If you want to benchmark the model latency, you can try this command:
python model_inspect.py --model_name=efficientdet-d0 --runmode=bm --bm_runs=100
If you want to predict a single image, here is a simple utility:
Example code is like this:
driver = inference.ServingDriver('efficientdet-d0', '/tmp/efficientdet-d0')
driver.build()
for f in tf.io.gfile.glob('/tmp/*.jpg'):
image = Image.open(f)
predictions = driver.serve(image)
out_image = driver.visualize(image, predictions[0])
I am going to close this issue for now, but if you have further question, please feel free to reopen it. Thanks!
Example code is like this:
driver = inference.ServingDriver('efficientdet-d0', '/tmp/efficientdet-d0') driver.build() for f in tf.io.gfile.glob('/tmp/*.jpg'): image = Image.open(f) predictions = driver.serve(image) out_image = driver.visualize(image, predictions[0])
I am going to close this issue for now, but if you have further question, please feel free to reopen it. Thanks!
I got this error
RuntimeError Traceback (most recent call last)
<ipython-input-48-4c96731ccaf1> in <module>()
3 import tensorflow.compat.v1 as tf
4 driver = inference.ServingDriver('efficientdet-d4', 'trained_model')
----> 5 driver.build()
6 for f in tf.io.gfile.glob('test/*.jpg'):
7 image = Image.open(f)
1 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/array_ops.py in placeholder(dtype, shape, name)
3021 """
3022 if context.executing_eagerly():
-> 3023 raise RuntimeError("tf.placeholder() is not compatible with "
3024 "eager execution.")
3025
RuntimeError: tf.placeholder() is not compatible with eager execution.
示例代码如下:
driver = inference.ServingDriver('efficientdet-d0', '/tmp/efficientdet-d0') driver.build() for f in tf.io.gfile.glob('/tmp/*.jpg'): image = Image.open(f) predictions = driver.serve(image) out_image = driver.visualize(image, predictions[0])
我将暂时关闭此问题,但是如果您还有其他问题,请随时重新打开。谢谢!
我收到这个错误
RuntimeError Traceback (most recent call last) <ipython-input-48-4c96731ccaf1> in <module>() 3 import tensorflow.compat.v1 as tf 4 driver = inference.ServingDriver('efficientdet-d4', 'trained_model') ----> 5 driver.build() 6 for f in tf.io.gfile.glob('test/*.jpg'): 7 image = Image.open(f) 1 frames /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/array_ops.py in placeholder(dtype, shape, name) 3021 """ 3022 if context.executing_eagerly(): -> 3023 raise RuntimeError("tf.placeholder() is not compatible with " 3024 "eager execution.") 3025 RuntimeError: tf.placeholder() is not compatible with eager execution.
大哥 我也遇到了同样的错误 请问你解决了吗?
Sorry for the issue. How about adding tf.compat.v1.disable_v2_behavior() at the beginning of your code?
对不起,这个问题。在代码开头添加tf.compat.v1.disable_v2_behavior()怎么样?
Very effective
one question, this code only takes into account the forward pass right. Does it also take into account the post_processing?
I have solved it by myself, besides I have tested the speed of d0 is faster than yolov3 (same img size, torch version) in 2080Ti。 blew is the source code, maybe you can test for your device, everything you need is download the checkpoint (must) and put it under the efficientdet dir:
1.first step: Download checkpoint.
cd efficientdet ipython MODEL = 'efficientdet-d0' #@param !wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco/{MODEL}.tar.gz !tar zxf {MODEL}.tar.gz
change the MODEL for d1, d2 ..., repeat
2.second step
cd efficientdet touch test.py create a new test.py file, and write the blew code, then , python test.py --model 0
3.you can also modify the code as your predict.py for your own image, other than fake image
---------------------------------- source code ---------------------------