application.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:visimil 作者: rene4jazz 项目源码 文件源码
def get_features(url):
    response = requests.get(url)
    img = Image.open(BytesIO(response.content)).convert('RGB')

    target_size = (224, 224)
    model = VGG16(weights='imagenet', include_top=False, pooling='avg')

    if img.size != target_size:
        img = img.resize(target_size)

    x = image.img_to_array(img)
    x = np.expand_dims(x, axis=0)
    x = preprocess_input(x)
    features = model.predict(x).flatten()
    return features.tolist()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号