├── .gitignore
├── .metadata
├── .vscode
└── launch.json
├── CHANGELOG.md
├── LICENSE
├── README.md
├── analysis_options.yaml
├── android
├── .gitignore
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── settings.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── kotlin
│ └── com
│ └── doryan
│ └── flutter_ml_image_transformation
│ ├── FlutterPytorchCoremlCycleganPlugin.kt
│ ├── channelMethods
│ └── CMImageTransform.kt
│ ├── pytorch
│ ├── MLProcessor.kt
│ └── MLProcessorImpl.kt
│ └── utils
│ ├── BitmapProcessor.kt
│ └── BitmapProcessorImpl.kt
├── example
├── .gitignore
├── .metadata
├── README.md
├── analysis_options.yaml
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── kotlin
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── flutter_ml_image_transformation_example
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── drawable-v21
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values-night
│ │ │ │ └── styles.xml
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── assets
│ ├── coreml_model
│ │ └── .empty
│ └── pytorch_model
│ │ └── .empty
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Podfile
│ ├── Podfile.lock
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ └── WorkspaceSettings.xcsettings
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── Runner
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── Runner-Bridging-Header.h
├── lib
│ ├── main.dart
│ ├── ui
│ │ ├── camera
│ │ │ └── camera.dart
│ │ └── display_image.dart
│ └── utils
│ │ └── file_utils.dart
├── pubspec.yaml
└── test
│ └── widget_test.dart
├── ios
├── .gitignore
├── Assets
│ └── .gitkeep
├── Classes
│ ├── ChannelMethods
│ │ └── CMImageTransform.swift
│ ├── Extension
│ │ ├── AppError.swift
│ │ └── ImageExtension.swift
│ ├── FlutterPytorchCoremlCycleganPlugin.h
│ ├── FlutterPytorchCoremlCycleganPlugin.m
│ ├── SwiftFlutterPytorchCoremlCycleganPlugin.swift
│ ├── ml
│ │ ├── MLProcessor.swift
│ │ └── MLProcessorImpl.swift
│ └── utils
│ │ ├── ImageUtils.swift
│ │ └── ImageUtilsImpl.swift
└── flutter_ml_image_transformation.podspec
├── lib
└── flutter_ml_image_transformation.dart
├── pubspec.yaml
└── test
└── flutter_ml_image_transformation_test.dart
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
25 | /pubspec.lock
26 | **/doc/api/
27 | .dart_tool/
28 | .packages
29 | build/
30 |
31 | # custom
32 | example/assets/*
33 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b
8 | channel: stable
9 |
10 | project_type: plugin
11 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "flutter-ML-imageTransformation",
9 | "request": "launch",
10 | "type": "dart"
11 | },
12 | {
13 | "name": "flutter-ML-imageTransformation (profile mode)",
14 | "request": "launch",
15 | "type": "dart",
16 | "flutterMode": "profile"
17 | },
18 | {
19 | "name": "example",
20 | "cwd": "example",
21 | "request": "launch",
22 | "type": "dart",
23 | "program": "lib/main.dart"
24 | },
25 | {
26 | "name": "example (profile mode)",
27 | "cwd": "example",
28 | "request": "launch",
29 | "type": "dart",
30 | "flutterMode": "profile"
31 | }
32 | ]
33 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.0.1
2 |
3 | * TODO: Describe initial release.
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 ryu38
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Flutter ML Image Transformation
2 | The flutter plugin for image-to-image-transformation using PyTorch-mobile (android) and CoreML (ios)
3 |
4 | ## Installation
5 | Add lines like below under `dependencies` in your package's pubspec.yaml and run `flutter pub get`.
6 | ```yaml
7 | dependencies:
8 |
9 | # ...
10 |
11 | flutter_ml_image_transformation:
12 | git:
13 | url: https://github.com/ryu38/flutter-ML-imageTransformation.git
14 | ref: master
15 | ```
16 |
17 | ## Usage
18 | 1. Create a assets folder to import models of PyTorch and/or CoreML. Add lines like below in pubspec.yaml.
19 | ```yaml
20 | assets:
21 | - assets/pytorch_model/
22 | - assets/coreml_model/
23 | ```
24 | 2. Store models in the assets folder created.
25 | 3. Copy your model to a documents directory.
26 | [About Documents Directory](https://docs.flutter.dev/cookbook/persistence/reading-writing-files)
27 | ```dart
28 | import 'package:flutter/services.dart';
29 | import 'package:path/path.dart';
30 | import 'package:path_provider/path_provider.dart';
31 |
32 |
33 | // Use a different model for IOS or android.
34 | final String assetModelPath;
35 | final String appDirModelName;
36 | if (Platform.isAndroid) {
37 | assetModelPath = 'assets/pytorch_model/MyModel.ptl';
38 | appDirModelName = 'MyModel.ptl';
39 | } else if (Platform.isIOS) {
40 | assetModelPath = 'assets/coreml_model/MyModel.mlmodel';
41 | appDirModelName = 'MyModel.mlmodel';
42 | } else {
43 | throw Exception();
44 | }
45 |
46 | // Get a path to a documents directory and define a path to a model to be copied there.
47 | final appDir = await getApplicationDocumentsDirectory();
48 | final appDirModelPath = join(appDir.path, appDirModelName);
49 |
50 | // Copy your model in the assets folder there.
51 | final byteData = await rootBundle.load(assetModelPath);
52 | final bytes = byteData.buffer
53 | .asUint8List(byteData.offsetInBytes, byteData.lengthInBytes);
54 | await File(appDirModelPath).writeAsBytes(bytes);
55 | ```
56 | 4. Import the library.
57 | ```dart
58 | import 'package:flutter_ml_image_transformation/flutter_ml_image_transformation.dart';
59 | ```
60 | 5. Load your model by `MLImageTransformer.setModel()` before executing Image Transformation.
61 | `inputWidth` and `inputHeight` are set to `256` by default.
62 | ```dart
63 | final result = await MLImageTransformer.setModel(
64 | modelPath: modelPath, inputWidth: 256, inputHeight: 256,
65 | );
66 | if (result != null) throw Exception(result);
67 | ```
68 | 6. Execute Image Transformation by `MLImageTransformer.transformImage()`.
69 | `imagePath` and `outputPath` need to be readable by the app (Documents Directory or Temporary Directory).
70 | ```dart
71 | final result = await MLImageTransformer.transformImage(
72 | imagePath: imagePath, outputPath: outputPath
73 | );
74 | if (result != null) throw Exception(result);
75 | ```
76 | ---
77 | #### NOTE
78 | You can also learn more about how to use the package from [/example](example/).
79 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:flutter_lints/flutter.yaml
2 |
3 | # Additional information about this file can be found at
4 | # https://dart.dev/guides/language/analysis-options
5 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | group 'com.doryan.flutter_ml_image_transformation'
2 | version '1.0-SNAPSHOT'
3 |
4 | buildscript {
5 | ext.kotlin_version = '1.6.10'
6 | repositories {
7 | google()
8 | mavenCentral()
9 | jcenter()
10 | }
11 |
12 | dependencies {
13 | classpath 'com.android.tools.build:gradle:7.1.2'
14 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15 | }
16 | }
17 |
18 | rootProject.allprojects {
19 | repositories {
20 | google()
21 | mavenCentral()
22 | jcenter()
23 | }
24 | }
25 |
26 | apply plugin: 'com.android.library'
27 | apply plugin: 'kotlin-android'
28 |
29 | android {
30 | compileSdkVersion 32
31 |
32 | compileOptions {
33 | sourceCompatibility JavaVersion.VERSION_1_8
34 | targetCompatibility JavaVersion.VERSION_1_8
35 | }
36 |
37 | kotlinOptions {
38 | jvmTarget = '1.8'
39 | }
40 |
41 | sourceSets {
42 | main.java.srcDirs += 'src/main/kotlin'
43 | }
44 |
45 | defaultConfig {
46 | minSdkVersion 27
47 | }
48 | }
49 |
50 | dependencies {
51 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
52 |
53 | // pytorch
54 | implementation "org.pytorch:pytorch_android:1.10.0"
55 | implementation "org.pytorch:pytorch_android_torchvision:1.10.0"
56 |
57 | // coroutines
58 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6"
59 | }
60 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'flutter_ml_image_transformation'
2 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/kotlin/com/doryan/flutter_ml_image_transformation/FlutterPytorchCoremlCycleganPlugin.kt:
--------------------------------------------------------------------------------
1 | package com.doryan.flutter_ml_image_transformation
2 |
3 | import androidx.annotation.NonNull
4 | import com.doryan.flutter_ml_image_transformation.channelMethods.CMImageTransform
5 |
6 | import io.flutter.embedding.engine.plugins.FlutterPlugin
7 | import io.flutter.plugin.common.MethodCall
8 | import io.flutter.plugin.common.MethodChannel
9 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler
10 | import io.flutter.plugin.common.MethodChannel.Result
11 | import kotlinx.coroutines.CoroutineScope
12 | import kotlinx.coroutines.Dispatchers
13 | import kotlinx.coroutines.launch
14 |
15 | /** FlutterPytorchCoremlCycleganPlugin */
16 | class FlutterPytorchCoremlCycleganPlugin: FlutterPlugin, MethodCallHandler {
17 | /// The MethodChannel that will the communication between Flutter and native Android
18 | ///
19 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it
20 | /// when the Flutter Engine is detached from the Activity
21 | private lateinit var channel : MethodChannel
22 |
23 | private val mainScope = CoroutineScope(Dispatchers.Main)
24 |
25 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
26 | channel = MethodChannel(flutterPluginBinding.binaryMessenger, "flutter_ml_image_transformation")
27 | channel.setMethodCallHandler(this)
28 | }
29 |
30 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
31 | when (call.method) {
32 | "setModel" -> {
33 | val params = call.arguments as HashMap
34 | val modelPath = params["modelPath"] as String
35 | val width = params["inputWidth"] as Int
36 | val height = params["inputHeight"] as Int
37 | mainScope.launch {
38 | result.success(
39 | CMImageTransform.setModel(modelPath, width, height)
40 | )
41 | }
42 | }
43 | "transformImage" -> {
44 | val params = call.arguments as HashMap
45 | val imagePath = params["imagePath"] as String
46 | val outputPath = params["outputPath"] as String
47 | mainScope.launch {
48 | result.success(
49 | CMImageTransform.transformImage(imagePath, outputPath)
50 | )
51 | }
52 | }
53 | else -> {
54 | result.notImplemented()
55 | }
56 | }
57 | }
58 |
59 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
60 | channel.setMethodCallHandler(null)
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/android/src/main/kotlin/com/doryan/flutter_ml_image_transformation/channelMethods/CMImageTransform.kt:
--------------------------------------------------------------------------------
1 | package com.doryan.flutter_ml_image_transformation.channelMethods
2 |
3 | import com.doryan.flutter_ml_image_transformation.pytorch.MLProcessor
4 | import com.doryan.flutter_ml_image_transformation.pytorch.MLProcessorImpl
5 | import com.doryan.flutter_ml_image_transformation.utils.BitmapProcessor
6 | import com.doryan.flutter_ml_image_transformation.utils.BitmapProcessorImpl
7 | import kotlinx.coroutines.CoroutineScope
8 | import kotlinx.coroutines.Dispatchers
9 | import kotlinx.coroutines.launch
10 | import kotlinx.coroutines.withContext
11 |
12 | object CMImageTransform {
13 |
14 | private val bitmapProcessor: BitmapProcessor = BitmapProcessorImpl()
15 | private var mlProcessor: MLProcessor? = null
16 |
17 | suspend fun setModel(modelPath: String, width: Int, height: Int): String? {
18 | try {
19 | mlProcessor = withContext(Dispatchers.IO) {
20 | MLProcessorImpl(modelPath, width, height)
21 | }
22 | } catch (ex: Exception) {
23 | return ex.message ?: "unknown"
24 | }
25 | return null
26 | }
27 |
28 | suspend fun transformImage(
29 | imagePath: String, outputPath: String): String? {
30 | try {
31 | mlProcessor?.let {
32 | withContext(Dispatchers.Default) {
33 | val srcBitmap = bitmapProcessor.loadImage(imagePath)
34 | val input = bitmapProcessor.centerCropScale(
35 | srcBitmap, it.width, it.height)
36 | it.process(input).also {
37 | bitmapProcessor.saveBitmap(it, outputPath)
38 | }
39 | }
40 | return null
41 | }
42 | throw Exception("a model is not set")
43 | } catch (ex: Exception) {
44 | return ex.message ?: "unknown"
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/android/src/main/kotlin/com/doryan/flutter_ml_image_transformation/pytorch/MLProcessor.kt:
--------------------------------------------------------------------------------
1 | package com.doryan.flutter_ml_image_transformation.pytorch
2 |
3 | import android.graphics.Bitmap
4 | import org.pytorch.Module
5 |
6 | interface MLProcessor {
7 |
8 | val module: Module
9 | val width: Int
10 | val height: Int
11 |
12 | fun process(bitmap: Bitmap): Bitmap
13 | }
--------------------------------------------------------------------------------
/android/src/main/kotlin/com/doryan/flutter_ml_image_transformation/pytorch/MLProcessorImpl.kt:
--------------------------------------------------------------------------------
1 | package com.doryan.flutter_ml_image_transformation.pytorch
2 |
3 | import android.graphics.Bitmap
4 | import android.graphics.Color
5 | import org.pytorch.IValue
6 | import org.pytorch.Module
7 | import org.pytorch.torchvision.TensorImageUtils
8 |
9 | class MLProcessorImpl(
10 | modelPath: String,
11 | override val width: Int,
12 | override val height: Int): MLProcessor {
13 |
14 | override val module = Module.load(modelPath)
15 |
16 | override fun process(bitmap: Bitmap): Bitmap {
17 | val inputTensor = TensorImageUtils.bitmapToFloat32Tensor(
18 | bitmap, FloatArray(3) { RGB_MEAN * 3 }, FloatArray(3) { RGB_STD * 3 }
19 | )
20 | val outputTensor = module.forward(IValue.from(inputTensor))
21 | .toTensor().dataAsFloatArray
22 | return outputTensor.bitmap
23 | }
24 |
25 | private val FloatArray.bitmap: Bitmap
26 | get() {
27 | val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
28 | val totalPixels = width * height
29 | val pixelArray = IntArray(totalPixels)
30 |
31 | val denorm = { n: Float -> (n * RGB_STD) + RGB_MEAN }
32 |
33 | for (i in 0 until totalPixels) {
34 | pixelArray[i] = Color.rgb(
35 | denorm(this[i]), denorm(this[i + totalPixels]), denorm(this[i + 2 * totalPixels])
36 | )
37 | }
38 | bitmap.setPixels(pixelArray, 0, width, 0, 0, width, height)
39 | return bitmap
40 | }
41 |
42 | companion object {
43 | private const val RGB_MEAN = 0.5f
44 | private const val RGB_STD = 0.5f
45 | }
46 | }
--------------------------------------------------------------------------------
/android/src/main/kotlin/com/doryan/flutter_ml_image_transformation/utils/BitmapProcessor.kt:
--------------------------------------------------------------------------------
1 | package com.doryan.flutter_ml_image_transformation.utils
2 |
3 | import android.graphics.Bitmap
4 |
5 | interface BitmapProcessor {
6 |
7 | fun loadImage(path: String): Bitmap
8 |
9 | fun saveBitmap(bitmap: Bitmap, path: String)
10 |
11 | fun centerCropScale(src: Bitmap, width: Int, height: Int): Bitmap
12 | }
--------------------------------------------------------------------------------
/android/src/main/kotlin/com/doryan/flutter_ml_image_transformation/utils/BitmapProcessorImpl.kt:
--------------------------------------------------------------------------------
1 | package com.doryan.flutter_ml_image_transformation.utils
2 |
3 | import android.graphics.Bitmap
4 | import android.graphics.BitmapFactory
5 | import android.graphics.Matrix
6 | import java.io.ByteArrayOutputStream
7 | import java.io.File
8 |
9 | class BitmapProcessorImpl: BitmapProcessor {
10 |
11 | override fun loadImage(path: String): Bitmap {
12 | return BitmapFactory.decodeFile(path)
13 | }
14 |
15 | override fun saveBitmap(bitmap: Bitmap, path: String) {
16 | val baos = ByteArrayOutputStream()
17 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos)
18 | val jpgArray = baos.toByteArray()
19 | File(path).writeBytes(jpgArray)
20 | }
21 |
22 | override fun centerCropScale(src: Bitmap, width: Int, height: Int): Bitmap {
23 | val srcWidth = src.width
24 | val srcHeight = src.height
25 |
26 | val srcAspect = srcHeight.toFloat() / srcWidth
27 | val cropAspect = height.toFloat() / width
28 |
29 | val matrix = { srcW: Int, srcH: Int ->
30 | Matrix().apply {
31 | postScale(width.toFloat() / srcW, height.toFloat() / srcH)
32 | }
33 | }
34 |
35 | if (srcAspect > cropAspect) {
36 | // width ratio larger than original so cut height side
37 | val cropHeight = (srcWidth * cropAspect).toInt()
38 | return Bitmap.createBitmap(
39 | src, 0, (srcHeight - cropHeight) / 2, srcWidth, cropHeight,
40 | matrix(srcWidth, cropHeight), true)
41 | } else {
42 | val cropWidth = (srcHeight / cropAspect).toInt()
43 | return Bitmap.createBitmap(
44 | src, (srcWidth - cropWidth) / 2, 0, cropWidth, srcHeight,
45 | matrix(cropWidth, srcHeight), true)
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | .dart_tool/
27 | .flutter-plugins
28 | .flutter-plugins-dependencies
29 | .packages
30 | .pub-cache/
31 | .pub/
32 | /build/
33 |
34 | # Web related
35 | lib/generated_plugin_registrant.dart
36 |
37 | # Symbolication related
38 | app.*.symbols
39 |
40 | # Obfuscation related
41 | app.*.map.json
42 |
43 | # Android Studio will place build artifacts here
44 | /android/app/debug
45 | /android/app/profile
46 | /android/app/release
47 |
--------------------------------------------------------------------------------
/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # flutter_ml_image_transformation_example
2 |
3 | Demonstrates how to use the flutter_ml_image_transformation plugin.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
18 | ## You need to add the following assets files:
19 | - example/assets/pytorch_model/GANModelFloat32.ptl
20 | - example/assets/coreml_model/GANModelFloat16.mlmodel
21 | - example/assets/target.jpg
--------------------------------------------------------------------------------
/example/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion flutter.compileSdkVersion
30 |
31 | compileOptions {
32 | sourceCompatibility JavaVersion.VERSION_1_8
33 | targetCompatibility JavaVersion.VERSION_1_8
34 | }
35 |
36 | kotlinOptions {
37 | jvmTarget = '1.8'
38 | }
39 |
40 | sourceSets {
41 | main.java.srcDirs += 'src/main/kotlin'
42 | }
43 |
44 | defaultConfig {
45 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
46 | applicationId "com.doryan.flutter_ml_image_transformation_example"
47 | minSdkVersion 27
48 | compileSdkVersion 33
49 | versionCode flutterVersionCode.toInteger()
50 | versionName flutterVersionName
51 | }
52 |
53 | buildTypes {
54 | release {
55 | // TODO: Add your own signing config for the release build.
56 | // Signing with the debug keys for now, so `flutter run --release` works.
57 | signingConfig signingConfigs.debug
58 | minifyEnabled false
59 | shrinkResources false
60 | }
61 | }
62 | }
63 |
64 | flutter {
65 | source '../..'
66 | }
67 |
68 | dependencies {
69 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
70 |
71 | implementation "org.pytorch:pytorch_android:1.10.0"
72 | implementation "org.pytorch:pytorch_android_torchvision:1.10.0"
73 | }
74 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
15 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/example/android/app/src/main/kotlin/com/example/flutter_ml_image_transformation_example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.doryan.flutter_ml_image_transformation_example
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.6.10'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.1.2'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
7 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4 | def properties = new Properties()
5 |
6 | assert localPropertiesFile.exists()
7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
8 |
9 | def flutterSdkPath = properties.getProperty("flutter.sdk")
10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
12 |
--------------------------------------------------------------------------------
/example/assets/coreml_model/.empty:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/assets/coreml_model/.empty
--------------------------------------------------------------------------------
/example/assets/pytorch_model/.empty:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/assets/pytorch_model/.empty
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 11.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '11.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def flutter_root
14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15 | unless File.exist?(generated_xcode_build_settings_path)
16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17 | end
18 |
19 | File.foreach(generated_xcode_build_settings_path) do |line|
20 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
21 | return matches[1].strip if matches
22 | end
23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24 | end
25 |
26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27 |
28 | flutter_ios_podfile_setup
29 |
30 | target 'Runner' do
31 | use_frameworks!
32 | use_modular_headers!
33 |
34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35 | end
36 |
37 | post_install do |installer|
38 | installer.pods_project.targets.each do |target|
39 | flutter_additional_ios_build_settings(target)
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/example/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - camera_avfoundation (0.0.1):
3 | - Flutter
4 | - Flutter (1.0.0)
5 | - flutter_exif_rotation (0.3.0):
6 | - Flutter
7 | - flutter_ml_image_transformation (0.0.1):
8 | - Flutter
9 | - path_provider_foundation (0.0.1):
10 | - Flutter
11 | - FlutterMacOS
12 |
13 | DEPENDENCIES:
14 | - camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`)
15 | - Flutter (from `Flutter`)
16 | - flutter_exif_rotation (from `.symlinks/plugins/flutter_exif_rotation/ios`)
17 | - flutter_ml_image_transformation (from `.symlinks/plugins/flutter_ml_image_transformation/ios`)
18 | - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
19 |
20 | EXTERNAL SOURCES:
21 | camera_avfoundation:
22 | :path: ".symlinks/plugins/camera_avfoundation/ios"
23 | Flutter:
24 | :path: Flutter
25 | flutter_exif_rotation:
26 | :path: ".symlinks/plugins/flutter_exif_rotation/ios"
27 | flutter_ml_image_transformation:
28 | :path: ".symlinks/plugins/flutter_ml_image_transformation/ios"
29 | path_provider_foundation:
30 | :path: ".symlinks/plugins/path_provider_foundation/ios"
31 |
32 | SPEC CHECKSUMS:
33 | camera_avfoundation: 07c77549ea54ad95d8581be86617c094a46280d9
34 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
35 | flutter_exif_rotation: de6b54e8bd54a687f28d6397d1a890391de41111
36 | flutter_ml_image_transformation: d60a24ea0ed3f74a9357e593f88b5dc5aba5e566
37 | path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
38 |
39 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
40 |
41 | COCOAPODS: 1.11.3
42 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 51;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
12 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
13 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
14 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
15 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
16 | BEA69C5407AD5EE6787555DF /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 929ECA30464F08CBDE041DAE /* Pods_Runner.framework */; };
17 | /* End PBXBuildFile section */
18 |
19 | /* Begin PBXCopyFilesBuildPhase section */
20 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = {
21 | isa = PBXCopyFilesBuildPhase;
22 | buildActionMask = 2147483647;
23 | dstPath = "";
24 | dstSubfolderSpec = 10;
25 | files = (
26 | );
27 | name = "Embed Frameworks";
28 | runOnlyForDeploymentPostprocessing = 0;
29 | };
30 | /* End PBXCopyFilesBuildPhase section */
31 |
32 | /* Begin PBXFileReference section */
33 | 0F0018A6F4CCAAE91BADD53E /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; };
34 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
35 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
36 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
37 | 458DF33DAE54B9D65ABD22CC /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
38 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
39 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
40 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
41 | 929ECA30464F08CBDE041DAE /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
42 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
43 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
44 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
45 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
46 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
47 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
48 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
49 | D75CB9814A9416D41949CA98 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
50 | /* End PBXFileReference section */
51 |
52 | /* Begin PBXFrameworksBuildPhase section */
53 | 97C146EB1CF9000F007C117D /* Frameworks */ = {
54 | isa = PBXFrameworksBuildPhase;
55 | buildActionMask = 2147483647;
56 | files = (
57 | BEA69C5407AD5EE6787555DF /* Pods_Runner.framework in Frameworks */,
58 | );
59 | runOnlyForDeploymentPostprocessing = 0;
60 | };
61 | /* End PBXFrameworksBuildPhase section */
62 |
63 | /* Begin PBXGroup section */
64 | 0B5B0DBC420F92367C28C993 /* Frameworks */ = {
65 | isa = PBXGroup;
66 | children = (
67 | 929ECA30464F08CBDE041DAE /* Pods_Runner.framework */,
68 | );
69 | name = Frameworks;
70 | sourceTree = "";
71 | };
72 | 5732DDCB3031687A59ABEA39 /* Pods */ = {
73 | isa = PBXGroup;
74 | children = (
75 | 458DF33DAE54B9D65ABD22CC /* Pods-Runner.debug.xcconfig */,
76 | D75CB9814A9416D41949CA98 /* Pods-Runner.release.xcconfig */,
77 | 0F0018A6F4CCAAE91BADD53E /* Pods-Runner.profile.xcconfig */,
78 | );
79 | path = Pods;
80 | sourceTree = "";
81 | };
82 | 9740EEB11CF90186004384FC /* Flutter */ = {
83 | isa = PBXGroup;
84 | children = (
85 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
86 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
87 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
88 | 9740EEB31CF90195004384FC /* Generated.xcconfig */,
89 | );
90 | name = Flutter;
91 | sourceTree = "";
92 | };
93 | 97C146E51CF9000F007C117D = {
94 | isa = PBXGroup;
95 | children = (
96 | 9740EEB11CF90186004384FC /* Flutter */,
97 | 97C146F01CF9000F007C117D /* Runner */,
98 | 97C146EF1CF9000F007C117D /* Products */,
99 | 5732DDCB3031687A59ABEA39 /* Pods */,
100 | 0B5B0DBC420F92367C28C993 /* Frameworks */,
101 | );
102 | sourceTree = "";
103 | };
104 | 97C146EF1CF9000F007C117D /* Products */ = {
105 | isa = PBXGroup;
106 | children = (
107 | 97C146EE1CF9000F007C117D /* Runner.app */,
108 | );
109 | name = Products;
110 | sourceTree = "";
111 | };
112 | 97C146F01CF9000F007C117D /* Runner */ = {
113 | isa = PBXGroup;
114 | children = (
115 | 97C146FA1CF9000F007C117D /* Main.storyboard */,
116 | 97C146FD1CF9000F007C117D /* Assets.xcassets */,
117 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
118 | 97C147021CF9000F007C117D /* Info.plist */,
119 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
120 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
121 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
122 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
123 | );
124 | path = Runner;
125 | sourceTree = "";
126 | };
127 | /* End PBXGroup section */
128 |
129 | /* Begin PBXNativeTarget section */
130 | 97C146ED1CF9000F007C117D /* Runner */ = {
131 | isa = PBXNativeTarget;
132 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
133 | buildPhases = (
134 | D2E7D4E1996C47D764613700 /* [CP] Check Pods Manifest.lock */,
135 | 9740EEB61CF901F6004384FC /* Run Script */,
136 | 97C146EA1CF9000F007C117D /* Sources */,
137 | 97C146EB1CF9000F007C117D /* Frameworks */,
138 | 97C146EC1CF9000F007C117D /* Resources */,
139 | 9705A1C41CF9048500538489 /* Embed Frameworks */,
140 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
141 | 48D71C15950028B09759CB42 /* [CP] Embed Pods Frameworks */,
142 | );
143 | buildRules = (
144 | );
145 | dependencies = (
146 | );
147 | name = Runner;
148 | productName = Runner;
149 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
150 | productType = "com.apple.product-type.application";
151 | };
152 | /* End PBXNativeTarget section */
153 |
154 | /* Begin PBXProject section */
155 | 97C146E61CF9000F007C117D /* Project object */ = {
156 | isa = PBXProject;
157 | attributes = {
158 | LastUpgradeCheck = 1300;
159 | ORGANIZATIONNAME = "";
160 | TargetAttributes = {
161 | 97C146ED1CF9000F007C117D = {
162 | CreatedOnToolsVersion = 7.3.1;
163 | LastSwiftMigration = 1100;
164 | };
165 | };
166 | };
167 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
168 | compatibilityVersion = "Xcode 9.3";
169 | developmentRegion = en;
170 | hasScannedForEncodings = 0;
171 | knownRegions = (
172 | en,
173 | Base,
174 | );
175 | mainGroup = 97C146E51CF9000F007C117D;
176 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
177 | projectDirPath = "";
178 | projectRoot = "";
179 | targets = (
180 | 97C146ED1CF9000F007C117D /* Runner */,
181 | );
182 | };
183 | /* End PBXProject section */
184 |
185 | /* Begin PBXResourcesBuildPhase section */
186 | 97C146EC1CF9000F007C117D /* Resources */ = {
187 | isa = PBXResourcesBuildPhase;
188 | buildActionMask = 2147483647;
189 | files = (
190 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
191 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
192 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
193 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
194 | );
195 | runOnlyForDeploymentPostprocessing = 0;
196 | };
197 | /* End PBXResourcesBuildPhase section */
198 |
199 | /* Begin PBXShellScriptBuildPhase section */
200 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
201 | isa = PBXShellScriptBuildPhase;
202 | buildActionMask = 2147483647;
203 | files = (
204 | );
205 | inputPaths = (
206 | );
207 | name = "Thin Binary";
208 | outputPaths = (
209 | );
210 | runOnlyForDeploymentPostprocessing = 0;
211 | shellPath = /bin/sh;
212 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
213 | };
214 | 48D71C15950028B09759CB42 /* [CP] Embed Pods Frameworks */ = {
215 | isa = PBXShellScriptBuildPhase;
216 | buildActionMask = 2147483647;
217 | files = (
218 | );
219 | inputFileListPaths = (
220 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
221 | );
222 | name = "[CP] Embed Pods Frameworks";
223 | outputFileListPaths = (
224 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
225 | );
226 | runOnlyForDeploymentPostprocessing = 0;
227 | shellPath = /bin/sh;
228 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
229 | showEnvVarsInLog = 0;
230 | };
231 | 9740EEB61CF901F6004384FC /* Run Script */ = {
232 | isa = PBXShellScriptBuildPhase;
233 | buildActionMask = 2147483647;
234 | files = (
235 | );
236 | inputPaths = (
237 | );
238 | name = "Run Script";
239 | outputPaths = (
240 | );
241 | runOnlyForDeploymentPostprocessing = 0;
242 | shellPath = /bin/sh;
243 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
244 | };
245 | D2E7D4E1996C47D764613700 /* [CP] Check Pods Manifest.lock */ = {
246 | isa = PBXShellScriptBuildPhase;
247 | buildActionMask = 2147483647;
248 | files = (
249 | );
250 | inputFileListPaths = (
251 | );
252 | inputPaths = (
253 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
254 | "${PODS_ROOT}/Manifest.lock",
255 | );
256 | name = "[CP] Check Pods Manifest.lock";
257 | outputFileListPaths = (
258 | );
259 | outputPaths = (
260 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
261 | );
262 | runOnlyForDeploymentPostprocessing = 0;
263 | shellPath = /bin/sh;
264 | 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";
265 | showEnvVarsInLog = 0;
266 | };
267 | /* End PBXShellScriptBuildPhase section */
268 |
269 | /* Begin PBXSourcesBuildPhase section */
270 | 97C146EA1CF9000F007C117D /* Sources */ = {
271 | isa = PBXSourcesBuildPhase;
272 | buildActionMask = 2147483647;
273 | files = (
274 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
275 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
276 | );
277 | runOnlyForDeploymentPostprocessing = 0;
278 | };
279 | /* End PBXSourcesBuildPhase section */
280 |
281 | /* Begin PBXVariantGroup section */
282 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = {
283 | isa = PBXVariantGroup;
284 | children = (
285 | 97C146FB1CF9000F007C117D /* Base */,
286 | );
287 | name = Main.storyboard;
288 | sourceTree = "";
289 | };
290 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
291 | isa = PBXVariantGroup;
292 | children = (
293 | 97C147001CF9000F007C117D /* Base */,
294 | );
295 | name = LaunchScreen.storyboard;
296 | sourceTree = "";
297 | };
298 | /* End PBXVariantGroup section */
299 |
300 | /* Begin XCBuildConfiguration section */
301 | 249021D3217E4FDB00AE95B9 /* Profile */ = {
302 | isa = XCBuildConfiguration;
303 | buildSettings = {
304 | ALWAYS_SEARCH_USER_PATHS = NO;
305 | CLANG_ANALYZER_NONNULL = YES;
306 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
307 | CLANG_CXX_LIBRARY = "libc++";
308 | CLANG_ENABLE_MODULES = YES;
309 | CLANG_ENABLE_OBJC_ARC = YES;
310 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
311 | CLANG_WARN_BOOL_CONVERSION = YES;
312 | CLANG_WARN_COMMA = YES;
313 | CLANG_WARN_CONSTANT_CONVERSION = YES;
314 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
315 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
316 | CLANG_WARN_EMPTY_BODY = YES;
317 | CLANG_WARN_ENUM_CONVERSION = YES;
318 | CLANG_WARN_INFINITE_RECURSION = YES;
319 | CLANG_WARN_INT_CONVERSION = YES;
320 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
321 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
322 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
323 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
324 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
325 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
326 | CLANG_WARN_STRICT_PROTOTYPES = YES;
327 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
328 | CLANG_WARN_UNREACHABLE_CODE = YES;
329 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
330 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
331 | COPY_PHASE_STRIP = NO;
332 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
333 | ENABLE_NS_ASSERTIONS = NO;
334 | ENABLE_STRICT_OBJC_MSGSEND = YES;
335 | GCC_C_LANGUAGE_STANDARD = gnu99;
336 | GCC_NO_COMMON_BLOCKS = YES;
337 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
338 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
339 | GCC_WARN_UNDECLARED_SELECTOR = YES;
340 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
341 | GCC_WARN_UNUSED_FUNCTION = YES;
342 | GCC_WARN_UNUSED_VARIABLE = YES;
343 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
344 | MTL_ENABLE_DEBUG_INFO = NO;
345 | SDKROOT = iphoneos;
346 | SUPPORTED_PLATFORMS = iphoneos;
347 | TARGETED_DEVICE_FAMILY = "1,2";
348 | VALIDATE_PRODUCT = YES;
349 | };
350 | name = Profile;
351 | };
352 | 249021D4217E4FDB00AE95B9 /* Profile */ = {
353 | isa = XCBuildConfiguration;
354 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
355 | buildSettings = {
356 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
357 | CLANG_ENABLE_MODULES = YES;
358 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
359 | DEVELOPMENT_TEAM = B4U63C2622;
360 | ENABLE_BITCODE = NO;
361 | INFOPLIST_FILE = Runner/Info.plist;
362 | LD_RUNPATH_SEARCH_PATHS = (
363 | "$(inherited)",
364 | "@executable_path/Frameworks",
365 | );
366 | PRODUCT_BUNDLE_IDENTIFIER = com.doryan.flutterPytorchCoremlCycleganExample;
367 | PRODUCT_NAME = "$(TARGET_NAME)";
368 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
369 | SWIFT_VERSION = 5.0;
370 | VERSIONING_SYSTEM = "apple-generic";
371 | };
372 | name = Profile;
373 | };
374 | 97C147031CF9000F007C117D /* Debug */ = {
375 | isa = XCBuildConfiguration;
376 | buildSettings = {
377 | ALWAYS_SEARCH_USER_PATHS = NO;
378 | CLANG_ANALYZER_NONNULL = YES;
379 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
380 | CLANG_CXX_LIBRARY = "libc++";
381 | CLANG_ENABLE_MODULES = YES;
382 | CLANG_ENABLE_OBJC_ARC = YES;
383 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
384 | CLANG_WARN_BOOL_CONVERSION = YES;
385 | CLANG_WARN_COMMA = YES;
386 | CLANG_WARN_CONSTANT_CONVERSION = YES;
387 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
388 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
389 | CLANG_WARN_EMPTY_BODY = YES;
390 | CLANG_WARN_ENUM_CONVERSION = YES;
391 | CLANG_WARN_INFINITE_RECURSION = YES;
392 | CLANG_WARN_INT_CONVERSION = YES;
393 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
394 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
395 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
396 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
397 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
398 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
399 | CLANG_WARN_STRICT_PROTOTYPES = YES;
400 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
401 | CLANG_WARN_UNREACHABLE_CODE = YES;
402 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
403 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
404 | COPY_PHASE_STRIP = NO;
405 | DEBUG_INFORMATION_FORMAT = dwarf;
406 | ENABLE_STRICT_OBJC_MSGSEND = YES;
407 | ENABLE_TESTABILITY = YES;
408 | GCC_C_LANGUAGE_STANDARD = gnu99;
409 | GCC_DYNAMIC_NO_PIC = NO;
410 | GCC_NO_COMMON_BLOCKS = YES;
411 | GCC_OPTIMIZATION_LEVEL = 0;
412 | GCC_PREPROCESSOR_DEFINITIONS = (
413 | "DEBUG=1",
414 | "$(inherited)",
415 | );
416 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
417 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
418 | GCC_WARN_UNDECLARED_SELECTOR = YES;
419 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
420 | GCC_WARN_UNUSED_FUNCTION = YES;
421 | GCC_WARN_UNUSED_VARIABLE = YES;
422 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
423 | MTL_ENABLE_DEBUG_INFO = YES;
424 | ONLY_ACTIVE_ARCH = YES;
425 | SDKROOT = iphoneos;
426 | TARGETED_DEVICE_FAMILY = "1,2";
427 | };
428 | name = Debug;
429 | };
430 | 97C147041CF9000F007C117D /* Release */ = {
431 | isa = XCBuildConfiguration;
432 | buildSettings = {
433 | ALWAYS_SEARCH_USER_PATHS = NO;
434 | CLANG_ANALYZER_NONNULL = YES;
435 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
436 | CLANG_CXX_LIBRARY = "libc++";
437 | CLANG_ENABLE_MODULES = YES;
438 | CLANG_ENABLE_OBJC_ARC = YES;
439 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
440 | CLANG_WARN_BOOL_CONVERSION = YES;
441 | CLANG_WARN_COMMA = YES;
442 | CLANG_WARN_CONSTANT_CONVERSION = YES;
443 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
444 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
445 | CLANG_WARN_EMPTY_BODY = YES;
446 | CLANG_WARN_ENUM_CONVERSION = YES;
447 | CLANG_WARN_INFINITE_RECURSION = YES;
448 | CLANG_WARN_INT_CONVERSION = YES;
449 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
450 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
451 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
452 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
453 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
454 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
455 | CLANG_WARN_STRICT_PROTOTYPES = YES;
456 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
457 | CLANG_WARN_UNREACHABLE_CODE = YES;
458 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
459 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
460 | COPY_PHASE_STRIP = NO;
461 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
462 | ENABLE_NS_ASSERTIONS = NO;
463 | ENABLE_STRICT_OBJC_MSGSEND = YES;
464 | GCC_C_LANGUAGE_STANDARD = gnu99;
465 | GCC_NO_COMMON_BLOCKS = YES;
466 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
467 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
468 | GCC_WARN_UNDECLARED_SELECTOR = YES;
469 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
470 | GCC_WARN_UNUSED_FUNCTION = YES;
471 | GCC_WARN_UNUSED_VARIABLE = YES;
472 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
473 | MTL_ENABLE_DEBUG_INFO = NO;
474 | SDKROOT = iphoneos;
475 | SUPPORTED_PLATFORMS = iphoneos;
476 | SWIFT_COMPILATION_MODE = wholemodule;
477 | SWIFT_OPTIMIZATION_LEVEL = "-O";
478 | TARGETED_DEVICE_FAMILY = "1,2";
479 | VALIDATE_PRODUCT = YES;
480 | };
481 | name = Release;
482 | };
483 | 97C147061CF9000F007C117D /* Debug */ = {
484 | isa = XCBuildConfiguration;
485 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
486 | buildSettings = {
487 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
488 | CLANG_ENABLE_MODULES = YES;
489 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
490 | DEVELOPMENT_TEAM = B4U63C2622;
491 | ENABLE_BITCODE = NO;
492 | INFOPLIST_FILE = Runner/Info.plist;
493 | LD_RUNPATH_SEARCH_PATHS = (
494 | "$(inherited)",
495 | "@executable_path/Frameworks",
496 | );
497 | PRODUCT_BUNDLE_IDENTIFIER = com.doryan.flutterPytorchCoremlCycleganExample;
498 | PRODUCT_NAME = "$(TARGET_NAME)";
499 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
500 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
501 | SWIFT_VERSION = 5.0;
502 | VERSIONING_SYSTEM = "apple-generic";
503 | };
504 | name = Debug;
505 | };
506 | 97C147071CF9000F007C117D /* Release */ = {
507 | isa = XCBuildConfiguration;
508 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
509 | buildSettings = {
510 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
511 | CLANG_ENABLE_MODULES = YES;
512 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
513 | DEVELOPMENT_TEAM = B4U63C2622;
514 | ENABLE_BITCODE = NO;
515 | INFOPLIST_FILE = Runner/Info.plist;
516 | LD_RUNPATH_SEARCH_PATHS = (
517 | "$(inherited)",
518 | "@executable_path/Frameworks",
519 | );
520 | PRODUCT_BUNDLE_IDENTIFIER = com.doryan.flutterPytorchCoremlCycleganExample;
521 | PRODUCT_NAME = "$(TARGET_NAME)";
522 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
523 | SWIFT_VERSION = 5.0;
524 | VERSIONING_SYSTEM = "apple-generic";
525 | };
526 | name = Release;
527 | };
528 | /* End XCBuildConfiguration section */
529 |
530 | /* Begin XCConfigurationList section */
531 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
532 | isa = XCConfigurationList;
533 | buildConfigurations = (
534 | 97C147031CF9000F007C117D /* Debug */,
535 | 97C147041CF9000F007C117D /* Release */,
536 | 249021D3217E4FDB00AE95B9 /* Profile */,
537 | );
538 | defaultConfigurationIsVisible = 0;
539 | defaultConfigurationName = Release;
540 | };
541 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
542 | isa = XCConfigurationList;
543 | buildConfigurations = (
544 | 97C147061CF9000F007C117D /* Debug */,
545 | 97C147071CF9000F007C117D /* Release */,
546 | 249021D4217E4FDB00AE95B9 /* Profile */,
547 | );
548 | defaultConfigurationIsVisible = 0;
549 | defaultConfigurationName = Release;
550 | };
551 | /* End XCConfigurationList section */
552 | };
553 | rootObject = 97C146E61CF9000F007C117D /* Project object */;
554 | }
555 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
52 |
54 |
60 |
61 |
62 |
63 |
69 |
71 |
77 |
78 |
79 |
80 |
82 |
83 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | Flutter Pytorch Coreml Cyclegan
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | flutter_ml_image_transformation_example
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | $(FLUTTER_BUILD_NUMBER)
25 | LSRequiresIPhoneOS
26 |
27 | NSCameraUsageDescription
28 | Can I use camera Please ?
29 | UILaunchStoryboardName
30 | LaunchScreen
31 | UIMainStoryboardFile
32 | Main
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 | UIViewControllerBasedStatusBarAppearance
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:camera/camera.dart';
4 | import 'package:flutter/material.dart';
5 | import 'dart:async';
6 |
7 | import 'package:flutter_ml_image_transformation/flutter_ml_image_transformation.dart';
8 | import 'package:flutter_ml_image_transformation_example/ui/display_image.dart';
9 | import 'package:flutter_ml_image_transformation_example/utils/file_utils.dart';
10 |
11 | late final CameraDescription camera;
12 | Future main() async {
13 | WidgetsFlutterBinding.ensureInitialized();
14 | camera = (await availableCameras()).last;
15 | runApp(const SampleApp());
16 | }
17 |
18 | class SampleApp extends StatefulWidget {
19 | const SampleApp({Key? key}) : super(key: key);
20 |
21 | @override
22 | State createState() => _SampleAppState();
23 | }
24 |
25 | class _SampleAppState extends State {
26 | String? _modelPath;
27 |
28 | @override
29 | void initState() {
30 | super.initState();
31 | loadMLModel();
32 | }
33 |
34 | Future loadMLModel() async {
35 | try {
36 | final config = _Config();
37 | final modelPath = await FileUtils.copyAssetToAppDir(
38 | config.assetModelPath, config.appDirModelPath);
39 | final result = await MLImageTransformer.setModel(modelPath: modelPath);
40 | if (result != null) throw Exception(result);
41 | setState(() {
42 | _modelPath = modelPath;
43 | });
44 | } on Exception catch (e) {
45 | print(e);
46 | }
47 | }
48 |
49 | @override
50 | Widget build(BuildContext context) {
51 | final modelPath = _modelPath;
52 |
53 | return MaterialApp(
54 | home: Scaffold(
55 | appBar: AppBar(
56 | title: const Text('Plugin example app'),
57 | ),
58 | body: SingleChildScrollView(
59 | child: Center(
60 | child: modelPath != null
61 | ? DisplayImage(modelPath: modelPath)
62 | : const Text('model loading...')),
63 | ),
64 | ),
65 | );
66 | }
67 | }
68 |
69 | class _Config {
70 | final String assetModelPath;
71 | final String appDirModelPath;
72 |
73 | // private constructor
74 | const _Config._(this.assetModelPath, this.appDirModelPath);
75 |
76 | factory _Config() {
77 | final _Config instance;
78 | if (Platform.isAndroid) {
79 | instance = const _Config._android();
80 | } else if (Platform.isIOS) {
81 | instance = const _Config._ios();
82 | } else {
83 | throw Exception("the platform not supported; supporting ios or android");
84 | }
85 | return instance;
86 | }
87 |
88 | const _Config._android()
89 | : this._('assets/pytorch_model/GANModelFloat32.ptl', 'GANModel.ptl');
90 |
91 | const _Config._ios()
92 | : this._(
93 | 'assets/coreml_model/GANModelFloat16.mlmodel', 'GANModel.mlmodel');
94 | }
95 |
--------------------------------------------------------------------------------
/example/lib/ui/camera/camera.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:camera/camera.dart';
3 | import 'package:flutter_exif_rotation/flutter_exif_rotation.dart';
4 | import 'package:flutter_ml_image_transformation_example/main.dart';
5 |
6 | class CameraScreen extends StatefulWidget {
7 | const CameraScreen({Key? key}) : super(key: key);
8 |
9 | @override
10 | _CameraScreenState createState() => _CameraScreenState();
11 | }
12 |
13 | class _CameraScreenState extends State {
14 | CameraController? _controller;
15 |
16 | @override
17 | void initState() {
18 | super.initState();
19 | _init();
20 | }
21 |
22 | Future _init() async {
23 | final controller = CameraController(
24 | camera,
25 | ResolutionPreset.medium,
26 | imageFormatGroup: ImageFormatGroup.jpeg,
27 | enableAudio: false,
28 | );
29 | await controller.initialize();
30 | setState(() {
31 | _controller = controller;
32 | });
33 | }
34 |
35 | Future _takePhoto(CameraController controller) async {
36 | await controller.setFlashMode(FlashMode.off);
37 | final imageXFile = await controller.takePicture();
38 | final rotatedFile =
39 | await FlutterExifRotation.rotateImage(path: imageXFile.path);
40 | Navigator.of(context).pop(rotatedFile.path);
41 | }
42 |
43 | @override
44 | Widget build(BuildContext context) {
45 | return Scaffold(
46 | body: _controller == null
47 | ? const Center(
48 | child: CircularProgressIndicator(),
49 | )
50 | : Column(
51 | crossAxisAlignment: CrossAxisAlignment.center,
52 | children: [
53 | CameraPreview(_controller!),
54 | const SizedBox(height: 16),
55 | ElevatedButton(
56 | onPressed: () => _takePhoto(_controller!),
57 | child: const Text('take photo'),
58 | ),
59 | ],
60 | ),
61 | );
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/example/lib/ui/display_image.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:io';
3 |
4 | import 'package:flutter/material.dart';
5 | import 'package:flutter_ml_image_transformation/flutter_ml_image_transformation.dart';
6 | import 'package:flutter_ml_image_transformation_example/ui/camera/camera.dart';
7 | import 'package:flutter_ml_image_transformation_example/utils/file_utils.dart';
8 |
9 | class DisplayImage extends StatefulWidget {
10 | final String modelPath;
11 |
12 | const DisplayImage({required this.modelPath, Key? key}) : super(key: key);
13 |
14 | @override
15 | _DisplayImageState createState() => _DisplayImageState();
16 | }
17 |
18 | class _DisplayImageState extends State {
19 | Image? _imageShown;
20 | String? _imagePath;
21 | bool _isConverted = false;
22 | bool _isStarted = false;
23 | double _time = 0;
24 |
25 | Timer? _timer;
26 |
27 | @override
28 | void initState() {
29 | super.initState();
30 | loadAssetImg();
31 | }
32 |
33 | Future loadAssetImg() async {
34 | const assetImg = Image(image: AssetImage(_Const.assetPath));
35 | final imagePath =
36 | await FileUtils.copyAssetToCache(_Const.assetPath, _Const.imageName);
37 |
38 | setState(() {
39 | _imageShown = assetImg;
40 | _imagePath = imagePath;
41 | _isConverted = false;
42 | _isStarted = false;
43 | _time = 0;
44 | });
45 | }
46 |
47 | Future _openCamera() async {
48 | final path = await Navigator.of(context).push(MaterialPageRoute(
49 | builder: (_) => const CameraScreen(),
50 | ));
51 | setState(() {
52 | _imageShown = Image.file(File(path!));
53 | _imagePath = path;
54 | });
55 | }
56 |
57 | Future _convert() async {
58 | final imagePath = _imagePath;
59 | if (imagePath == null) return;
60 |
61 | if (!mounted) return;
62 | setState(() {
63 | _isStarted = true;
64 | });
65 |
66 | _timer = Timer.periodic(const Duration(milliseconds: 100), (timer) {
67 | setState(() {
68 | _time = _time + 0.1;
69 | });
70 | });
71 |
72 | final outputPath = await FileUtils.joinPathToCache(_Const.outputName);
73 |
74 | final result = await MLImageTransformer.transformImage(
75 | imagePath: imagePath,
76 | outputPath: outputPath,
77 | );
78 | _timer?.cancel();
79 | print(result ?? "no error");
80 | if (result == null) {
81 | final newImage = Image.file(File(outputPath));
82 |
83 | if (!mounted) return;
84 |
85 | setState(() {
86 | _imageShown = newImage;
87 | _imagePath = outputPath;
88 | _isConverted = true;
89 | });
90 | }
91 | }
92 |
93 | @override
94 | Widget build(BuildContext context) {
95 | // type promotion only works for local vars
96 | final imageShown = _imageShown;
97 |
98 | return imageShown != null
99 | ? Column(
100 | children: [
101 | imageShown,
102 | Row(
103 | mainAxisAlignment: MainAxisAlignment.center,
104 | children: [
105 | if (!_isConverted) ElevatedButton(
106 | onPressed: _openCamera,
107 | child: const Text('camera'),
108 | ),
109 | const SizedBox(width: 16),
110 | !_isConverted
111 | ? ElevatedButton(
112 | onPressed: !_isStarted ? _convert : null,
113 | child: const Text('convert'))
114 | : ElevatedButton(
115 | onPressed: loadAssetImg, child: const Text('reset')),
116 | const SizedBox(width: 16),
117 | Text('sec: ${_time.toStringAsFixed(1)}'),
118 | ],
119 | ),
120 | Text('image path: ${_imagePath ?? 'error path'}'),
121 | const SizedBox(height: 24),
122 | Text('model path: ${widget.modelPath}')
123 | ],
124 | )
125 | : const Text('No Images');
126 | }
127 | }
128 |
129 | class TimerWidget extends StatefulWidget {
130 | const TimerWidget({Key? key}) : super(key: key);
131 |
132 | @override
133 | _TimerWidgetState createState() => _TimerWidgetState();
134 | }
135 |
136 | class _TimerWidgetState extends State {
137 | double _time = 0;
138 | late Timer _timer;
139 |
140 | @override
141 | void initState() {
142 | super.initState();
143 | _timer = Timer.periodic(const Duration(milliseconds: 100), (timer) {
144 | setState(() {
145 | _time = _time + 0.1;
146 | });
147 | });
148 | }
149 |
150 | @override
151 | Widget build(BuildContext context) {
152 | return Container();
153 | }
154 | }
155 |
156 | class _Const {
157 | static const assetPath = 'assets/target.jpg';
158 |
159 | static const imageName = 'target.jpg';
160 | static const outputName = 'output.jpg';
161 | }
162 |
--------------------------------------------------------------------------------
/example/lib/utils/file_utils.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:flutter/services.dart';
4 | import 'package:path/path.dart';
5 | import 'package:path_provider/path_provider.dart';
6 |
7 | /// FileUtils methods have possibilities to throw an exception
8 | class FileUtils {
9 |
10 | static Future copyAssetToAppDir(String assetPath, String saveRelPath) async {
11 | final savePath = await joinPathToAppDir(saveRelPath);
12 | await copyAssetToPath(assetPath, savePath);
13 | return savePath;
14 | }
15 |
16 | static Future joinPathToAppDir(String relPath) async {
17 | final appDir = await getApplicationDocumentsDirectory();
18 | return join(appDir.path, relPath);
19 | }
20 |
21 | static Future copyAssetToCache(String assetPath, String saveRelPath) async {
22 | final savePath = await joinPathToCache(saveRelPath);
23 | await copyAssetToPath(assetPath, savePath);
24 | return savePath;
25 | }
26 |
27 | static Future joinPathToCache(String relPath) async {
28 | final appDir = await getTemporaryDirectory();
29 | return join(appDir.path, relPath);
30 | }
31 |
32 | static Future copyAssetToPath(String assetPath, String savePath) async {
33 | final data = await rootBundle.load(assetPath);
34 | final bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
35 | await File(savePath).writeAsBytes(bytes);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_ml_image_transformation_example
2 | description: Demonstrates how to use the flutter_ml_image_transformation plugin.
3 | version: 1.1.1
4 | # The following line prevents the package from being accidentally published to
5 | # pub.dev using `flutter pub publish`. This is preferred for private packages.
6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev
7 |
8 | environment:
9 | sdk: '>=2.18.5 <5.0.0'
10 | flutter: ">=2.5.0"
11 |
12 | # Dependencies specify other packages that your package needs in order to work.
13 | # To automatically upgrade your package dependencies to the latest versions
14 | # consider running `flutter pub upgrade --major-versions`. Alternatively,
15 | # dependencies can be manually updated by changing the version numbers below to
16 | # the latest version available on pub.dev. To see which dependencies have newer
17 | # versions available, run `flutter pub outdated`.
18 | dependencies:
19 | flutter:
20 | sdk: flutter
21 |
22 | flutter_ml_image_transformation:
23 | # When depending on this package from a real application you should use:
24 | # flutter_ml_image_transformation: ^x.y.z
25 | # See https://dart.dev/tools/pub/dependencies#version-constraints
26 | # The example app is bundled with the plugin so we use a path dependency on
27 | # the parent directory to use the current plugin's version.
28 | path: ../
29 |
30 | # The following adds the Cupertino Icons font to your application.
31 | # Use with the CupertinoIcons class for iOS style icons.
32 | cupertino_icons: ^1.0.2
33 |
34 | path_provider: ^2.0.11
35 | path: ^1.8.2
36 | camera: ^0.9.4+14
37 | flutter_exif_rotation: ^0.5.1
38 |
39 | dev_dependencies:
40 | flutter_test:
41 | sdk: flutter
42 |
43 | # The "flutter_lints" package below contains a set of recommended lints to
44 | # encourage good coding practices. The lint set provided by the package is
45 | # activated in the `analysis_options.yaml` file located at the root of your
46 | # package. See that file for information about deactivating specific lint
47 | # rules and activating additional ones.
48 | flutter_lints: ^1.0.0
49 |
50 | # For information on the generic Dart part of this file, see the
51 | # following page: https://dart.dev/tools/pub/pubspec
52 |
53 | # The following section is specific to Flutter.
54 | flutter:
55 |
56 | # The following line ensures that the Material Icons font is
57 | # included with your application, so that you can use the icons in
58 | # the material Icons class.
59 | uses-material-design: true
60 |
61 | # To add assets to your application, add an assets section, like this:
62 | assets:
63 | - assets/target.jpg
64 | - assets/pytorch_model/
65 | - assets/coreml_model/
66 |
67 | # An image asset can refer to one or more resolution-specific "variants", see
68 | # https://flutter.dev/assets-and-images/#resolution-aware.
69 |
70 | # For details regarding adding assets from package dependencies, see
71 | # https://flutter.dev/assets-and-images/#from-packages
72 |
73 | # To add custom fonts to your application, add a fonts section here,
74 | # in this "flutter" section. Each entry in this list should have a
75 | # "family" key with the font family name, and a "fonts" key with a
76 | # list giving the asset and other descriptors for the font. For
77 | # example:
78 | # fonts:
79 | # - family: Schyler
80 | # fonts:
81 | # - asset: fonts/Schyler-Regular.ttf
82 | # - asset: fonts/Schyler-Italic.ttf
83 | # style: italic
84 | # - family: Trajan Pro
85 | # fonts:
86 | # - asset: fonts/TrajanPro.ttf
87 | # - asset: fonts/TrajanPro_Bold.ttf
88 | # weight: 700
89 | #
90 | # For details regarding fonts from package dependencies,
91 | # see https://flutter.dev/custom-fonts/#from-packages
92 |
--------------------------------------------------------------------------------
/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:flutter_ml_image_transformation_example/main.dart';
12 |
13 | void main() {
14 | testWidgets('Verify Platform version', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(const SampleApp());
17 |
18 | // Verify that platform version is retrieved.
19 | expect(
20 | find.byWidgetPredicate(
21 | (Widget widget) => widget is Text &&
22 | widget.data!.startsWith('Running on:'),
23 | ),
24 | findsOneWidget,
25 | );
26 | });
27 | }
28 |
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/Generated.xcconfig
37 | /Flutter/ephemeral/
38 | /Flutter/flutter_export_environment.sh
--------------------------------------------------------------------------------
/ios/Assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryu38/flutter-ML-imageTransformation/7b4e5f4ed3a135d3dba2ee34cc7e90bd58ac0fea/ios/Assets/.gitkeep
--------------------------------------------------------------------------------
/ios/Classes/ChannelMethods/CMImageTransform.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CMImageTransform.swift
3 | // flutter_ml_image_transformation
4 | //
5 | // Created by no145 on 2022/01/08.
6 | //
7 |
8 | import Foundation
9 | import UIKit
10 |
11 | class CMImageTransform {
12 |
13 | static let imageUtils: ImageUtils = ImageUtilsImpl()
14 | static var mlProcessor: MLProcessor?
15 |
16 | static func setModel(modelPath: String, width: Int, height: Int) -> String? {
17 | do {
18 | if (mlProcessor == nil) {
19 | mlProcessor = try MLProcessorImpl(modelPath, width, height)
20 | }
21 | return nil
22 | } catch let error {
23 | return error.localizedDescription
24 | }
25 | }
26 |
27 | static func transformImage(
28 | imagePath: String, outputPath: String) -> String? {
29 | do {
30 | guard let mlProcessor = self.mlProcessor else {
31 | throw AppError.nilResult("a model is not set")
32 | }
33 | let src = try imageUtils.loadImage(path: imagePath)
34 | let input = src.centerCropScale(
35 | width: mlProcessor.width, height: mlProcessor.height)
36 | let output = try mlProcessor.process(image: input)
37 | try imageUtils.saveImage(image: output, path: outputPath)
38 | return nil
39 | } catch let error {
40 | return error.localizedDescription
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ios/Classes/Extension/AppError.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppError.swift
3 | // flutter_ml_image_transformation
4 | //
5 | // Created by no145 on 2022/01/09.
6 | //
7 |
8 | import Foundation
9 |
10 | enum AppError: LocalizedError, Error {
11 | case nilResult(String)
12 |
13 | var errorDescription: String? {
14 | switch self {
15 | case .nilResult(let message): return message
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ios/Classes/Extension/ImageExtension.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ImageExtension.swift
3 | // flutter_ml_image_transformation
4 | //
5 | // Created by no145 on 2022/01/09.
6 | //
7 |
8 | import Foundation
9 | import VideoToolbox
10 |
11 | extension CIImage {
12 |
13 | func centerCropScale(width: Int, height: Int) -> CIImage {
14 | let width = CGFloat(width)
15 | let height = CGFloat(height)
16 |
17 | let srcWidth = self.extent.width
18 | let srcHeight = self.extent.height
19 |
20 | let srcAspect = srcHeight / srcWidth
21 | let cropAspect = height / width
22 |
23 | let resizedImage: CIImage
24 | if srcAspect > cropAspect {
25 | let cropHeight = srcWidth * cropAspect
26 | let croppedImage = self.cropped(to: CGRect(
27 | x: 0, y: ceil((srcHeight - cropHeight) / 2),
28 | width: srcWidth, height: cropHeight))
29 | resizedImage = croppedImage.transformed(by: CGAffineTransform(
30 | scaleX: width / srcWidth, y: height / cropHeight))
31 | } else {
32 | let cropWidth = srcHeight / cropAspect
33 | let croppedImage = self.cropped(to: CGRect(
34 | x: ceil((srcWidth - cropWidth) / 2), y: 0,
35 | width: cropWidth, height: srcHeight))
36 | resizedImage = croppedImage.transformed(by: CGAffineTransform(
37 | scaleX: width / cropWidth, y: height / srcHeight))
38 | }
39 | return resizedImage.cropped(to: CGRect(
40 | x: resizedImage.extent.minX, y: resizedImage.extent.minY,
41 | width: width, height: height))
42 | }
43 | }
44 |
45 | extension UIImage {
46 | /**
47 | Creates a new UIImage from a CVPixelBuffer.
48 | - Note: Not all CVPixelBuffer pixel formats support conversion into a
49 | CGImage-compatible pixel format.
50 | */
51 | public convenience init?(pixelBuffer: CVPixelBuffer) {
52 | if let cgImage = CGImage.create(pixelBuffer: pixelBuffer) {
53 | self.init(cgImage: cgImage)
54 | } else {
55 | return nil
56 | }
57 | }
58 | }
59 |
60 | extension CGImage {
61 | /**
62 | Creates a new CGImage from a CVPixelBuffer.
63 | - Note: Not all CVPixelBuffer pixel formats support conversion into a
64 | CGImage-compatible pixel format.
65 | */
66 | public static func create(pixelBuffer: CVPixelBuffer) -> CGImage? {
67 | var cgImage: CGImage?
68 | VTCreateCGImageFromCVPixelBuffer(pixelBuffer, options: nil, imageOut: &cgImage)
69 | return cgImage
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/ios/Classes/FlutterPytorchCoremlCycleganPlugin.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface FlutterPytorchCoremlCycleganPlugin : NSObject
4 | @end
5 |
--------------------------------------------------------------------------------
/ios/Classes/FlutterPytorchCoremlCycleganPlugin.m:
--------------------------------------------------------------------------------
1 | #import "FlutterPytorchCoremlCycleganPlugin.h"
2 | #if __has_include()
3 | #import
4 | #else
5 | // Support project import fallback if the generated compatibility header
6 | // is not copied when this plugin is created as a library.
7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
8 | #import "flutter_ml_image_transformation-Swift.h"
9 | #endif
10 |
11 | @implementation FlutterPytorchCoremlCycleganPlugin
12 | + (void)registerWithRegistrar:(NSObject*)registrar {
13 | [SwiftFlutterPytorchCoremlCycleganPlugin registerWithRegistrar:registrar];
14 | }
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/Classes/SwiftFlutterPytorchCoremlCycleganPlugin.swift:
--------------------------------------------------------------------------------
1 | import Flutter
2 | import UIKit
3 |
4 | public class SwiftFlutterPytorchCoremlCycleganPlugin: NSObject, FlutterPlugin {
5 | public static func register(with registrar: FlutterPluginRegistrar) {
6 | let channel = FlutterMethodChannel(
7 | name: "flutter_ml_image_transformation",
8 | binaryMessenger: registrar.messenger()
9 | )
10 | let instance = SwiftFlutterPytorchCoremlCycleganPlugin()
11 | registrar.addMethodCallDelegate(instance, channel: channel)
12 | }
13 |
14 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
15 | switch call.method {
16 | case "setModel":
17 | let params = call.arguments as! Dictionary
18 | let modelPath = params["modelPath"] as! String
19 | let width = params["inputWidth"] as! Int
20 | let height = params["inputHeight"] as! Int
21 | result(CMImageTransform.setModel(
22 | modelPath: modelPath, width: width, height: height
23 | ))
24 | case "transformImage":
25 | let params = call.arguments as! Dictionary
26 | let imagePath = params["imagePath"] as! String
27 | let outputPath = params["outputPath"] as! String
28 | result(CMImageTransform.transformImage(
29 | imagePath: imagePath, outputPath: outputPath
30 | ))
31 | default:
32 | result(FlutterMethodNotImplemented)
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ios/Classes/ml/MLProcessor.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GANProcessor.swift
3 | // flutter_ml_image_transformation
4 | //
5 | // Created by no145 on 2022/01/08.
6 | //
7 |
8 | import Foundation
9 | import Vision
10 |
11 | protocol MLProcessor {
12 |
13 | var width: Int { get }
14 | var height: Int { get }
15 |
16 | func process(image: CIImage) throws -> UIImage
17 | }
18 |
--------------------------------------------------------------------------------
/ios/Classes/ml/MLProcessorImpl.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MLProcessorImpl.swift
3 | // flutter_ml_image_transformation
4 | //
5 | // Created by no145 on 2022/01/08.
6 | //
7 |
8 | import Foundation
9 | import CoreML
10 | import Vision
11 |
12 | class MLProcessorImpl: MLProcessor {
13 |
14 | let width: Int
15 | let height: Int
16 |
17 | private let _model: VNCoreMLModel
18 | private let _request: VNCoreMLRequest
19 |
20 | init(_ modelPath: String, _ width: Int, _ height: Int) throws {
21 | self.width = width
22 | self.height = height
23 | _model = try createVNModel(modelPath: modelPath)
24 | _request = VNCoreMLRequest(model: _model)
25 | _request.imageCropAndScaleOption = .centerCrop
26 | _request.usesCPUOnly = true
27 | }
28 |
29 | func process(image: CIImage) throws -> UIImage {
30 | let handler = VNImageRequestHandler(ciImage: image)
31 | try handler.perform([_request])
32 | if let result = _request.results?[0] as? VNPixelBufferObservation,
33 | let outputImage = UIImage(pixelBuffer: result.pixelBuffer) {
34 | return outputImage
35 | } else {
36 | throw AppError.nilResult("a mlprocess result is nil")
37 | }
38 | }
39 | }
40 |
41 | func createVNModel(modelPath: String) throws -> VNCoreMLModel {
42 | let modelUrl = URL.init(fileURLWithPath: modelPath)
43 | let compiledUrl = try MLModel.compileModel(at: modelUrl)
44 | let model = try MLModel(contentsOf: compiledUrl)
45 | return try VNCoreMLModel(for: model)
46 | }
47 |
--------------------------------------------------------------------------------
/ios/Classes/utils/ImageUtils.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ImageUtils.swift
3 | // flutter_ml_image_transformation
4 | //
5 | // Created by no145 on 2022/01/08.
6 | //
7 |
8 | import Foundation
9 |
10 | protocol ImageUtils {
11 |
12 | func loadImage(path: String) throws -> CIImage
13 |
14 | func saveImage(image: UIImage, path: String) throws
15 | }
16 |
--------------------------------------------------------------------------------
/ios/Classes/utils/ImageUtilsImpl.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ImageUtilsImpl.swift
3 | // flutter_ml_image_transformation
4 | //
5 | // Created by no145 on 2022/01/08.
6 | //
7 |
8 | import Foundation
9 |
10 | class ImageUtilsImpl: ImageUtils {
11 |
12 | func loadImage(path: String) throws -> CIImage {
13 | let url = URL.init(fileURLWithPath: path)
14 | let imageData = try Data(contentsOf: url)
15 | guard let image = CIImage(data: imageData) else {
16 | throw AppError.nilResult("loadImage: UIImage")
17 | }
18 | return image
19 | }
20 |
21 | func saveImage(image: UIImage, path: String) throws {
22 | guard let jpgData = image.jpegData(compressionQuality: 1.0) else {
23 | throw AppError.nilResult("fail to convert uiimage to jpg")
24 | }
25 | let url = URL.init(fileURLWithPath: path)
26 | try jpgData.write(to: url)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ios/flutter_ml_image_transformation.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
3 | # Run `pod lib lint flutter_ml_image_transformation.podspec` to validate before publishing.
4 | #
5 | Pod::Spec.new do |s|
6 | s.name = 'flutter_ml_image_transformation'
7 | s.version = '0.0.1'
8 | s.summary = 'A new flutter plugin project.'
9 | s.description = <<-DESC
10 | A new flutter plugin project.
11 | DESC
12 | s.homepage = 'http://example.com'
13 | s.license = { :file => '../LICENSE' }
14 | s.author = { 'Your Company' => 'email@example.com' }
15 | s.source = { :path => '.' }
16 | s.source_files = 'Classes/**/*'
17 | s.dependency 'Flutter'
18 | s.platform = :ios, '11.0'
19 |
20 | # Flutter.framework does not contain a i386 slice.
21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
22 | s.swift_version = '5.0'
23 | end
24 |
--------------------------------------------------------------------------------
/lib/flutter_ml_image_transformation.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'dart:async';
3 |
4 | import 'package:flutter/services.dart';
5 |
6 | class MLImageTransformer {
7 | static const MethodChannel _channel = MethodChannel('flutter_ml_image_transformation');
8 |
9 | static Future setModel({
10 | required String modelPath,
11 | int inputWidth = 256,
12 | int inputHeight = 256,
13 | }) async {
14 | final params = {
15 | 'modelPath': modelPath,
16 | 'inputWidth': inputWidth,
17 | 'inputHeight': inputHeight
18 | };
19 | final String? errorMessage = await _channel.invokeMethod('setModel', params);
20 | return errorMessage;
21 | }
22 |
23 | static Future transformImage({
24 | required String imagePath,
25 | required String outputPath,
26 | }) async {
27 | final params = {
28 | 'imagePath': imagePath,
29 | 'outputPath': outputPath,
30 | };
31 | final String? errorMessage = await _channel.invokeMethod('transformImage', params);
32 | return errorMessage;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_ml_image_transformation
2 | description: A new flutter plugin project.
3 | version: 0.0.1
4 | homepage:
5 |
6 | environment:
7 | sdk: '>=2.18.5 <5.0.0'
8 | flutter: ">=2.5.0"
9 |
10 | dependencies:
11 | flutter:
12 | sdk: flutter
13 |
14 | dev_dependencies:
15 | flutter_test:
16 | sdk: flutter
17 | flutter_lints: ^2.0.0
18 |
19 | # For information on the generic Dart part of this file, see the
20 | # following page: https://dart.dev/tools/pub/pubspec
21 |
22 | # The following section is specific to Flutter.
23 | flutter:
24 | # This section identifies this Flutter project as a plugin project.
25 | # The 'pluginClass' and Android 'package' identifiers should not ordinarily
26 | # be modified. They are used by the tooling to maintain consistency when
27 | # adding or updating assets for this project.
28 | plugin:
29 | platforms:
30 | android:
31 | package: com.doryan.flutter_ml_image_transformation
32 | pluginClass: FlutterPytorchCoremlCycleganPlugin
33 | ios:
34 | pluginClass: FlutterPytorchCoremlCycleganPlugin
35 |
--------------------------------------------------------------------------------
/test/flutter_ml_image_transformation_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/services.dart';
2 | import 'package:flutter_test/flutter_test.dart';
3 | import 'package:flutter_ml_image_transformation/flutter_ml_image_transformation.dart';
4 |
5 | void main() {
6 | const MethodChannel channel = MethodChannel('flutter_ml_image_transformation');
7 |
8 | TestWidgetsFlutterBinding.ensureInitialized();
9 |
10 | setUp(() {
11 | channel.setMockMethodCallHandler((MethodCall methodCall) async {
12 | return '42';
13 | });
14 | });
15 |
16 | tearDown(() {
17 | channel.setMockMethodCallHandler(null);
18 | });
19 |
20 | test('getPlatformVersion', () async {
21 | expect('42', '42');
22 | });
23 | }
24 |
--------------------------------------------------------------------------------