diff --git a/.gitignore b/.gitignore index 8e4725d6ac91a4680c78ebf0e03a867521ba93d2..68380e97ab92a0632675a709836d19be669de89d 100644 --- a/.gitignore +++ b/.gitignore @@ -96,3 +96,7 @@ metal/paddle-mobile/paddle-mobile/CPU/libpaddle-mobile.a metal/paddle-mobile-demo/paddle-mobile-demo/images metal/paddle-mobile-demo/paddle-mobile-demo/models +metal/paddle-mobile-demo/paddle-mobile-demo/Resources +metal/paddle-mobile-demo/paddle-mobile-demo/Resources/images +metal/paddle-mobile-demo/paddle-mobile-demo/Resources/models +metal/MobileNetDemo/MobileNetDemo/Resources diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e33b715093d5ede1cb92641533fe42c2f25f831..9f956960fe0beed64592bbd115b9b434c5df3206 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,20 @@ cmake_minimum_required(VERSION 3.0.0) -option(USE_OPENMP "openmp support" ON) -option(DEBUGING "enable debug mode" ON) -option(USE_EXCEPTION "use std exception" ON) -option(SYMBOL_HIDDEN "symbol hidden" OFF) # on when use jni or ios io -option(LOG_PROFILE "log profile" OFF) +option(USE_OPENMP "build with openmp support" ON) +option(USE_EXCEPTION "build with exception" ON) +option(WITH_LOGGING "print logging for debug" ON) +option(WITH_SYMBOL "build with all symbols" ON) # turn off if use jni or ios io +option(WITH_PROFILE "print op profile for debug" OFF) +option(WITH_TEST "build with unit tests" ON) # select the platform to build -option(CPU "armv7 with neon" ON) -option(GPU_MALI "mali gpu" OFF) -option(GPU_CL "opencl gpu" OFF) - -option(FPGA "fpga" OFF) +option(CPU "build with arm CPU support" ON) +option(GPU_MALI "build with arm mali GPU support" OFF) +option(GPU_CL "build with OpenCL support" OFF) +option(FPGA "build with FPGA support" OFF) if(FPGA) - option(FPGAV1 "fpga v1" ON) - option(FPGAV2 "fpga v2" OFF) + option(FPGAV1 "build with fpga v1 support" ON) + option(FPGAV2 "build with fpga v2 support" OFF) endif() project(paddle-mobile) @@ -23,7 +23,6 @@ file(GLOB_RECURSE PADDLE_MOBILE_CC src/*.cc src/*.cpp src/*.c src/*.mm) file(GLOB_RECURSE PADDLE_MOBILE_H src/*.h) include_directories(src/) -set(CMAKE_BUILD_TYPE Release) set(CMAKE_CXX_FLAGS "-O3 -s -DNDEBUG ${CMAKE_CXX_FLAGS}") if(IS_IOS) set(CMAKE_CXX_FLAGS "-mfpu=neon -marm -fobjc-abi-version=2 -fobjc-arc \ @@ -33,13 +32,18 @@ else() set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") endif() -if(DEBUGING) +if(USE_OPENMP) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") + add_definitions(-DPADDLE_MOBILE_USE_OPENMP) +endif() + +if(WITH_LOGGING) message(STATUS "debugging mode") add_definitions(-DPADDLE_MOBILE_DEBUG) else() endif() -if(SYMBOL_HIDDEN) +if(NOT WITH_SYMBOL) add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden) endif() @@ -50,15 +54,10 @@ else() add_definitions(-fno-exceptions) endif() -if(LOG_PROFILE) +if(WITH_PROFILE) add_definitions(-DPADDLE_MOBILE_PROFILE) endif() -if(USE_OPENMP) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") - add_definitions(-DPADDLE_MOBILE_USE_OPENMP) -endif() - # platform control if(ARM_LINUX) include("${CMAKE_CURRENT_LIST_DIR}/tools/arm-platform.cmake") @@ -217,7 +216,6 @@ endif() set_property(CACHE NET PROPERTY STRINGS "default" "googlenet" "mobilenet" "yolo" "squeezenet" "FPGA_NET_V1" "FPGA_NET_V2" "NLP") include("${CMAKE_CURRENT_LIST_DIR}/tools/op.cmake") - # build library if(ANDROID_NDK_TOOLCHAIN_INCLUDED) list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS) @@ -239,7 +237,7 @@ else() endif() # unit test -if(DEBUGING) +if(WITH_TEST AND WITH_SYMBOL) if(IS_IOS) else() add_subdirectory(test) diff --git a/metal/MobileNetDemo/MobileNetDemo.xcodeproj/project.pbxproj b/metal/MobileNetDemo/MobileNetDemo.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..5596c6f0a24471b42e7aedf48db84384b1042e5c --- /dev/null +++ b/metal/MobileNetDemo/MobileNetDemo.xcodeproj/project.pbxproj @@ -0,0 +1,498 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + FA37E99B9AD29A07FEE8E743 /* Pods_MobileNetDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD3A2E3175627EF63DACA36C /* Pods_MobileNetDemo.framework */; }; + FC74BB3621DFAFEC0055232B /* MobileNet.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC74BB3521DFAFEC0055232B /* MobileNet.swift */; }; + FCB40DA221E0B7C60075EC91 /* MobilenetPreProcess.metal in Sources */ = {isa = PBXBuildFile; fileRef = FCB40DA121E0B7C60075EC91 /* MobilenetPreProcess.metal */; }; + FCB40DA421E0B85B0075EC91 /* MetalHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCB40DA321E0B85B0075EC91 /* MetalHelper.swift */; }; + FCB40DE921E0B9410075EC91 /* banana.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FCB40DD221E0B9410075EC91 /* banana.jpeg */; }; + FCB40E5121E0CEBB0075EC91 /* mobilenet_model in Resources */ = {isa = PBXBuildFile; fileRef = FCB40E4F21E0CEBB0075EC91 /* mobilenet_model */; }; + FCB40E5221E0CEBB0075EC91 /* mobilenet_params in Resources */ = {isa = PBXBuildFile; fileRef = FCB40E5021E0CEBB0075EC91 /* mobilenet_params */; }; + FCB40E5421E0CEF80075EC91 /* synset.txt in Resources */ = {isa = PBXBuildFile; fileRef = FCB40E5321E0CEF80075EC91 /* synset.txt */; }; + FCD3873821E1C31F0052F3D0 /* paddle_mobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCD3873721E1C31F0052F3D0 /* paddle_mobile.framework */; }; + FCD3873921E1C31F0052F3D0 /* paddle_mobile.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FCD3873721E1C31F0052F3D0 /* paddle_mobile.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + FCF2870921DFAEC7009A87DA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCF2870821DFAEC7009A87DA /* AppDelegate.swift */; }; + FCF2870B21DFAEC7009A87DA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCF2870A21DFAEC7009A87DA /* ViewController.swift */; }; + FCF2870E21DFAEC7009A87DA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FCF2870C21DFAEC7009A87DA /* Main.storyboard */; }; + FCF2871021DFAEC8009A87DA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FCF2870F21DFAEC8009A87DA /* Assets.xcassets */; }; + FCF2871321DFAEC8009A87DA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FCF2871121DFAEC8009A87DA /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + FCB40DFC21E0BC360075EC91 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + FCD3873921E1C31F0052F3D0 /* paddle_mobile.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 4FE67FF667A24FCB0134F627 /* Pods-MobileNetDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobileNetDemo.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-MobileNetDemo/Pods-MobileNetDemo.debug.xcconfig"; sourceTree = ""; }; + DD3A2E3175627EF63DACA36C /* Pods_MobileNetDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MobileNetDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + E57059FE3629E3A8DE6C7ECF /* Pods-MobileNetDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobileNetDemo.release.xcconfig"; path = "../Pods/Target Support Files/Pods-MobileNetDemo/Pods-MobileNetDemo.release.xcconfig"; sourceTree = ""; }; + FC74BB3521DFAFEC0055232B /* MobileNet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileNet.swift; sourceTree = ""; }; + FCB40DA121E0B7C60075EC91 /* MobilenetPreProcess.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = MobilenetPreProcess.metal; sourceTree = ""; }; + FCB40DA321E0B85B0075EC91 /* MetalHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MetalHelper.swift; path = "../../paddle-mobile-demo/paddle-mobile-demo/MetalHelper.swift"; sourceTree = ""; }; + FCB40DD221E0B9410075EC91 /* banana.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = banana.jpeg; sourceTree = ""; }; + FCB40E4F21E0CEBB0075EC91 /* mobilenet_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = mobilenet_model; sourceTree = ""; }; + FCB40E5021E0CEBB0075EC91 /* mobilenet_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = mobilenet_params; sourceTree = ""; }; + FCB40E5321E0CEF80075EC91 /* synset.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = synset.txt; sourceTree = ""; }; + FCD3873721E1C31F0052F3D0 /* paddle_mobile.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = paddle_mobile.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + FCF2870521DFAEC7009A87DA /* MobileNetDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MobileNetDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + FCF2870821DFAEC7009A87DA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + FCF2870A21DFAEC7009A87DA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + FCF2870D21DFAEC7009A87DA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + FCF2870F21DFAEC8009A87DA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + FCF2871221DFAEC8009A87DA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + FCF2871421DFAEC8009A87DA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + FCF2870221DFAEC7009A87DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + FCD3873821E1C31F0052F3D0 /* paddle_mobile.framework in Frameworks */, + FA37E99B9AD29A07FEE8E743 /* Pods_MobileNetDemo.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0DDBA47E92A64BC7B0385B0F /* Frameworks */ = { + isa = PBXGroup; + children = ( + DD3A2E3175627EF63DACA36C /* Pods_MobileNetDemo.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 1EACBAAF38D9EDE0AC2B3F90 /* Pods */ = { + isa = PBXGroup; + children = ( + 4FE67FF667A24FCB0134F627 /* Pods-MobileNetDemo.debug.xcconfig */, + E57059FE3629E3A8DE6C7ECF /* Pods-MobileNetDemo.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + FCB40DCF21E0B9410075EC91 /* Resources */ = { + isa = PBXGroup; + children = ( + FCB40DD021E0B9410075EC91 /* images */, + FCB40DD921E0B9410075EC91 /* models */, + ); + path = Resources; + sourceTree = ""; + }; + FCB40DD021E0B9410075EC91 /* images */ = { + isa = PBXGroup; + children = ( + FCB40DD221E0B9410075EC91 /* banana.jpeg */, + ); + path = images; + sourceTree = ""; + }; + FCB40DD921E0B9410075EC91 /* models */ = { + isa = PBXGroup; + children = ( + FCB40E4E21E0CEBB0075EC91 /* mobilenet_combine */, + ); + path = models; + sourceTree = ""; + }; + FCB40E4E21E0CEBB0075EC91 /* mobilenet_combine */ = { + isa = PBXGroup; + children = ( + FCB40E5321E0CEF80075EC91 /* synset.txt */, + FCB40E4F21E0CEBB0075EC91 /* mobilenet_model */, + FCB40E5021E0CEBB0075EC91 /* mobilenet_params */, + ); + path = mobilenet_combine; + sourceTree = ""; + }; + FCF286FC21DFAEC7009A87DA = { + isa = PBXGroup; + children = ( + FCD3873721E1C31F0052F3D0 /* paddle_mobile.framework */, + FCF2870721DFAEC7009A87DA /* MobileNetDemo */, + FCF2870621DFAEC7009A87DA /* Products */, + 1EACBAAF38D9EDE0AC2B3F90 /* Pods */, + 0DDBA47E92A64BC7B0385B0F /* Frameworks */, + ); + sourceTree = ""; + }; + FCF2870621DFAEC7009A87DA /* Products */ = { + isa = PBXGroup; + children = ( + FCF2870521DFAEC7009A87DA /* MobileNetDemo.app */, + ); + name = Products; + sourceTree = ""; + }; + FCF2870721DFAEC7009A87DA /* MobileNetDemo */ = { + isa = PBXGroup; + children = ( + FCB40DCF21E0B9410075EC91 /* Resources */, + FCB40DA321E0B85B0075EC91 /* MetalHelper.swift */, + FC74BB3521DFAFEC0055232B /* MobileNet.swift */, + FCF2870821DFAEC7009A87DA /* AppDelegate.swift */, + FCF2870A21DFAEC7009A87DA /* ViewController.swift */, + FCF2870C21DFAEC7009A87DA /* Main.storyboard */, + FCF2870F21DFAEC8009A87DA /* Assets.xcassets */, + FCF2871121DFAEC8009A87DA /* LaunchScreen.storyboard */, + FCF2871421DFAEC8009A87DA /* Info.plist */, + FCB40DA121E0B7C60075EC91 /* MobilenetPreProcess.metal */, + ); + path = MobileNetDemo; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + FCF2870421DFAEC7009A87DA /* MobileNetDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = FCF2871721DFAEC8009A87DA /* Build configuration list for PBXNativeTarget "MobileNetDemo" */; + buildPhases = ( + B4EB56AEEFF6F3965DA3D2DA /* [CP] Check Pods Manifest.lock */, + FCF2870121DFAEC7009A87DA /* Sources */, + FCF2870221DFAEC7009A87DA /* Frameworks */, + FCF2870321DFAEC7009A87DA /* Resources */, + 1D801B9681ACFCA70D444D2C /* [CP] Embed Pods Frameworks */, + FCB40DFC21E0BC360075EC91 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = MobileNetDemo; + productName = MobileNetDemo; + productReference = FCF2870521DFAEC7009A87DA /* MobileNetDemo.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + FCF286FD21DFAEC7009A87DA /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1010; + LastUpgradeCheck = 1010; + ORGANIZATIONNAME = Ray; + TargetAttributes = { + FCF2870421DFAEC7009A87DA = { + CreatedOnToolsVersion = 10.1; + }; + }; + }; + buildConfigurationList = FCF2870021DFAEC7009A87DA /* Build configuration list for PBXProject "MobileNetDemo" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = FCF286FC21DFAEC7009A87DA; + productRefGroup = FCF2870621DFAEC7009A87DA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + FCF2870421DFAEC7009A87DA /* MobileNetDemo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + FCF2870321DFAEC7009A87DA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + FCF2871321DFAEC8009A87DA /* LaunchScreen.storyboard in Resources */, + FCB40E5121E0CEBB0075EC91 /* mobilenet_model in Resources */, + FCB40DE921E0B9410075EC91 /* banana.jpeg in Resources */, + FCF2871021DFAEC8009A87DA /* Assets.xcassets in Resources */, + FCB40E5421E0CEF80075EC91 /* synset.txt in Resources */, + FCB40E5221E0CEBB0075EC91 /* mobilenet_params in Resources */, + FCF2870E21DFAEC7009A87DA /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 1D801B9681ACFCA70D444D2C /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${SRCROOT}/../Pods/Target Support Files/Pods-MobileNetDemo/Pods-MobileNetDemo-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/../Pods/Target Support Files/Pods-MobileNetDemo/Pods-MobileNetDemo-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + B4EB56AEEFF6F3965DA3D2DA /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-MobileNetDemo-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + FCF2870121DFAEC7009A87DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + FC74BB3621DFAFEC0055232B /* MobileNet.swift in Sources */, + FCB40DA421E0B85B0075EC91 /* MetalHelper.swift in Sources */, + FCB40DA221E0B7C60075EC91 /* MobilenetPreProcess.metal in Sources */, + FCF2870B21DFAEC7009A87DA /* ViewController.swift in Sources */, + FCF2870921DFAEC7009A87DA /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + FCF2870C21DFAEC7009A87DA /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + FCF2870D21DFAEC7009A87DA /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + FCF2871121DFAEC8009A87DA /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + FCF2871221DFAEC8009A87DA /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + FCF2871521DFAEC8009A87DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + FCF2871621DFAEC8009A87DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + FCF2871821DFAEC8009A87DA /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4FE67FF667A24FCB0134F627 /* Pods-MobileNetDemo.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = A798K58VVL; + INFOPLIST_FILE = MobileNetDemo/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = Ray.MobileNetDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + FCF2871921DFAEC8009A87DA /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E57059FE3629E3A8DE6C7ECF /* Pods-MobileNetDemo.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = A798K58VVL; + INFOPLIST_FILE = MobileNetDemo/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = Ray.MobileNetDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + FCF2870021DFAEC7009A87DA /* Build configuration list for PBXProject "MobileNetDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FCF2871521DFAEC8009A87DA /* Debug */, + FCF2871621DFAEC8009A87DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + FCF2871721DFAEC8009A87DA /* Build configuration list for PBXNativeTarget "MobileNetDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FCF2871821DFAEC8009A87DA /* Debug */, + FCF2871921DFAEC8009A87DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = FCF286FD21DFAEC7009A87DA /* Project object */; +} diff --git a/metal/MobileNetDemo/MobileNetDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/metal/MobileNetDemo/MobileNetDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000000000000000000000000000000000..73ab39f972e15921714f718758c421cbdf174cec --- /dev/null +++ b/metal/MobileNetDemo/MobileNetDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/metal/MobileNetDemo/MobileNetDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/metal/MobileNetDemo/MobileNetDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/metal/MobileNetDemo/MobileNetDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/metal/MobileNetDemo/MobileNetDemo/AppDelegate.swift b/metal/MobileNetDemo/MobileNetDemo/AppDelegate.swift new file mode 100644 index 0000000000000000000000000000000000000000..4152b9be890fe3101e3137f02686fb6359cb108d --- /dev/null +++ b/metal/MobileNetDemo/MobileNetDemo/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// MobileNetDemo +// +// Created by liuRuiLong on 2019/1/4. +// Copyright © 2019 Ray. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/metal/MobileNetDemo/MobileNetDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/metal/MobileNetDemo/MobileNetDemo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..d8db8d65fd79fd541b2b7eba75c7378af3448f9c --- /dev/null +++ b/metal/MobileNetDemo/MobileNetDemo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/metal/MobileNetDemo/MobileNetDemo/Assets.xcassets/Contents.json b/metal/MobileNetDemo/MobileNetDemo/Assets.xcassets/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..da4a164c918651cdd1e11dca5cc62c333f097601 --- /dev/null +++ b/metal/MobileNetDemo/MobileNetDemo/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/metal/MobileNetDemo/MobileNetDemo/Base.lproj/LaunchScreen.storyboard b/metal/MobileNetDemo/MobileNetDemo/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..bfa36129419f8bd7ad73581cb9f07b8c6eec3fcf --- /dev/null +++ b/metal/MobileNetDemo/MobileNetDemo/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metal/MobileNetDemo/MobileNetDemo/Base.lproj/Main.storyboard b/metal/MobileNetDemo/MobileNetDemo/Base.lproj/Main.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..067a594bf334dcdd23b37115f98e8e13313a06dd --- /dev/null +++ b/metal/MobileNetDemo/MobileNetDemo/Base.lproj/Main.storyboard @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metal/MobileNetDemo/MobileNetDemo/Info.plist b/metal/MobileNetDemo/MobileNetDemo/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..fbe86e68a60c6a0fb1f318432b3cd1a4730a9dfe --- /dev/null +++ b/metal/MobileNetDemo/MobileNetDemo/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + NSCameraUsageDescription + use camera + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/metal/paddle-mobile/paddle-mobile/MobileNet.swift b/metal/MobileNetDemo/MobileNetDemo/MobileNet.swift similarity index 77% rename from metal/paddle-mobile/paddle-mobile/MobileNet.swift rename to metal/MobileNetDemo/MobileNetDemo/MobileNet.swift index 7d10a920d15e751f29fce7f9f6be71cd6a2d6b69..9a50f3db8d7d1b57853d5ba6893e4af14879173c 100644 --- a/metal/paddle-mobile/paddle-mobile/MobileNet.swift +++ b/metal/MobileNetDemo/MobileNetDemo/MobileNet.swift @@ -13,13 +13,13 @@ limitations under the License. */ import Foundation +import paddle_mobile -class MobileNet: Net{ - +public class MobileNet: Net{ class MobilenetPreProccess: CusomKernel { init(device: MTLDevice) { - let s = CusomKernel.Shape.init(inWidth: 224, inHeight: 224, inChannel: 3) - super.init(device: device, inFunctionName: "mobilenet_preprocess", outputDim: s, usePaddleMobileLib: false) + let s = Shape.init(inWidth: 224, inHeight: 224, inChannel: 3) + super.init(device: device, inFunctionName: "mobilenet_preprocess", outputDim: s, metalLoadModel: .LoadMetalInDefaultLib, metalLibPath: nil) } } @@ -43,9 +43,7 @@ class MobileNet: Net{ let labels = PreWords.init(fileName: "synset") override public func resultStr(res: ResultHolder) -> String { - guard let resPointer = res.result else { - fatalError() - } + let resPointer = res.result var s: [String] = [] (0.. +using namespace metal; + +kernel void mobilenet_preprocess( + texture2d inTexture [[texture(0)]], + texture2d outTexture [[texture(1)]], + uint2 gid [[thread_position_in_grid]]) +{ + if (gid.x >= outTexture.get_width() || + gid.y >= outTexture.get_height()) { + return; + } + const auto means = float4(123.68f, 116.78f, 103.94f, 0.0f); + const float4 inColor = (inTexture.read(gid) * 255.0 - means) * 0.017; + outTexture.write(float4(inColor.z, inColor.y, inColor.x, 0.0f), gid); +} + +kernel void mobilenet_preprocess_half( + texture2d inTexture [[texture(0)]], + texture2d outTexture [[texture(1)]], + uint2 gid [[thread_position_in_grid]]) +{ + if (gid.x >= outTexture.get_width() || + gid.y >= outTexture.get_height()) { + return; + } + const auto means = half4(123.68f, 116.78f, 103.94f, 0.0f); + const half4 inColor = (inTexture.read(gid) * 255.0 - means) * 0.017; + outTexture.write(half4(inColor.z, inColor.y, inColor.x, 0.0f), gid); +} diff --git a/metal/MobileNetDemo/MobileNetDemo/ViewController.swift b/metal/MobileNetDemo/MobileNetDemo/ViewController.swift new file mode 100644 index 0000000000000000000000000000000000000000..4e31282f0356bdd3ce4bc2b7ef69e7ad0bd5ef89 --- /dev/null +++ b/metal/MobileNetDemo/MobileNetDemo/ViewController.swift @@ -0,0 +1,93 @@ +// +// ViewController.swift +// MobileNetDemo +// +// Created by liuRuiLong on 2019/1/4. +// Copyright © 2019 Ray. All rights reserved. +// + +import UIKit +import paddle_mobile + +class ViewController: UIViewController { + @IBOutlet weak var resultTextView: UITextView! + @IBOutlet weak var selectImageView: UIImageView! + @IBOutlet weak var elapsedTimeLabel: UILabel! + var net: MobileNet! + var runner: Runner! + var toPredictTexture: MTLTexture? + + override func viewDidLoad() { + super.viewDidLoad() + GlobalConfig.shared.computePrecision = .Float16 + net = MobileNet.init(device: MetalHelper.shared.device) + runner = Runner.init(inNet: net, commandQueue: MetalHelper.shared.queue) + + if let selectImage = UIImage.init(named: "banana.jpeg") { + selectImageView.image = selectImage + runner.getTexture(image: selectImage.cgImage!) {[weak self] (texture) in + self?.toPredictTexture = texture + } + } + + } + + @IBAction func loadAct(_ sender: Any) { + if runner.load() { + let resutText = " load success ! " + print(resutText) + self.resultTextView.text = resutText + } else { + fatalError(" load error ") + } + } + + @IBAction func selectImageAct(_ sender: Any) { + let imagePicker = UIImagePickerController() + imagePicker.sourceType = .camera + imagePicker.delegate = self + self.present(imagePicker, animated: true, completion: nil) + } + + @IBAction func clearAct(_ sender: Any) { + runner.clear() + } + + @IBAction func predictAct(_ sender: Any) { + + if let texture = toPredictTexture { + let beginDate = Date.init() + runner.predict(texture: texture) { [weak self] (success, resultHolder) in + if success, let inResultHolder = resultHolder { + let timeUse = Date.init().timeIntervalSince(beginDate) + DispatchQueue.main.async { + self?.elapsedTimeLabel.text = "\(timeUse * 1000)ms" + self?.resultTextView.text = self?.net.resultStr(res: inResultHolder) + } + + } else { + print(" predict fail ") + } + } + } else { + print(" toPredictTexture is nil ") + } + + } + +} + +extension ViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { + picker.dismiss(animated: true){[weak self] in + guard let sSelf = self, let image = info["UIImagePickerControllerOriginalImage"] as? UIImage else { + fatalError("no image") + } + sSelf.selectImageView.image = image + sSelf.runner.getTexture(image: image.cgImage!, getTexture: { (texture) in + sSelf.toPredictTexture = texture + }) + } + } +} + diff --git a/metal/Podfile b/metal/Podfile index 6e9a6c6e3713ceaafc8d1769d7ec731ecc78b615..0262c9beaf3e3d973de4cb2a3d7af041cbff0627 100644 --- a/metal/Podfile +++ b/metal/Podfile @@ -17,3 +17,9 @@ target 'paddle-mobile-unit-test' do project 'paddle-mobile-unit-test/paddle-mobile-unit-test.xcodeproj' pod 'SwiftProtobuf', '~> 1.0' end + +target 'MobileNetDemo' do + project 'MobileNetDemo/MobileNetDemo.xcodeproj' + pod 'SwiftProtobuf', '~> 1.0' +end + diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj index 7ef082fcde7c46e63b1fe35ed24e9fc76b83f0c0..75e48f2d894c54ac385df4d71c014de370af0053 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj +++ b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj @@ -10,20 +10,42 @@ 30D0ED21F392CFA3885B1002 /* Pods_paddle_mobile_demo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18896810981724F8A0FED62A /* Pods_paddle_mobile_demo.framework */; }; C2CBB49021B778EA0020DC6C /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = FC4FD97B2140EE250073E130 /* libc++.tbd */; }; C2E67E5E21524E460013F575 /* LoadPointerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2E67E5D21524E460013F575 /* LoadPointerViewController.m */; }; - FC013928210204A3008100E3 /* PreProcessKernel.metal in Sources */ = {isa = PBXBuildFile; fileRef = FC013927210204A3008100E3 /* PreProcessKernel.metal */; }; FC039B8220E11C550081E9F8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC039B8120E11C550081E9F8 /* AppDelegate.swift */; }; FC039B8420E11C550081E9F8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC039B8320E11C550081E9F8 /* ViewController.swift */; }; FC039B8720E11C550081E9F8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC039B8520E11C550081E9F8 /* Main.storyboard */; }; FC039B8920E11C560081E9F8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FC039B8820E11C560081E9F8 /* Assets.xcassets */; }; FC039B8C20E11C560081E9F8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC039B8A20E11C560081E9F8 /* LaunchScreen.storyboard */; }; FC203FB221CBFDBA00B37166 /* test.jpg in Resources */ = {isa = PBXBuildFile; fileRef = FC203FA921CBFDBA00B37166 /* test.jpg */; }; - FC203FB321CBFDBA00B37166 /* combined_mobilenet_params in Resources */ = {isa = PBXBuildFile; fileRef = FC203FAD21CBFDBA00B37166 /* combined_mobilenet_params */; }; - FC203FB421CBFDBA00B37166 /* combined_mobilenet_model in Resources */ = {isa = PBXBuildFile; fileRef = FC203FAE21CBFDBA00B37166 /* combined_mobilenet_model */; }; - FC203FB521CBFDBA00B37166 /* yolo_params in Resources */ = {isa = PBXBuildFile; fileRef = FC203FB021CBFDBA00B37166 /* yolo_params */; }; - FC203FB621CBFDBA00B37166 /* yolo_model in Resources */ = {isa = PBXBuildFile; fileRef = FC203FB121CBFDBA00B37166 /* yolo_model */; }; + FC2BFCBC21DF0A8600C262B2 /* 00001.jpg in Resources */ = {isa = PBXBuildFile; fileRef = FC2BFCBB21DF0A8600C262B2 /* 00001.jpg */; }; + FC2BFCBE21DF15D900C262B2 /* 123.jpg in Resources */ = {isa = PBXBuildFile; fileRef = FC2BFCBD21DF15D900C262B2 /* 123.jpg */; }; + FC2BFCC021DF279900C262B2 /* classify-img-output.png in Resources */ = {isa = PBXBuildFile; fileRef = FC2BFCBF21DF279900C262B2 /* classify-img-output.png */; }; + FC2BFD3021DF3FEA00C262B2 /* MobilenetSSD_AR.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD2A21DF3FE900C262B2 /* MobilenetSSD_AR.swift */; }; + FC2BFD3121DF3FEA00C262B2 /* Genet.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD2B21DF3FE900C262B2 /* Genet.swift */; }; + FC2BFD3221DF3FEA00C262B2 /* MobileNetSSD.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD2C21DF3FE900C262B2 /* MobileNetSSD.swift */; }; + FC2BFD3321DF3FEA00C262B2 /* YoloNet.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD2D21DF3FE900C262B2 /* YoloNet.swift */; }; + FC2BFD3421DF3FEA00C262B2 /* MobileNetCombined.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD2E21DF3FEA00C262B2 /* MobileNetCombined.swift */; }; + FC2BFD3521DF3FEA00C262B2 /* MobileNet.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD2F21DF3FEA00C262B2 /* MobileNet.swift */; }; + FC2BFD3821DF46DE00C262B2 /* OCDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD3721DF46DE00C262B2 /* OCDemoViewController.m */; }; + FC2BFD3C21DF480400C262B2 /* CPUCompute.mm in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD3B21DF480400C262B2 /* CPUCompute.mm */; }; + FC2BFD3E21DF5CE800C262B2 /* PreProcessKernel.metal in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD3D21DF5CE800C262B2 /* PreProcessKernel.metal */; }; + FC2BFD4321DF5E1E00C262B2 /* PaddleMobileGPU.m in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD4021DF5E1E00C262B2 /* PaddleMobileGPU.m */; }; + FC2BFD4421DF5E1E00C262B2 /* SuperResolutionNet.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC2BFD4221DF5E1E00C262B2 /* SuperResolutionNet.swift */; }; + FC5E03B221DCE8D90016C137 /* mingren_input_data in Resources */ = {isa = PBXBuildFile; fileRef = FC5E03B121DCE8D90016C137 /* mingren_input_data */; }; + FC704C1921D2375300F98BAB /* super_params in Resources */ = {isa = PBXBuildFile; fileRef = FC704C1721D2375300F98BAB /* super_params */; }; + FC704C1A21D2375300F98BAB /* super_model in Resources */ = {isa = PBXBuildFile; fileRef = FC704C1821D2375300F98BAB /* super_model */; }; + FC704C2221D237FC00F98BAB /* combined_mobilenet_params in Resources */ = {isa = PBXBuildFile; fileRef = FC704C1D21D237FC00F98BAB /* combined_mobilenet_params */; }; + FC704C2321D237FC00F98BAB /* combined_mobilenet_model in Resources */ = {isa = PBXBuildFile; fileRef = FC704C1E21D237FC00F98BAB /* combined_mobilenet_model */; }; + FC704C2421D237FC00F98BAB /* yolo_params in Resources */ = {isa = PBXBuildFile; fileRef = FC704C2021D237FC00F98BAB /* yolo_params */; }; + FC704C2521D237FC00F98BAB /* yolo_model in Resources */ = {isa = PBXBuildFile; fileRef = FC704C2121D237FC00F98BAB /* yolo_model */; }; FC803BCD214D27930094B8E5 /* FPSCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC803BCB214D27920094B8E5 /* FPSCounter.swift */; }; FC803BCE214D27930094B8E5 /* VideoCapture.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC803BCC214D27920094B8E5 /* VideoCapture.swift */; }; + FC9797BE21D6045B00F2FD90 /* banana.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = FC9797BD21D6045B00F2FD90 /* banana.jpeg */; }; + FC9797C221D608E000F2FD90 /* mobilenet_model in Resources */ = {isa = PBXBuildFile; fileRef = FC9797C021D608DF00F2FD90 /* mobilenet_model */; }; + FC9797C321D608E000F2FD90 /* mobilenet_params in Resources */ = {isa = PBXBuildFile; fileRef = FC9797C121D608DF00F2FD90 /* mobilenet_params */; }; + FC9797C721D609FB00F2FD90 /* synset.txt in Resources */ = {isa = PBXBuildFile; fileRef = FC9797C621D609FB00F2FD90 /* synset.txt */; }; + FC9797CF21D6506F00F2FD90 /* mingren.jpg in Resources */ = {isa = PBXBuildFile; fileRef = FC9797CE21D6506F00F2FD90 /* mingren.jpg */; }; FCBCCC552122EF5500D94F7E /* MetalHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCBCCC542122EF5400D94F7E /* MetalHelper.swift */; }; + FCCED60521D7646E00BE8D5F /* test_image_super in Resources */ = {isa = PBXBuildFile; fileRef = FCCED60421D7646E00BE8D5F /* test_image_super */; }; FCEBEC2C20E1391F00C0B14D /* paddle_mobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */; }; FCEBEC2D20E1391F00C0B14D /* paddle_mobile.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; FCF437E8214B6DDB00943429 /* MultiPredictViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCF437E7214B6DDB00943429 /* MultiPredictViewController.swift */; }; @@ -49,7 +71,6 @@ 878829884E1A14D7044721D5 /* Pods-paddle-mobile-demo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-paddle-mobile-demo.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-paddle-mobile-demo/Pods-paddle-mobile-demo.debug.xcconfig"; sourceTree = ""; }; C2E67E5C21524E460013F575 /* LoadPointerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoadPointerViewController.h; sourceTree = ""; }; C2E67E5D21524E460013F575 /* LoadPointerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoadPointerViewController.m; sourceTree = ""; }; - FC013927210204A3008100E3 /* PreProcessKernel.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = PreProcessKernel.metal; sourceTree = ""; }; FC039B7E20E11C550081E9F8 /* paddle-mobile-demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "paddle-mobile-demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; FC039B8120E11C550081E9F8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; FC039B8320E11C550081E9F8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -58,15 +79,41 @@ FC039B8B20E11C560081E9F8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; FC039B8D20E11C560081E9F8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; FC203FA921CBFDBA00B37166 /* test.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = test.jpg; sourceTree = ""; }; - FC203FAD21CBFDBA00B37166 /* combined_mobilenet_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = combined_mobilenet_params; sourceTree = ""; }; - FC203FAE21CBFDBA00B37166 /* combined_mobilenet_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = combined_mobilenet_model; sourceTree = ""; }; - FC203FB021CBFDBA00B37166 /* yolo_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = yolo_params; sourceTree = ""; }; - FC203FB121CBFDBA00B37166 /* yolo_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = yolo_model; sourceTree = ""; }; FC27991121343A39000B6BAD /* paddle-mobile-demo-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "paddle-mobile-demo-Bridging-Header.h"; sourceTree = ""; }; + FC2BFCBB21DF0A8600C262B2 /* 00001.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 00001.jpg; sourceTree = ""; }; + FC2BFCBD21DF15D900C262B2 /* 123.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 123.jpg; sourceTree = ""; }; + FC2BFCBF21DF279900C262B2 /* classify-img-output.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "classify-img-output.png"; sourceTree = ""; }; + FC2BFD2A21DF3FE900C262B2 /* MobilenetSSD_AR.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobilenetSSD_AR.swift; sourceTree = ""; }; + FC2BFD2B21DF3FE900C262B2 /* Genet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Genet.swift; sourceTree = ""; }; + FC2BFD2C21DF3FE900C262B2 /* MobileNetSSD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobileNetSSD.swift; sourceTree = ""; }; + FC2BFD2D21DF3FE900C262B2 /* YoloNet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YoloNet.swift; sourceTree = ""; }; + FC2BFD2E21DF3FEA00C262B2 /* MobileNetCombined.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobileNetCombined.swift; sourceTree = ""; }; + FC2BFD2F21DF3FEA00C262B2 /* MobileNet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobileNet.swift; sourceTree = ""; }; + FC2BFD3621DF46DE00C262B2 /* OCDemoViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OCDemoViewController.h; sourceTree = ""; }; + FC2BFD3721DF46DE00C262B2 /* OCDemoViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OCDemoViewController.m; sourceTree = ""; }; + FC2BFD3A21DF480300C262B2 /* CPUCompute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUCompute.h; sourceTree = ""; }; + FC2BFD3B21DF480400C262B2 /* CPUCompute.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CPUCompute.mm; sourceTree = ""; }; + FC2BFD3D21DF5CE800C262B2 /* PreProcessKernel.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = PreProcessKernel.metal; sourceTree = ""; }; + FC2BFD4021DF5E1E00C262B2 /* PaddleMobileGPU.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PaddleMobileGPU.m; sourceTree = ""; }; + FC2BFD4121DF5E1E00C262B2 /* PaddleMobileGPU.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PaddleMobileGPU.h; sourceTree = ""; }; + FC2BFD4221DF5E1E00C262B2 /* SuperResolutionNet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SuperResolutionNet.swift; sourceTree = ""; }; FC4FD97B2140EE250073E130 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; + FC5E03B121DCE8D90016C137 /* mingren_input_data */ = {isa = PBXFileReference; lastKnownFileType = file; path = mingren_input_data; sourceTree = ""; }; + FC704C1721D2375300F98BAB /* super_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = super_params; sourceTree = ""; }; + FC704C1821D2375300F98BAB /* super_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = super_model; sourceTree = ""; }; + FC704C1D21D237FC00F98BAB /* combined_mobilenet_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = combined_mobilenet_params; sourceTree = ""; }; + FC704C1E21D237FC00F98BAB /* combined_mobilenet_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = combined_mobilenet_model; sourceTree = ""; }; + FC704C2021D237FC00F98BAB /* yolo_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = yolo_params; sourceTree = ""; }; + FC704C2121D237FC00F98BAB /* yolo_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = yolo_model; sourceTree = ""; }; FC803BCB214D27920094B8E5 /* FPSCounter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FPSCounter.swift; sourceTree = ""; }; FC803BCC214D27920094B8E5 /* VideoCapture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoCapture.swift; sourceTree = ""; }; + FC9797BD21D6045B00F2FD90 /* banana.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = banana.jpeg; sourceTree = ""; }; + FC9797C021D608DF00F2FD90 /* mobilenet_model */ = {isa = PBXFileReference; lastKnownFileType = file; path = mobilenet_model; sourceTree = ""; }; + FC9797C121D608DF00F2FD90 /* mobilenet_params */ = {isa = PBXFileReference; lastKnownFileType = file; path = mobilenet_params; sourceTree = ""; }; + FC9797C621D609FB00F2FD90 /* synset.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = synset.txt; sourceTree = ""; }; + FC9797CE21D6506F00F2FD90 /* mingren.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = mingren.jpg; sourceTree = ""; }; FCBCCC542122EF5400D94F7E /* MetalHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MetalHelper.swift; sourceTree = ""; }; + FCCED60421D7646E00BE8D5F /* test_image_super */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_image_super; sourceTree = ""; }; FCEBEC2B20E1391F00C0B14D /* paddle_mobile.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = paddle_mobile.framework; sourceTree = BUILT_PRODUCTS_DIR; }; FCF437E7214B6DDB00943429 /* MultiPredictViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiPredictViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -125,8 +172,11 @@ FC039B8020E11C550081E9F8 /* paddle-mobile-demo */ = { isa = PBXGroup; children = ( - FC203FA821CBFDBA00B37166 /* images */, - FC203FAA21CBFDBA00B37166 /* models */, + FC2BFD4F21DF892500C262B2 /* Resources */, + FCBCCC542122EF5400D94F7E /* MetalHelper.swift */, + FC2BFD3F21DF5DDF00C262B2 /* OCInterface */, + FC27991121343A39000B6BAD /* paddle-mobile-demo-Bridging-Header.h */, + FC2BFD3921DF46F000C262B2 /* OCDemo */, FC803BCA214D27920094B8E5 /* VideoCapture */, FC8CFED2213519540094D569 /* Net */, FC039B8120E11C550081E9F8 /* AppDelegate.swift */, @@ -135,10 +185,7 @@ FC039B8820E11C560081E9F8 /* Assets.xcassets */, FC039B8A20E11C560081E9F8 /* LaunchScreen.storyboard */, FC039B8D20E11C560081E9F8 /* Info.plist */, - FC27991121343A39000B6BAD /* paddle-mobile-demo-Bridging-Header.h */, FCF437E7214B6DDB00943429 /* MultiPredictViewController.swift */, - C2E67E5C21524E460013F575 /* LoadPointerViewController.h */, - C2E67E5D21524E460013F575 /* LoadPointerViewController.m */, ); path = "paddle-mobile-demo"; sourceTree = ""; @@ -146,44 +193,90 @@ FC203FA821CBFDBA00B37166 /* images */ = { isa = PBXGroup; children = ( + FC2BFCBF21DF279900C262B2 /* classify-img-output.png */, + FC2BFCBD21DF15D900C262B2 /* 123.jpg */, + FC2BFCBB21DF0A8600C262B2 /* 00001.jpg */, + FC5E03B121DCE8D90016C137 /* mingren_input_data */, + FCCED60421D7646E00BE8D5F /* test_image_super */, + FC9797CE21D6506F00F2FD90 /* mingren.jpg */, + FC9797BD21D6045B00F2FD90 /* banana.jpeg */, FC203FA921CBFDBA00B37166 /* test.jpg */, ); - name = images; - path = ../../images; + path = images; sourceTree = ""; }; FC203FAA21CBFDBA00B37166 /* models */ = { isa = PBXGroup; children = ( - FC203FAB21CBFDBA00B37166 /* vision_model */, + FC9797BF21D608DF00F2FD90 /* mobilenet */, + FC704C1B21D237FC00F98BAB /* vision_model */, + FC704C1621D2375300F98BAB /* superresoltion */, + ); + path = models; + sourceTree = ""; + }; + FC2BFD3921DF46F000C262B2 /* OCDemo */ = { + isa = PBXGroup; + children = ( + C2E67E5C21524E460013F575 /* LoadPointerViewController.h */, + C2E67E5D21524E460013F575 /* LoadPointerViewController.m */, + FC2BFD3621DF46DE00C262B2 /* OCDemoViewController.h */, + FC2BFD3721DF46DE00C262B2 /* OCDemoViewController.m */, + ); + path = OCDemo; + sourceTree = ""; + }; + FC2BFD3F21DF5DDF00C262B2 /* OCInterface */ = { + isa = PBXGroup; + children = ( + FC2BFD4121DF5E1E00C262B2 /* PaddleMobileGPU.h */, + FC2BFD4021DF5E1E00C262B2 /* PaddleMobileGPU.m */, + FC2BFD4221DF5E1E00C262B2 /* SuperResolutionNet.swift */, ); - name = models; - path = ../../models; + path = OCInterface; sourceTree = ""; }; - FC203FAB21CBFDBA00B37166 /* vision_model */ = { + FC2BFD4F21DF892500C262B2 /* Resources */ = { isa = PBXGroup; children = ( - FC203FAC21CBFDBA00B37166 /* mobilenet */, - FC203FAF21CBFDBA00B37166 /* yolo */, + FC203FA821CBFDBA00B37166 /* images */, + FC203FAA21CBFDBA00B37166 /* models */, + ); + path = Resources; + sourceTree = ""; + }; + FC704C1621D2375300F98BAB /* superresoltion */ = { + isa = PBXGroup; + children = ( + FC704C1721D2375300F98BAB /* super_params */, + FC704C1821D2375300F98BAB /* super_model */, + ); + path = superresoltion; + sourceTree = ""; + }; + FC704C1B21D237FC00F98BAB /* vision_model */ = { + isa = PBXGroup; + children = ( + FC704C1C21D237FC00F98BAB /* mobilenet */, + FC704C1F21D237FC00F98BAB /* yolo */, ); path = vision_model; sourceTree = ""; }; - FC203FAC21CBFDBA00B37166 /* mobilenet */ = { + FC704C1C21D237FC00F98BAB /* mobilenet */ = { isa = PBXGroup; children = ( - FC203FAD21CBFDBA00B37166 /* combined_mobilenet_params */, - FC203FAE21CBFDBA00B37166 /* combined_mobilenet_model */, + FC704C1D21D237FC00F98BAB /* combined_mobilenet_params */, + FC704C1E21D237FC00F98BAB /* combined_mobilenet_model */, ); path = mobilenet; sourceTree = ""; }; - FC203FAF21CBFDBA00B37166 /* yolo */ = { + FC704C1F21D237FC00F98BAB /* yolo */ = { isa = PBXGroup; children = ( - FC203FB021CBFDBA00B37166 /* yolo_params */, - FC203FB121CBFDBA00B37166 /* yolo_model */, + FC704C2021D237FC00F98BAB /* yolo_params */, + FC704C2121D237FC00F98BAB /* yolo_model */, ); path = yolo; sourceTree = ""; @@ -200,12 +293,29 @@ FC8CFED2213519540094D569 /* Net */ = { isa = PBXGroup; children = ( - FC013927210204A3008100E3 /* PreProcessKernel.metal */, - FCBCCC542122EF5400D94F7E /* MetalHelper.swift */, + FC2BFD3A21DF480300C262B2 /* CPUCompute.h */, + FC2BFD3B21DF480400C262B2 /* CPUCompute.mm */, + FC2BFD3D21DF5CE800C262B2 /* PreProcessKernel.metal */, + FC2BFD2B21DF3FE900C262B2 /* Genet.swift */, + FC2BFD2F21DF3FEA00C262B2 /* MobileNet.swift */, + FC2BFD2E21DF3FEA00C262B2 /* MobileNetCombined.swift */, + FC2BFD2A21DF3FE900C262B2 /* MobilenetSSD_AR.swift */, + FC2BFD2C21DF3FE900C262B2 /* MobileNetSSD.swift */, + FC2BFD2D21DF3FE900C262B2 /* YoloNet.swift */, ); path = Net; sourceTree = ""; }; + FC9797BF21D608DF00F2FD90 /* mobilenet */ = { + isa = PBXGroup; + children = ( + FC9797C621D609FB00F2FD90 /* synset.txt */, + FC9797C021D608DF00F2FD90 /* mobilenet_model */, + FC9797C121D608DF00F2FD90 /* mobilenet_params */, + ); + path = mobilenet; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -268,14 +378,26 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + FCCED60521D7646E00BE8D5F /* test_image_super in Resources */, FC039B8C20E11C560081E9F8 /* LaunchScreen.storyboard in Resources */, - FC203FB421CBFDBA00B37166 /* combined_mobilenet_model in Resources */, - FC203FB321CBFDBA00B37166 /* combined_mobilenet_params in Resources */, + FC9797CF21D6506F00F2FD90 /* mingren.jpg in Resources */, + FC704C2221D237FC00F98BAB /* combined_mobilenet_params in Resources */, + FC704C1921D2375300F98BAB /* super_params in Resources */, + FC2BFCBE21DF15D900C262B2 /* 123.jpg in Resources */, FC039B8920E11C560081E9F8 /* Assets.xcassets in Resources */, - FC203FB521CBFDBA00B37166 /* yolo_params in Resources */, - FC203FB621CBFDBA00B37166 /* yolo_model in Resources */, + FC9797C721D609FB00F2FD90 /* synset.txt in Resources */, + FC5E03B221DCE8D90016C137 /* mingren_input_data in Resources */, + FC704C1A21D2375300F98BAB /* super_model in Resources */, FC039B8720E11C550081E9F8 /* Main.storyboard in Resources */, + FC9797C221D608E000F2FD90 /* mobilenet_model in Resources */, + FC2BFCC021DF279900C262B2 /* classify-img-output.png in Resources */, FC203FB221CBFDBA00B37166 /* test.jpg in Resources */, + FC704C2321D237FC00F98BAB /* combined_mobilenet_model in Resources */, + FC9797C321D608E000F2FD90 /* mobilenet_params in Resources */, + FC704C2421D237FC00F98BAB /* yolo_params in Resources */, + FC2BFCBC21DF0A8600C262B2 /* 00001.jpg in Resources */, + FC9797BE21D6045B00F2FD90 /* banana.jpeg in Resources */, + FC704C2521D237FC00F98BAB /* yolo_model in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -325,14 +447,24 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + FC2BFD3221DF3FEA00C262B2 /* MobileNetSSD.swift in Sources */, + FC2BFD3C21DF480400C262B2 /* CPUCompute.mm in Sources */, + FC2BFD4321DF5E1E00C262B2 /* PaddleMobileGPU.m in Sources */, FC039B8420E11C550081E9F8 /* ViewController.swift in Sources */, FC803BCE214D27930094B8E5 /* VideoCapture.swift in Sources */, - FC013928210204A3008100E3 /* PreProcessKernel.metal in Sources */, FCF437E8214B6DDB00943429 /* MultiPredictViewController.swift in Sources */, + FC2BFD3021DF3FEA00C262B2 /* MobilenetSSD_AR.swift in Sources */, + FC2BFD3321DF3FEA00C262B2 /* YoloNet.swift in Sources */, + FC2BFD3421DF3FEA00C262B2 /* MobileNetCombined.swift in Sources */, FCBCCC552122EF5500D94F7E /* MetalHelper.swift in Sources */, FC803BCD214D27930094B8E5 /* FPSCounter.swift in Sources */, + FC2BFD3521DF3FEA00C262B2 /* MobileNet.swift in Sources */, C2E67E5E21524E460013F575 /* LoadPointerViewController.m in Sources */, + FC2BFD3121DF3FEA00C262B2 /* Genet.swift in Sources */, FC039B8220E11C550081E9F8 /* AppDelegate.swift in Sources */, + FC2BFD4421DF5E1E00C262B2 /* SuperResolutionNet.swift in Sources */, + FC2BFD3E21DF5CE800C262B2 /* PreProcessKernel.metal in Sources */, + FC2BFD3821DF46DE00C262B2 /* OCDemoViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/xcshareddata/xcschemes/paddle-mobile-demo.xcscheme b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/xcshareddata/xcschemes/paddle-mobile-demo.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..b812f38e882bd99acc87bb9e8e01d8e46ef87477 --- /dev/null +++ b/metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/xcshareddata/xcschemes/paddle-mobile-demo.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metal/paddle-mobile-demo/paddle-mobile-demo/Base.lproj/Main.storyboard b/metal/paddle-mobile-demo/paddle-mobile-demo/Base.lproj/Main.storyboard index d72694fdacf5b46821ba6422fa77e095f92382b9..4060bb7b3566fc79cc043e861e7917ebf1d91f65 100644 --- a/metal/paddle-mobile-demo/paddle-mobile-demo/Base.lproj/Main.storyboard +++ b/metal/paddle-mobile-demo/paddle-mobile-demo/Base.lproj/Main.storyboard @@ -1,12 +1,11 @@ - + - - + @@ -20,7 +19,7 @@