Skip to content

Commit

Permalink
Fixed Has everything become outdated? #130 (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHauschildt authored Aug 7, 2024
1 parent f802bb2 commit c9f7e5c
Show file tree
Hide file tree
Showing 22 changed files with 93 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21.x]
node-version: [20.x]
steps:
- uses: actions/checkout@v3
with:
Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.5.3",
"version": "1.5.5",
"name": "workspace",
"workspaces": [
"packages/web",
Expand Down Expand Up @@ -38,7 +38,7 @@
"meow": "~13.0.0",
"moment": "~2.29.4",
"onchange": "~7.1.0",
"prettier": "3.2.5",
"prettier": "^3.2.5",
"yaml": "~2.3.4"
}
}
2 changes: 1 addition & 1 deletion packages/node-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"@imgly/background-removal-node": "file:../node",
"jest": "^29.6.2"
},
"version": "1.5.3"
"version": "1.5.5"
}
2 changes: 1 addition & 1 deletion packages/node-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"@imgly/background-removal-node": "file:../node",
"uuidv4": "^6.2.13"
},
"version": "1.5.3"
"version": "1.5.5"
}
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@imgly/background-removal-node",
"version": "1.5.3",
"version": "1.5.5",
"description": "Background Removal in NodeJS",
"resources": "@imgly/background-removal-node",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/web-data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@imgly/background-removal-data",
"version": "1.5.3",
"version": "1.5.5",
"description": "Background Removal Data",
"keywords": [
"background-removal",
Expand Down
8 changes: 4 additions & 4 deletions packages/web-examples/vite-project/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/web-examples/vite-project/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vite-project",
"private": true,
"version": "1.5.3",
"version": "1.5.5",
"type": "module",
"scripts": {
"start": "npm run dev",
Expand Down
6 changes: 3 additions & 3 deletions packages/web-examples/vite-project/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ export default {
onMounted(async () => {
// Optional Preload all assets
// await preload(config).then(() => {
// console.log('Asset preloading succeeded');
// });
await preload(config).then(() => {
console.log('Asset preloading succeeded');
});
if (isRunning.value) {
interval = setInterval(() => {
seconds.value = calculateSecondsBetweenDates(
Expand Down
2 changes: 1 addition & 1 deletion packages/web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project 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).

## [Unreleased]
## [1.5.0]

### Added

Expand Down
22 changes: 7 additions & 15 deletions packages/web/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# Background Removal in the Browser

### 🚨 We are hiring 🚨

We are always looking for great people at IMG.LY. If you are working with our background removal library you might be a perfect fit! **Apply now at [IMG.LY Careers](https://img.ly/company/careers/?utm_source=github&utm_medium=readme&utm_campaign=background-removal-js)**

<p align="center">
<img src="https://img.ly/showcases/cesdk/web/s/case-thumbnail/background-removal/background-removal-0.png?utm_source=github&utm_medium=project&utm_campaign=background-removal-js" alt="background removal js showcase" />
</p>
&lt;p align="center"&gt; &lt;img src="https://img.ly/showcases/cesdk/web/s/case-thumbnail/background-removal/background-removal-0.png?utm_source=github&utm_medium=project&utm_campaign=background-removal-js" alt="background removal js showcase" /&gt; &lt;/p&gt;

Remove backgrounds from images directly in the browser environment with ease and no additional costs or privacy concerns.
Explore an [interactive demo](https://img.ly/showcases/cesdk/web/background-removal/web?utm_source=github&utm_medium=project&utm_campaign=background-removal-js).
Remove backgrounds from images directly in the browser environment with ease and no additional costs or privacy concerns. Explore an [interactive demo](https://img.ly/showcases/cesdk/web/background-removal/web?utm_source=github&utm_medium=project&utm_campaign=background-removal-js).

## News

Expand Down Expand Up @@ -64,7 +59,7 @@ type Config = {
debug: bool; // enable or disable useful console.log outputs
device: 'cpu' | 'gpu'; // choose the execution device. gpu will use webgpu if available
proxyToWorker: bool; // Whether to proxy the calculations to a web worker. (Default true)
model: 'small' | 'medium'; // The model to use. (Default "medium")
model: 'isnet' | 'isnet_fp16' | 'isnet_quint8'; // The model to use. (Default "isnet_fp16")
output: {
format: 'image/png' | 'image/jpeg' | 'image/webp'; // The output format. (Default "image/png")
quality: number; // The quality. (Default: 0.8)
Expand All @@ -77,8 +72,8 @@ type Config = {

The onnx model is shipped in various sizes and needs.

- small (~40 MB) is the smallest model and is in most cases working fine but sometimes shows some artifacts. It's a quantized model.
- medium (~80MB) is the default model.
- small (\~40 MB) is the smallest model and is in most cases working fine but sometimes shows some artifacts. It's a quantized model.
- medium (\~80MB) is the default model.

### Preloading Assets

Expand All @@ -91,7 +86,6 @@ const config: Configuration = ...;
preload(config).then(() => {
console.log("Asset preloading succeeded")
})

```

### Download Progress Monitoring
Expand Down Expand Up @@ -119,8 +113,7 @@ The performance is largely dependent on the feature set available. Most prominen

The wasm and onnx neural networks are hosted by IMG.LY by default. For production use, we advise you to host them yourself:

- Download the following package with the package version that matches your `@imgly/background-removal` version from the IMG.LY CDN and decompress it. Note that you need to replace `YOUR_PACKAGE_VERSION` with the actual version of the package you are using. The URL is
`https://staticimgly.com/@imgly/background-removal-data/YOUR_PACKAGE_VERSION/package.tgz`.
- Download the following package with the package version that matches your `@imgly/background-removal` version from the IMG.LY CDN and decompress it. Note that you need to replace `YOUR_PACKAGE_VERSION` with the actual version of the package you are using. The URL is `https://staticimgly.com/@imgly/background-removal-data/YOUR_PACKAGE_VERSION/package.tgz`.
- Move the content of the `package/dist` folder to be served by your web server. This often is the `/public` folder.

```typescript
Expand Down Expand Up @@ -185,5 +178,4 @@ The software is free for use under the AGPL License. Please contact [support@img

## Authors & Contributors

This library is made by IMG.LY shipping the world's premier SDKs for building creative applications.
Start your trial of the [CreativeEditor SDK](https://img.ly/products/creative-sdk?utm_source=github&utm_medium=project&utm_campaign=background-removal-js), [PhotoEditor SDK](https://img.ly/products/photo-sdk?utm_source=github&utm_medium=project&utm_campaign=background-removal-js) & [VideoEditor SDK](https://img.ly/products/video-sdk?utm_source=github&utm_medium=project&utm_campaign=background-removal-js).
This library is made by IMG.LY shipping the world's premier SDKs for building creative applications. Start your trial of the [CreativeEditor SDK](https://img.ly/products/creative-sdk?utm_source=github&utm_medium=project&utm_campaign=background-removal-js), [PhotoEditor SDK](https://img.ly/products/photo-sdk?utm_source=github&utm_medium=project&utm_campaign=background-removal-js) & [VideoEditor SDK](https://img.ly/products/video-sdk?utm_source=github&utm_medium=project&utm_campaign=background-removal-js).
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@imgly/background-removal",
"version": "1.5.3",
"version": "1.5.5",
"description": "Background Removal in the Browser",
"keywords": [
"background-removal",
Expand Down
41 changes: 41 additions & 0 deletions packages/web/src/MimeType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export class MimeType {
type: string = 'application/octet-stream';
params: Record<string, string> = {};

private constructor(type: string, params: Record<string, string>) {
this.type = type;
this.params = params;
}

toString(): string {
const paramsStr = [];
for (const key in this.params) {
const value = this.params[key];
paramsStr.push(`${key}=${value}`);
}
return [this.type, ...paramsStr].join(';');
}

static create(type, params: Record<string, string>): MimeType {
return new MimeType(type, params);
}

isIdentical(other: MimeType): Boolean {
return this.type === other.type && this.params === other.params;
}

isEqual(other: MimeType): Boolean {
return this.type === other.type;
}

static fromString(mimeType: string): MimeType {
const [type, ...paramsArr] = mimeType.split(';');
const params: Record<string, string> = {};

for (const param of paramsArr) {
const [key, value] = param.split('=');
params[key.trim()] = value.trim();
}
return new MimeType(type, params);
}
}
3 changes: 1 addition & 2 deletions packages/web/src/api/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import { ImageSource } from '../utils';
const init = memoize(initInference, (config) => JSON.stringify(config));

async function preload(configuration?: Config): Promise<void> {
const config = validateConfig(configuration);
await preloadResources(config);
await init(configuration);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,9 @@ export const bigInt = () =>
])
);

export const webgpu = () => navigator.gpu !== undefined;
export const webgpu = async () => {
if (navigator.gpu === undefined) return false;
const adapter = await navigator.gpu.requestAdapter();
return adapter !== null;
};
export const maxNumThreads = () => navigator.hardwareConcurrency ?? 4;
43 changes: 1 addition & 42 deletions packages/web/src/codecs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { imageEncode, imageDecode, MimeType };
import { MimeType } from './MimeType';
import { imageBitmapToImageData, createCanvas } from './utils';
import ndarray, { NdArray } from 'ndarray';

Expand Down Expand Up @@ -77,45 +78,3 @@ async function imageEncode(
throw new Error(`Invalid format: ${format}`);
}
}

class MimeType {
type: string = 'application/octet-stream';
params: Record<string, string> = {};

private constructor(type: string, params: Record<string, string>) {
this.type = type;
this.params = params;
}

toString(): string {
const paramsStr = [];
for (const key in this.params) {
const value = this.params[key];
paramsStr.push(`${key}=${value}`);
}
return [this.type, ...paramsStr].join(';');
}

static create(type, params: Record<string, string>): MimeType {
return new MimeType(type, params);
}

isIdentical(other: MimeType): Boolean {
return this.type === other.type && this.params === other.params;
}

isEqual(other: MimeType): Boolean {
return this.type === other.type;
}

static fromString(mimeType: string): MimeType {
const [type, ...paramsArr] = mimeType.split(';');
const params: Record<string, string> = {};

for (const param of paramsArr) {
const [key, value] = param.split('=');
params[key.trim()] = value.trim();
}
return new MimeType(type, params);
}
}
Loading

0 comments on commit c9f7e5c

Please sign in to comment.