Giter Site home page Giter Site logo

dev2devdeeplearningsample's Introduction

端到端的图像识别样例(Flask)

环境

  • tensorflow2.7
  • pillow
  • Flask
  • numpy、pandas、requests

ps: 该测试使用了GPU、如果不需要请设置model里的GPU调用为false

快速开始

  • 服务端

    python flasker.py
  • 客户端

    请求发起代码在client中、按照Jupyter中代码顺序运行即可

神经网络模型

  • 简介: 使用了cifar10数据集合,模型由 3层卷积(Conv2D)、两层池化(maxpooling)、一层全连接构成

  • 模型代码放在model/ 下,拥有独立的README文档

  • model/predict中代码是为Flask准备的接口

  • 模型可预测标签共十类:

    'airplane', 'automobile', 'bird', 'cat', 'deer','dog', 'frog', 'horse', 'ship', 'truck'
    

特别注意

  • 如果没有GPU使用需求请将代码中含有

    gpus = tf.config.experimental.list_physical_devices('GPU')
    if gpus:
        # Restrict TensorFlow to only allocate 1GB of memory on the first GPU
        try:
            tf.config.experimental.set_virtual_device_configuration(
                gpus[0],
                [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=1024*2)])
            logical_gpus = tf.config.experimental.list_logical_devices('GPU')
            print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
        except RuntimeError as e:
          # Virtual devices must be set before GPUs have been initialized
            print(e)

    替换为:

    tf.device('/CPU:0')

dev2devdeeplearningsample's People

Contributors

sixone-jiang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.