Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
indent_style = space
tab_width = 4

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2

# JSON files
[*.json]
indent_size = 2

# YAML files
[*.{yml,yaml}]
indent_size = 2

# Markdown files
[*.md]
trim_trailing_whitespace = false

# C# files
[*.cs]

# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true

# Indentation preferences
csharp_indent_case_contents = true
csharp_indent_switch_labels = true

# Space preferences
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true

# Using directive preferences
csharp_using_directive_placement = outside_namespace:silent

# Code style
csharp_prefer_braces = true:suggestion
csharp_prefer_simple_using_statement = true:suggestion

# Naming conventions
dotnet_naming_rule.interfaces_should_be_prefixed_with_i.severity = suggestion
dotnet_naming_rule.interfaces_should_be_prefixed_with_i.symbols = interface
dotnet_naming_rule.interfaces_should_be_prefixed_with_i.style = begins_with_i

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.capitalization = pascal_case
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and Test

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
dotnet-version: ['8.0.x']

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore --configuration Release

- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal

- name: Pack
if: matrix.os == 'ubuntu-latest'
run: dotnet pack src/BiRefNetSharp/BiRefNetSharp.csproj --configuration Release --no-build --output ./artifacts

- name: Upload artifacts
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: ./artifacts/*.nupkg
56 changes: 56 additions & 0 deletions BiRefNetSharp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BiRefNetSharp", "src\BiRefNetSharp\BiRefNetSharp.csproj", "{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{5D20AA90-6969-D8BD-9DCD-8634F4692FDA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BiRefNetSharp.Sample", "samples\BiRefNetSharp.Sample\BiRefNetSharp.Sample.csproj", "{53863F60-7577-4E9C-9A9C-0605B6B64E85}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Debug|x64.ActiveCfg = Debug|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Debug|x64.Build.0 = Debug|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Debug|x86.ActiveCfg = Debug|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Debug|x86.Build.0 = Debug|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Release|Any CPU.Build.0 = Release|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Release|x64.ActiveCfg = Release|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Release|x64.Build.0 = Release|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Release|x86.ActiveCfg = Release|Any CPU
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7}.Release|x86.Build.0 = Release|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Debug|x64.ActiveCfg = Debug|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Debug|x64.Build.0 = Debug|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Debug|x86.ActiveCfg = Debug|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Debug|x86.Build.0 = Debug|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Release|Any CPU.Build.0 = Release|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Release|x64.ActiveCfg = Release|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Release|x64.Build.0 = Release|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Release|x86.ActiveCfg = Release|Any CPU
{53863F60-7577-4E9C-9A9C-0605B6B64E85}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{321C0277-D19B-49C2-BDDB-1A974B8AA3A7} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{53863F60-7577-4E9C-9A9C-0605B6B64E85} = {5D20AA90-6969-D8BD-9DCD-8634F4692FDA}
EndGlobalSection
EndGlobal
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Changelog

All notable changes to BiRefNetSharp will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0] - 2024-12-24

### Added
- Initial release of BiRefNetSharp
- Core BiRefNetModel class for ONNX inference
- ImagePreprocessor with ImageNet normalization support
- ImagePostprocessor with mask generation and refinement
- BiRefNetHelper utilities for common operations
- Support for both synchronous and asynchronous operations
- Sample console application demonstrating usage
- Comprehensive documentation and examples
- Support for custom ONNX session options
- Background removal functionality
- Mask extraction and manipulation
- Threshold and smoothing operations
- XML documentation for IntelliSense support

### Dependencies
- Microsoft.ML.OnnxRuntime 1.19.2
- SixLabors.ImageSharp 3.1.12
- .NET 8.0

[1.0.0]: https://github.com/dogvane/BiRefNetSharp/releases/tag/v1.0.0
111 changes: 111 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Contributing to BiRefNetSharp

Thank you for your interest in contributing to BiRefNetSharp! This document provides guidelines for contributing to the project.

## How to Contribute

### Reporting Bugs

If you find a bug, please create an issue on GitHub with:
- A clear, descriptive title
- Steps to reproduce the issue
- Expected behavior
- Actual behavior
- Your environment (OS, .NET version, etc.)
- Any relevant code samples or error messages

### Suggesting Enhancements

Enhancement suggestions are welcome! Please create an issue with:
- A clear description of the enhancement
- Why it would be useful
- Any implementation ideas you have

### Pull Requests

1. Fork the repository
2. Create a new branch for your feature (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Ensure your code follows the project's coding standards
5. Add or update tests as needed
6. Update documentation if necessary
7. Commit your changes (`git commit -m 'Add amazing feature'`)
8. Push to your branch (`git push origin feature/amazing-feature`)
9. Open a Pull Request

## Development Setup

### Prerequisites

- .NET 8.0 SDK or later
- Git
- Your favorite code editor (Visual Studio, VS Code, Rider, etc.)

### Building the Project

```bash
# Clone the repository
git clone https://github.com/dogvane/BiRefNetSharp.git
cd BiRefNetSharp

# Restore dependencies
dotnet restore

# Build the solution
dotnet build

# Run the sample (requires ONNX model)
cd samples/BiRefNetSharp.Sample
dotnet run -- <model_path> <image_path>
```

## Coding Standards

### General Guidelines

- Follow standard C# coding conventions
- Use meaningful variable and method names
- Add XML documentation comments for public APIs
- Keep methods focused and concise
- Handle errors appropriately
- Dispose of resources properly

### Code Style

This project uses an `.editorconfig` file to maintain consistent code style. Key points:

- Use 4 spaces for indentation
- Place opening braces on new lines
- Use `var` when the type is obvious
- Prefer explicit accessibility modifiers
- Use `using` statements for IDisposable objects

### Documentation

- Add XML documentation comments for all public types and members
- Include `<summary>`, `<param>`, and `<returns>` tags as appropriate
- Provide code examples in documentation when helpful
- Update README.md if you add new features
- Add entries to EXAMPLES.md for new usage patterns

### Testing

Currently, this project doesn't have automated tests, but we welcome contributions in this area!

If you add tests:
- Write clear, focused test cases
- Test both success and failure scenarios
- Use descriptive test names
- Mock external dependencies where appropriate

## License

By contributing to BiRefNetSharp, you agree that your contributions will be licensed under the MIT License.

## Questions?

If you have questions about contributing, feel free to:
- Open an issue for discussion
- Reach out to the maintainers

Thank you for contributing to BiRefNetSharp! 🎉
Loading