Comments (5)
Thanks for the question. I want to make sure I understand what you're trying to do. (While also confessing I will need to page many details about the code back into my brain.)
Do you just want (1) an easy way to map from a list of image paths to the predicted strings (i.e., piped to standard output), or do you actually (2) want the tensor of images packed together as input (i.e., you'll need the sequence lengths, too) and run a single GPU-parallel inference on them, producing the prediction sequences (i.e. as a sparse tensor)?
Both should be possible, but the second may require deriving some new client code for the Estimator that blends elements of validate.py
and test.py
.
from cnn_lstm_ctc_ocr.
Hello Jerod @weinman. Definitely the (2), the tensor of images packed together as input and run a single GPU-parallel inference on them, producing the prediction sequences (i.e. as a sparse tensor). Thank you for your help to understand how it could be achieved.
from cnn_lstm_ctc_ocr.
Well, it should be possible without too much trouble, I hope.
I note that both model_fn.predict_fn (used for validate.py
to predict strings) and model_fn.evaluate_fn use the same underlying processing that can handle batched inputs (namely, calls to model_fn.get_output.
When I try a simple/dummy example taking the batched dataset from train.py
and putting it through the predictor, i.e.,
# both from cnn_lstm_ctc_ocr/src
import model_fn
import train
classifier = tf.estimator.Estimator(
model_fn=model_fn.predict_fn(
None,None), # no lexicon or prior weight
model_dir='/tmp/model' )
predictions = classifier.predict( input_fn=train._get_input )
results = next(predictions)
it still seems to gives me a single (unbatched) example.
I don't have more time right now to test this out further (determining what I'm probably doing wrong), but if you can get a batched tensor into model_fn.predict_fn
I think it just might work as you would want. (Or at least be a start for doing so...)
from cnn_lstm_ctc_ocr.
Thank you so much Jerod @weinman. I will take over from here. Will check in PR as soon as I get it working.
from cnn_lstm_ctc_ocr.
As a quick follow-up before I completely lose track of this thread. The confusing issue that stymied me was that I thought the underlying tensors should be producing batched outputs, even in predict mode.
I thought this because the following test seems to indicate so:
import tensorflow as tf
from tensorflow.contrib import learn
import model_fn
import train
ds = train._get_input()
[features,labels]=tf.data.make_one_shot_iterator(ds).get_next()
mode = learn.ModeKeys.EVAL
logits, sequence_length = model_fn._get_image_info(features, mode)
predictions, log_probs = model_fn._get_output( logits, sequence_length, None, None ) # no lexicon or prior weight
with tf.Session() as sess:
tf.initialize_all_variables().run()
[logit,pred] = sess.run([logits,predictions])
print(logit.shape)
print(pred[0].dense_shape)
Using the simple tfrecord file included in the repo, for me this produces:
(60, 32, 63)
[32 25]
which seems to indicate the full batch (size 32) is being produced.
I don't know if that helps, but I hope you figure out what you're looking for. I think it would be useful for others as well.
from cnn_lstm_ctc_ocr.
Related Issues (20)
- Training error HOT 9
- How to deal with single character input HOT 2
- Using Multiple GPU as a train_device HOT 3
- ctc_loss_calculator.cc Not a valid path HOT 3
- are there any pretrain model file HOT 3
- Input shapes: [72,357,1], [4] and with input tensors computed HOT 3
- It's possible to use a pre-trained model? HOT 1
- CuDnn 7.2.1 HOT 1
- get not good result, HOT 2
- FineTune ! HOT 3
- Model learns nothing about certain characters. HOT 1
- TypeError HOT 4
- Fixed sequence length HOT 1
- Training Error when using my data HOT 1
- 0% GPU-Util when testing HOT 1
- Train on vertical patches HOT 1
- Question Regarding End Model HOT 3
- confidence on sess passing HOT 6
- How to convert .ckpt model to SavedModel .pb format for hosting with Tensorflow Model Serving? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cnn_lstm_ctc_ocr.