无法识别图像文件'/tmp/image.png'



我正在谷歌Colab上训练一个基于1的对象检测模型。在训练了模型之后,我想在新的图像上测试模型,就像在本次测试中在您的图像上的TFLite模型一样。我在运行对象检测中运行代码并显示检测结果时获得错误:

INPUT_IMAGE_URL = "https://storage.googleapis.com/cloud-ml-data/img/openimage/3/2520/3916261642_0a504acd60_o.jpg"
DETECTION_THRESHOLD = 0.3
TEMP_FILE = '/tmp/image.png'
!wget -q -O $TEMP_FILE $INPUT_IMAGE_URL
im = Image.open(TEMP_FILE)
im.thumbnail((512, 512), Image.ANTIALIAS)
im.save(TEMP_FILE, 'PNG')
# Load the TFLite model
interpreter = tf.lite.Interpreter(model_path=model_path)
interpreter.allocate_tensors()
# Run inference and draw detection result on the local copy of the original file
detection_result_image = run_odt_and_draw_results(
TEMP_FILE,
interpreter,
threshold=DETECTION_THRESHOLD
)
# Show the detection result
Image.fromarray(detection_result_image)

有人能向我解释一下以下代码部分的用途吗:

TEMP_FILE = '/tmp/image.png'
!wget -q -O $TEMP_FILE $INPUT_IMAGE_URL
im = Image.open(TEMP_FILE)
im.thumbnail((512, 512), Image.ANTIALIAS)
im.save(TEMP_FILE, 'PNG')

提前谢谢!

# define local path to save image
TEMP_FILE = '/tmp/image.png'
# In a notebook, run bash command to download image locally from URL
!wget -q -O $TEMP_FILE $INPUT_IMAGE_URL
# Open the image (with Pillow library most likely)
im = Image.open(TEMP_FILE)
# Resize it to 512*512 pixels with the antialiasing resampling algorithm 
im.thumbnail((512, 512), Image.ANTIALIAS)
# Save output image to local file
im.save(TEMP_FILE, 'PNG')

相关内容

  • 没有找到相关文章

最新更新