|
1 | 1 | # OnnxStack.FeatureExtractor
|
2 | 2 |
|
3 |
| -## Canny |
4 |
| -https://huggingface.co/axodoxian/controlnet_onnx/resolve/main/annotators/canny.onnx |
| 3 | +### Canny |
| 4 | +* https://huggingface.co/axodoxian/controlnet_onnx/resolve/main/annotators/canny.onnx |
5 | 5 |
|
6 |
| -## Hed |
7 |
| -https://huggingface.co/axodoxian/controlnet_onnx/resolve/main/annotators/hed.onnx |
| 6 | +### Hed |
| 7 | +* https://huggingface.co/axodoxian/controlnet_onnx/resolve/main/annotators/hed.onnx |
8 | 8 |
|
9 |
| -## Depth |
10 |
| -https://huggingface.co/axodoxian/controlnet_onnx/resolve/main/annotators/depth.onnx |
11 |
| -https://huggingface.co/Xenova/depth-anything-large-hf/onnx/model.onnx |
12 |
| -https://huggingface.co/julienkay/sentis-MiDaS |
| 9 | +### Depth |
| 10 | +* https://huggingface.co/axodoxian/controlnet_onnx/resolve/main/annotators/depth.onnx |
| 11 | +* https://huggingface.co/Xenova/depth-anything-large-hf/onnx/model.onnx |
| 12 | +* https://huggingface.co/julienkay/sentis-MiDaS |
13 | 13 |
|
14 |
| -## OpenPose (TODO) |
15 |
| -https://huggingface.co/axodoxian/controlnet_onnx/resolve/main/annotators/openpose.onnx |
| 14 | +### OpenPose (TODO) |
| 15 | +* https://huggingface.co/axodoxian/controlnet_onnx/resolve/main/annotators/openpose.onnx |
16 | 16 |
|
17 | 17 | # Image Example
|
18 | 18 | ```csharp
|
19 |
| - |
20 | 19 | // Load Input Image
|
21 | 20 | var inputImage = await OnnxImage.FromFileAsync("Input.png");
|
22 | 21 |
|
23 | 22 | // Load Pipeline
|
24 | 23 | var pipeline = FeatureExtractorPipeline.CreatePipeline("canny.onnx");
|
25 | 24 |
|
26 | 25 | // Run Pipeline
|
27 |
| -var imageFeature = await pipeline.RunAsync(inputImage); |
| 26 | +var result = await pipeline.RunAsync(inputImage); |
28 | 27 |
|
29 | 28 | // Save Image
|
30 |
| -await imageFeature.Image.SaveAsync("Result.png"); |
| 29 | +await result.SaveAsync("Result.png"); |
31 | 30 |
|
32 | 31 | //Unload
|
33 | 32 | await pipeline.UnloadAsync();
|
34 | 33 | ```
|
35 | 34 |
|
36 | 35 | # Video Example
|
37 | 36 | ```csharp
|
38 |
| - |
39 |
| -// Load Input Video |
40 |
| -var inputVideo = await OnnxVideo.FromFileAsync("Input.mp4"); |
| 37 | +// Load Input Image |
| 38 | +var inputImage = await OnnxVideo.FromFileAsync("Input.mp4"); |
41 | 39 |
|
42 | 40 | // Load Pipeline
|
43 | 41 | var pipeline = FeatureExtractorPipeline.CreatePipeline("canny.onnx");
|
44 | 42 |
|
45 | 43 | // Run Pipeline
|
46 |
| -var videoFeature = await pipeline.RunAsync(inputVideo); |
| 44 | +var result = await pipeline.RunAsync(inputImage); |
| 45 | + |
| 46 | +// Save Image |
| 47 | +await result.SaveAsync("Result.mp4"); |
| 48 | + |
| 49 | +//Unload |
| 50 | +await pipeline.UnloadAsync(); |
| 51 | + ``` |
| 52 | + |
| 53 | + # Video Stream Example |
| 54 | +```csharp |
| 55 | +// Read Video Info |
| 56 | +var videoFile = "Input.mp4"; |
| 57 | +var videoInfo = await VideoHelper.ReadVideoInfoAsync(videoFile); |
| 58 | + |
| 59 | +// Create Video Stream |
| 60 | +var videoStream = VideoHelper.ReadVideoStreamAsync(videoFile, videoInfo.FrameRate); |
| 61 | + |
| 62 | +// Create pipeline |
| 63 | +var pipeline = FeatureExtractorPipeline.CreatePipeline("canny.onnx"); |
| 64 | + |
| 65 | +// Create Pipeline Stream |
| 66 | +var pipelineStream = pipeline.RunAsync(videoStream); |
47 | 67 |
|
48 |
| -// Save Video |
49 |
| -await videoFeature.SaveAsync("Result.mp4"); |
| 68 | +// Write Video Stream |
| 69 | +await VideoHelper.WriteVideoStreamAsync(videoInfo, pipelineStream, "Result.mp4"); |
50 | 70 |
|
51 | 71 | //Unload
|
52 | 72 | await pipeline.UnloadAsync();
|
|
0 commit comments