emedvedev / attention-ocr

A Tensorflow model for text recognition (CNN + seq2seq with visual attention) available as a Python package and compatible with Google Cloud ML Engine.
MIT License
1.08k stars 256 forks source link

different output at exported model V2 #139

Closed kspook closed 5 years ago

kspook commented 5 years ago

@emedvedev , I had different output at exported model.

I tried to Koreans replacing with ASCII values when I made tfrecords file.

    if c=='하':      
        c='!'
    elif c=='나':
        c='#'
    elif c=='우':
        c='$'
    elif c=='리':
        c='%'
    elif c=='국':
        c='&'
    elif c=='민':
        c='(' 
    elif c=='신':
        c=')'
    elif c=='한':
        c='*'
    elif c=='기':
        c='+'
    elif c=='업':
        c='.'
    elif c=='농':
        c='?'
    elif c=='협': 
        c='@'
    else: c=c

But, it has different output. In curl, it returns "W". In the scrip, it produce 1 like the below log. Can you guess what's the problem? In case of #135, I changed a lot. But here I almost didn't change.

131 issued is applied, but return different value.


(py37g) PS>python .\aocr\__main__.py predict
2019-06-24 01:59:46.063512: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2019-06-24 01:59:46.254786: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties:
name: GeForce RTX 2080 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.545
pciBusID: 0000:01:00.0
totalMemory: 11.00GiB freeMemory: 9.03GiB
2019-06-24 01:59:46.368405: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 1 with properties:
name: GeForce RTX 2080 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.545
pciBusID: 0000:02:00.0
totalMemory: 11.00GiB freeMemory: 9.03GiB
2019-06-24 01:59:46.374181: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0, 1
2019-06-24 01:59:47.146893: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-06-24 01:59:47.150042: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0 1
2019-06-24 01:59:47.152398: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N N
2019-06-24 01:59:47.154438: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 1:   N N
2019-06-24 01:59:47.156605: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8698 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2080 Ti, pci bus id: 0000:01:00.0, compute capability: 7.5)
2019-06-24 01:59:47.163194: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 8699 MB memory) -> physical GPU (device: 1, name: GeForce RTX 2080 Ti, pci bus id: 0000:02:00.0, compute capability: 7.5)
2019-06-24 01:59:47,167 root  INFO     phase: predict
2019-06-24 01:59:47,167 root  INFO     model_dir: ./checkpoints
2019-06-24 01:59:47,167 root  INFO     load_model: True
2019-06-24 01:59:47,167 root  INFO     output_dir: ./results
2019-06-24 01:59:47,167 root  INFO     steps_per_checkpoint: 0
2019-06-24 01:59:47,167 root  INFO     batch_size: 1
2019-06-24 01:59:47,167 root  INFO     learning_rate: 1.000000
2019-06-24 01:59:47,167 root  INFO     reg_val: 0
2019-06-24 01:59:47,167 root  INFO     max_gradient_norm: 5.000000
2019-06-24 01:59:47,167 root  INFO     clip_gradients: True
2019-06-24 01:59:47,167 root  INFO     max_image_width 160.000000
2019-06-24 01:59:47,167 root  INFO     max_prediction_length 8.000000
2019-06-24 01:59:47,167 root  INFO     channels: 1
2019-06-24 01:59:47,167 root  INFO     target_embedding_size: 10.000000
2019-06-24 01:59:47,167 root  INFO     attn_num_hidden: 128
2019-06-24 01:59:47,167 root  INFO     attn_num_layers: 2
2019-06-24 01:59:47,167 root  INFO     visualize: False
2019-06-24 01:59:48,494 root  INFO     Reading model parameters from ./checkpoints\model.ckpt-909723
dataset/test-img3/1.jpeg
2019-06-24 01:59:57.995124: I tensorflow/stream_executor/dso_loader.cc:152] successfully opened CUDA library cublas64_100.dll locally
2019-06-24 01:59:59,655 root  INFO     Result: OK. 1.00 I

(base) kspook@kspook-ROG-MAXIMUS-XI-HERO:~/aocrKRwin0528$ curl -X POST \
>   http://localhost:9002/v1/models/aocr:predict \
>   -H 'cache-control: no-cache' \
>   -H 'content-type: application/json' \
>   -d '{
>   "signature_name": "serving_default",
>   "inputs":
>     {
>     "input": { "b64": "/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAOaADAAQAAAABAAAAHAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgAHAA5AwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMACAYGBwYFCAcHBwkJCAoMFA0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