Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Machine Learning by (33.1k points)

I have an Android app that was modeled after the Tensorflow Android demo for classifying images,

https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android

The original app uses a tensorflow graph (.pb) file to classify a generic set of images from Inception v3 (I think)

I then trained my own graph for my own images following the instruction in Tensorflow for Poets blog,

https://petewarden.com/2016/02/28/tensorflow-for-poets/

and this worked in the Android app very well, after changing the settings in,

ClassifierActivity

private static final int INPUT_SIZE = 299;

private static final int IMAGE_MEAN = 128;

private static final float IMAGE_STD = 128.0f;

private static final String INPUT_NAME = "Mul";

private static final String OUTPUT_NAME = "final_result";

private static final String MODEL_FILE = "file:///android_asset/optimized_graph.pb";

private static final String LABEL_FILE =  "file:///android_asset/retrained_labels.txt";

To port the app to iOS, I then used the iOS camera demo, https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/ios/camera

and used the same graph file and changed the settings in,

CameraExampleViewController.mm

Not sure if this is the best way to resize, but this worked. But it seemed to make image classification even worse, not better...

Any ideas, or issues with the image conversion/resize?

1 Answer

0 votes
by (33.1k points)

For your problem, if I say you can use the NLTK library, then I’d also want to say that there is not any perfect method in machine learning that can fit your model properly. So you have to try some different techniques also to get the best accuracy on unknown data.

There is a class in NLTK called perceptron tagger, which can help your model to return correct parts of speech.

>>> import inspect 

>>> print inspect.getsource(pos_tag) 

def pos_tag(tokens, tagset=None): 

tagger = PerceptronTagger() 

return _pos_tag(tokens, tagset, tagger)

Still, it's better but not perfect:

>>> from nltk import pos_tag 

>>> pos_tag("The quick brown fox jumps over the lazy dog".split())

[('The', 'DT'), ('quick', 'JJ'), ('brown', 'NN'), ('fox', 'NN'), ('jumps', 'VBZ'), ('over', 'IN'), ('the', 'DT'), ('lazy', 'JJ'), ('dog', 'NN')]

The above code will improve the output of your model.

I hope this answer helps.

Browse Categories

...