Move dependency to HEAD (#1712)
This commit is contained in:
commit
98d7302a7c
4 changed files with 12 additions and 54 deletions
|
@ -27,7 +27,7 @@ class RemoteAssetsService {
|
|||
}
|
||||
|
||||
Future<String> _getLocalPath(String remotePath) async {
|
||||
return (await getTemporaryDirectory()).path +
|
||||
return (await getApplicationSupportDirectory()).path +
|
||||
"/assets/" +
|
||||
_urlToFileName(remotePath);
|
||||
}
|
||||
|
@ -53,5 +53,6 @@ class RemoteAssetsService {
|
|||
await existingFile.delete();
|
||||
}
|
||||
await NetworkClient.instance.getDio().download(url, savePath);
|
||||
_logger.info("Downloaded " + url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,13 @@ import "dart:async";
|
|||
import "dart:io";
|
||||
|
||||
import "package:connectivity_plus/connectivity_plus.dart";
|
||||
import "package:flutter/services.dart";
|
||||
import "package:logging/logging.dart";
|
||||
import "package:path/path.dart";
|
||||
import "package:path_provider/path_provider.dart";
|
||||
import "package:photos/core/errors.dart";
|
||||
|
||||
import "package:photos/core/event_bus.dart";
|
||||
import "package:photos/core/network/network.dart";
|
||||
import "package:photos/events/event.dart";
|
||||
import "package:photos/services/remote_assets_service.dart";
|
||||
|
||||
abstract class MLFramework {
|
||||
static const kImageEncoderEnabled = true;
|
||||
|
@ -105,46 +103,20 @@ abstract class MLFramework {
|
|||
return;
|
||||
}
|
||||
_initState = InitializationState.initializingImageModel;
|
||||
final path = await _getLocalImageModelPath();
|
||||
if (await File(path).exists()) {
|
||||
await loadImageModel(path);
|
||||
} else {
|
||||
_initState = InitializationState.downloadingImageModel;
|
||||
final tempFile = File(path + ".temp");
|
||||
await _downloadFile(getImageModelRemotePath(), tempFile.path);
|
||||
await tempFile.rename(path);
|
||||
await loadImageModel(path);
|
||||
}
|
||||
final imageModel =
|
||||
await RemoteAssetsService.instance.getAsset(getImageModelRemotePath());
|
||||
await loadImageModel(imageModel.path);
|
||||
_initState = InitializationState.initializedImageModel;
|
||||
}
|
||||
|
||||
Future<void> _initTextModel() async {
|
||||
final path = await _getLocalTextModelPath();
|
||||
_initState = InitializationState.initializingTextModel;
|
||||
if (await File(path).exists()) {
|
||||
await loadTextModel(path);
|
||||
} else {
|
||||
_initState = InitializationState.downloadingTextModel;
|
||||
final tempFile = File(path + ".temp");
|
||||
await _downloadFile(getTextModelRemotePath(), tempFile.path);
|
||||
await tempFile.rename(path);
|
||||
await loadTextModel(path);
|
||||
}
|
||||
final textModel =
|
||||
await RemoteAssetsService.instance.getAsset(getTextModelRemotePath());
|
||||
await loadTextModel(textModel.path);
|
||||
_initState = InitializationState.initializedTextModel;
|
||||
}
|
||||
|
||||
Future<String> _getLocalImageModelPath() async {
|
||||
return (await getTemporaryDirectory()).path +
|
||||
"/models/" +
|
||||
basename(getImageModelRemotePath());
|
||||
}
|
||||
|
||||
Future<String> _getLocalTextModelPath() async {
|
||||
return (await getTemporaryDirectory()).path +
|
||||
"/models/" +
|
||||
basename(getTextModelRemotePath());
|
||||
}
|
||||
|
||||
Future<void> _downloadFile(
|
||||
String url,
|
||||
String savePath, {
|
||||
|
@ -176,17 +148,6 @@ abstract class MLFramework {
|
|||
return connectivityResult != ConnectivityResult.mobile ||
|
||||
shouldDownloadOverMobileData;
|
||||
}
|
||||
|
||||
Future<String> getAccessiblePathForAsset(
|
||||
String assetPath,
|
||||
String tempName,
|
||||
) async {
|
||||
final byteData = await rootBundle.load(assetPath);
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
final file = await File('${tempDir.path}/$tempName')
|
||||
.writeAsBytes(byteData.buffer.asUint8List());
|
||||
return file.path;
|
||||
}
|
||||
}
|
||||
|
||||
class MLFrameworkInitializationUpdateEvent extends Event {
|
||||
|
@ -198,10 +159,8 @@ class MLFrameworkInitializationUpdateEvent extends Event {
|
|||
enum InitializationState {
|
||||
notInitialized,
|
||||
waitingForNetwork,
|
||||
downloadingImageModel,
|
||||
initializingImageModel,
|
||||
initializedImageModel,
|
||||
downloadingTextModel,
|
||||
initializingTextModel,
|
||||
initializedTextModel,
|
||||
initialized,
|
||||
|
|
|
@ -1381,7 +1381,7 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: isolates
|
||||
ref: HEAD
|
||||
resolved-ref: "5f26aef45ed9f5e563c26f90c1e21b3339ed906d"
|
||||
url: "https://github.com/ente-io/onnxruntime.git"
|
||||
source: git
|
||||
|
|
|
@ -12,7 +12,7 @@ description: ente photos application
|
|||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
|
||||
version: 0.8.57+577
|
||||
version: 0.8.58+578
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
|
@ -118,9 +118,7 @@ dependencies:
|
|||
|
||||
# open_file: ^3.2.1
|
||||
onnxruntime:
|
||||
git:
|
||||
url: "https://github.com/ente-io/onnxruntime.git"
|
||||
ref: "isolates"
|
||||
git: "https://github.com/ente-io/onnxruntime.git"
|
||||
open_mail_app: ^0.4.5
|
||||
package_info_plus: ^4.1.0
|
||||
page_transition: ^2.0.2
|
||||
|
|
Loading…
Add table
Reference in a new issue