Skip to content

Commit

Permalink
Finish Tauri & ORT Upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
bencevans committed Nov 28, 2024
1 parent fea3b31 commit c5ffc4f
Show file tree
Hide file tree
Showing 8 changed files with 897 additions and 602 deletions.
1,449 changes: 870 additions & 579 deletions src-tauri/Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ tauri-plugin-dialog = "2"
tauri-plugin-notification = "2"

[target.'cfg(target_os = "windows")'.dependencies.ort]
version = "2.0.0-rc.6"
version = "2.0.0-rc.9"
features = ["download-binaries", "cuda", "tensorrt"]

[target.'cfg(target_os = "linux")'.dependencies.ort]
version = "2.0.0-rc.6"
version = "2.0.0-rc.9"
features = ["download-binaries", "cuda", "tensorrt"]

[target.'cfg(target_os = "macos")'.dependencies]
ort = { version = "2.0.0-rc.8", features = ["download-binaries", "coreml"] }
ort = { version = "2.0.0-rc.9", features = ["download-binaries", "coreml"] }

[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-updater = "2"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "./schemas/desktop-schema.json",
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "main-capability",
"description": "Capability for the main window",
"windows": ["main"],
Expand Down
10 changes: 8 additions & 2 deletions src-tauri/capabilities/desktop.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "desktop-capability",
"windows": ["main"],
"platforms": [
"macOS",
"windows",
"linux"
],
"permissions": [
"updater:default"
"updater:default",
"core:window:allow-set-size",
"notification:allow-is-permission-granted",
"dialog:allow-open",
"dialog:allow-save"
]
}
}
2 changes: 1 addition & 1 deletion src-tauri/gen/schemas/capabilities.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"permissions":["updater:default"],"platforms":["macOS","windows","linux"]},"main-capability":{"identifier":"main-capability","description":"Capability for the main window","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-set-title"]}}
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"windows":["main"],"permissions":["updater:default","core:window:allow-set-size","notification:allow-is-permission-granted","dialog:allow-open","dialog:allow-save"],"platforms":["macOS","windows","linux"]},"main-capability":{"identifier":"main-capability","description":"Capability for the main window","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-set-title"]}}
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ async fn process(
/// and the window is hidden by default.
#[tauri::command]
async fn showup(window: Window) {
window.get_window("main").unwrap().show().unwrap();
window.get_webview_window("main").unwrap().show().unwrap();
}

fn main() {
Expand Down
11 changes: 6 additions & 5 deletions src-tauri/src/yolov5/model.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use image::imageops::FilterType;
use image::{DynamicImage, GenericImageView};
use ndarray::{s, Array, Axis};
use ort::{ExecutionProvider, Session};
use ort::execution_providers::{CUDAExecutionProvider, CoreMLExecutionProvider, DirectMLExecutionProvider, ExecutionProvider, TensorRTExecutionProvider};
use ort::session::Session;
use serde::{Deserialize, Serialize};

pub struct YoloModel {
Expand Down Expand Up @@ -41,21 +42,21 @@ impl YoloModel {
) -> Result<Self, Box<dyn std::error::Error>> {
println!("Loading model");

let coreml = ort::CoreMLExecutionProvider::default()
let coreml = CoreMLExecutionProvider::default()
.with_ane_only()
.with_subgraphs();
println!("CoreML available: {:?}", coreml.is_available().unwrap());

let tensor_rt = ort::TensorRTExecutionProvider::default();
let tensor_rt = TensorRTExecutionProvider::default();
println!(
"TensorRT available: {:?}",
tensor_rt.is_available().unwrap()
);

let cuda = ort::CUDAExecutionProvider::default();
let cuda = CUDAExecutionProvider::default();
println!("CUDA available: {:?}", cuda.is_available().unwrap());

let direct_ml = ort::DirectMLExecutionProvider::default();
let direct_ml = DirectMLExecutionProvider::default();
println!(
"DirectML available: {:?}",
direct_ml.is_available().unwrap()
Expand Down
17 changes: 7 additions & 10 deletions src/components/ExportDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { open } from "@tauri-apps/plugin-dialog";
import { open, save } from "@tauri-apps/plugin-dialog";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { LogicalSize } from "@tauri-apps/api/window";
import { useEffect, useState } from "react";
Expand Down Expand Up @@ -287,10 +287,9 @@ export default function ExportDialog({ onReset }: { onReset: () => void }) {
<button
onClick={() => {
if (format.id === "image-dir") {

open({
directory: true,
})
open({
directory: true,
})
.then((outputPath) => {
if (outputPath === null || Array.isArray(outputPath)) {
return;
Expand Down Expand Up @@ -325,11 +324,9 @@ export default function ExportDialog({ onReset }: { onReset: () => void }) {
const defaultFileName =
format.id === "json" ? "ct.0.1.0.json" : "ct.0.1.0.csv";

dialog
.save({
defaultPath: defaultFileName,
})

save({
defaultPath: defaultFileName,
})
.then((outputPath) => {
if (outputPath === null || Array.isArray(outputPath)) {
return;
Expand Down

0 comments on commit c5ffc4f

Please sign in to comment.