Comments (2)
I have created a gui but it still requires python to be installed with all the supporting extras. This works with cuda, tensor, openvino, cpu, and dml execution providers. OpenVino is harder to get going as I cant seem to make it work with the pip module and have to use the zip located https://docs.openvino.ai/2023.3/openvino_docs_install_guides_installing_openvino_from_archive_windows.html
And then specifically tell it to use the setupvars.bat that comes with the zip. Also it seems the onnxruntime for openvino 1.17.1 does not work as there is entry point errors in the capi dll but 1.16.0 works fine.
This is some of the code that is in place for the GUI. Now I have also forked this and added extra options to the Deface tool.
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Management;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections.Generic;
namespace AnonFacesApp
{
public partial class MainForm : Form
{
private Process runningProcess;
private bool isProcessRunning;
private string lastSelectedFile;
private string ExecutionProvider;
private readonly string CudaDirectory = @"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA";
private readonly string TensorDirectory = @"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA";
private readonly string NvinferDllPath = "lib\\nvinfer.dll";
private const string KeepAudioOption = "--keep-audio";
private const string ViewPreviewOption = "--preview";
private const string ScaleOption = "--scale 1280x720";
private const string DistortAudio = "--distort-audio";
private const string rootDirectory = @"C:\Program Files (x86)\Intel";
private decimal thresh = 0.200M;
private Process ffmpegProcess;
public MainForm()
{
InitializeComponent();
this.AllowDrop = true;
this.Load += MainForm_Load;
AudioCheckBox.Checked = true;
trackBar1.Scroll += TrackBar1_Scroll;
}
private void MainForm_Load(object sender, EventArgs e)
{
// In the MainForm_Load event, set the TrackBar properties:
trackBar1.Minimum = 0;
trackBar1.Maximum = 12; // 10 steps (0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.20, 0.22)
trackBar1.LargeChange = 1;
trackBar1.SmallChange = 1;
trackBar1.TickFrequency = 1;
trackBar1.Value = 9; // 0.200 corresponds to the midddle step
UpdateLabelFromTrackBarValue(); // Update the label to reflect the default value.
List<string> availableProviders = GetAvailableProviders();
// Populate the ComboBox with the obtained providers
ExecutionComboBox.Items.AddRange(availableProviders.ToArray());
// Check if OpenVINO or CUDA are available
if (availableProviders.Contains("OpenVINOExecutionProvider"))
{
ExecutionComboBox.SelectedItem = "OpenVINOExecutionProvider";
SetExecutionProviderFromComboBox();
}
else if (availableProviders.Contains("CUDAExecutionProvider"))
{
ExecutionComboBox.SelectedItem = "CUDAExecutionProvider";
SetExecutionProviderFromComboBox();
}
else if (availableProviders.Contains("DmlExecutionProvider"))
{
ExecutionComboBox.SelectedItem = "DmlExecutionProvider";
SetExecutionProviderFromComboBox();
}
else
{
// If neither provider is available, you can set a default selection
ExecutionComboBox.SelectedItem = "CPUExecutionProvider";
SetExecutionProviderFromComboBox();
}
}
private List<string> ParseAvailableProviders(string providersString)
{
List<string> availableProviders = new List<string>();
string[] providerArray = providersString
.Replace("[", "")
.Replace("]", "")
.Replace("'", "")
.Split(',')
.Select(provider => provider.Trim())
.ToArray();
availableProviders.AddRange(providerArray);
return availableProviders;
}
private List<string> GetAvailableProviders()
{
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process
{
StartInfo = new System.Diagnostics.ProcessStartInfo
{
FileName = "python",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
Arguments = "-c \"import onnx; import onnxruntime; print(onnxruntime.get_available_providers())\""
}
};
process.Start();
string providersString = process.StandardOutput.ReadToEnd();
return ParseAvailableProviders(providersString);
}
catch (Exception)
{
// Handle the exception if needed
return new List<string>();
}
}
private void SetExecutionProviderFromComboBox()
{
int selectedProviderIndex = ExecutionComboBox.SelectedIndex;
// Get the list of available providers dynamically
List<string> availableProviders = GetAvailableProviders();
if (selectedProviderIndex >= 0 && selectedProviderIndex < availableProviders.Count)
{
// Set the execution provider based on the selected index
string selectedProvider = availableProviders[selectedProviderIndex];
// Implement logic based on the selected provider
switch (selectedProvider)
{
case "DmlExecutionProvider":
ExecutionProvider = "--ep DmlExecutionProvider";
break;
case "CPUExecutionProvider":
ExecutionProvider = "--ep CPUExecutionProvider";
break;
case "CUDAExecutionProvider":
ExecutionProvider = "--ep CUDAExecutionProvider";
break;
case "TensorrtExecutionProvider":
ExecutionProvider = "--ep TensorrtExecutionProvider";
break;
case "OpenVINOExecutionProvider":
ExecutionProvider = "--ep OpenVINOExecutionProvider";
break;
default:
// Handle the default case (e.g., show an error message)
MessageBox.Show("Invalid selection");
break;
}
}
else
{
// Handle the case where the selected index is out of bounds
MessageBox.Show("Invalid selection");
}
}```
from deface.
I have created a gui but it still requires python to be installed with all the supporting extras. This works with cuda, tensor, openvino, cpu, and dml execution providers. OpenVino is harder to get going as I cant seem to make it work with the pip module and have to use the zip located https://docs.openvino.ai/2023.3/openvino_docs_install_guides_installing_openvino_from_archive_windows.html
And then specifically tell it to use the setupvars.bat that comes with the zip. Also it seems the onnxruntime for openvino 1.17.1 does not work as there is entry point errors in the capi dll but 1.16.0 works fine.
Seems like the issue with 1.17.1 was my Python Version. I thought i had 3.11.9 but the instance was confused on the multiple versions on my machine. So this works lol
from deface.
Related Issues (20)
- error: Number of input channels should be multiple of 3 but got 4 in function 'getMemoryShapes' HOT 4
- cv2.error: OpenCV HOT 5
- Adding -vf to ffmpeg HOT 2
- Enhancement Suggestion: add timespan(s) option HOT 1
- Doesn't seem to use hardware acceleration despite it being available HOT 2
- cuda_path is set but cuda wasn't able to be loaded HOT 6
- Feature Request: Add support for Coral TPU HOT 1
- Consider switching model to centerface_bnmerged.onnx HOT 1
- OpenVino for onnxruntime-openvino HOT 3
- Error when entering images of different sizes HOT 4
- Limit mask size to filter out unrealistic false positives HOT 3
- (Question) use with live streams (rtsp)
- Output has no audio HOT 1
- [macOS] Could not open file <file> as a video file with imageio
- select faces to not be blurred HOT 8
- Videos are sped-up when anonymized HOT 2
- Failed to load library libonnxruntime_providers_tensorrt.so with error HOT 1
- [macOS] RuntimeError: Could not get number of frames HOT 2
- Add tracking as well as detection to improve speed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deface.