Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Weird Image classification results ONLY on iOS, using ios-demo-app framework #17

Closed
dorcatty opened this issue May 16, 2020 · 1 comment

Comments

@dorcatty
Copy link

Dear pytorch geeks, I got a weird Image Classification result using this ios-demo-app xcodeproject (both HelloWorld and also Pytorch Demo), please figure me out where is the issue. thanks!!!

what i did:

  • train a dataset (40 classifications) with Pytorch 1.5.0 with Transfer Learning (with resnet18), a traced 'mymodel.pt' is generated. acc=99%
  • tested with some input images (e.g.FigureA.jpg) with traced 'mymodel.pt' , the image classification is perfect!
    issue is coming->?>?>?>?>?>?>?>
  • replace the original mobilenet v2 .pt and words.txt in the HelloWorld project with my traced 'mymodel.pt' and 'mywords.txt'
  • the classification result. (e.g. FigureA.jpg) is completely wrong on simulator and iPhone device
    However, the classificaiton of FigureA.jpg is correct on my MacOS.
    How it is possible ?
    this issue blocks me since 1 month ago.

thanks a lot !!

@dorcatty
Copy link
Author

I have figured out where is the problem.
i double checked the predict output of Desktop and iOS, the torch.max gives the same tensor value(more or less same)
But in iOS, the label.txt should be generated along with PyTorch learning process.
I manually created a label.txt, like:
Class1
Class2
Class3
...
However, during the PyTorch learning process, with the dataloader, the class_name should be shuffled. So, just replace the shuffled label.txt with manually generated label.txt in XCODE project should be fine!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant