RobertBiehl / caffe2-ios

☕️ Caffe2Kit. A simple one step integration of Caffe2 for iOS.
Apache License 2.0
71 stars 13 forks source link

libprotobuff error #12

Open tallalj opened 7 years ago

tallalj commented 7 years ago

Report

What did you do?

Added Podfile: ` Uncomment the next line to define a global platform for your project platform :ios, '10.3'

target 'meh' do /# Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks!

/# Pods for meh pod 'Caffe2Kit', :git => 'git://github.com/RobertBiehl/caffe2-ios'

post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ENABLE_BITCODE'] = 'NO' end end end

target 'mehTests' do inherit! :search_paths /# Pods for testing end

target 'mehUITests' do inherit! :search_paths /# Pods for testing end

end ` installed pod. changed bitcode to no added libstdc++ added other linker flags of: -force_load "$(PODS_ROOT)/Caffe2Kit/install/lib/libCaffe2_CPU.a"

My view controller is same as yours: ` class ViewController: UIViewController {

@IBOutlet var textView : UITextView!
@IBOutlet var imageView : UIImageView!

var caffe : Caffe2?

override func viewDidLoad() {
    super.viewDidLoad()
    do{
     try self.caffe = Caffe2(initNetNamed: "squeeze_init_net", predictNetNamed:"squeeze_predict_net")
    }
    catch{

    }
    let 🌅 = #imageLiteral(resourceName: "lion.png")

    if let res = caffe?.prediction(regarding: 🌅) {
        // find top 5 classes
        let sorted = res
            .map{$0.floatValue}
            .enumerated()
            .sorted(by: {$0.element > $1.element})[0...5]

        // generate output
        let text = sorted
            .map{"\($0.offset): \(classes[$0.offset]) \($0.element*100)%"}
            .joined(separator: "\n")

        print("Result\n\(text)")
        textView.text = text
        imageView.image = 🌅
    }
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

}

override func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

let classes = [ has all classes trust me :D    ]

} ` I copied all the sources like lion.png etc from your git.

What did you expect to happen?

The project should run. Giving me the output just like in tutorial

What happened instead?

Instead I ended up with [libprotobuf ERROR /Users/Robert/Documents/Workspace/caffe2-swift/lib/caffe2/third_party/protobuf/src/google/protobuf/descriptor_database.cc:57] File already exists in database: caffe/proto/caffe.proto [libprotobuf FATAL /Users/Robert/Documents/Workspace/caffe2-swift/lib/caffe2/third_party/protobuf/src/google/protobuf/descriptor.cc:1272] CHECK failed: generated_database_->Add(encoded_file_descriptor, size): libc++abi.dylib: terminating with uncaught exception of type google::protobuf::FatalException: CHECK failed: generated_database_->Add(encoded_file_descriptor, size):

Project that demonstrates the issue

libsystem_kernel.dylib__pthread_kill: 0x185709330 <+0>: mov x16, #0x148 0x185709334 <+4>: svc #0x80 -> 0x185709338 <+8>: b.lo 0x185709350 ; <+32> 0x18570933c <+12>: stp x29, x30, [sp, #-0x10]! 0x185709340 <+16>: mov x29, sp 0x185709344 <+20>: bl 0x1856ea098 ; cerror_nocancel 0x185709348 <+24>: mov sp, x29 0x18570934c <+28>: ldp x29, x30, [sp], #0x10 0x185709350 <+32>: ret
` It happens before the UI even loads. I have used both simulator and device along with xcode 8 and 9. Although I do realize it is not a problem related to that but still for sanity purposes did that.

ℹ Please link to a project we can download that reproduces the issue. https://github.com/Quisher/caffe2-ios-exp