Skip to content

Commit

Permalink
update the doc (replace npm -> bun etc)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbilcke-hf committed Aug 15, 2024
1 parent ebea0c0 commit 6318758
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 27 deletions.
56 changes: 36 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ As a prerequisite you need to have [git lfs](https://git-lfs.com/) installed (se
git lfs install
```

You will also need to install [Bun](https://bun.sh/docs/installation)

Clapper has been tested with Node `20.15.1`.

To make sure you use this version, you can use [NVM](https://github.com/nvm-sh/nvm) to activate it:
Expand All @@ -84,39 +86,42 @@ nvm use

If you find that Clapper is working with a more recent (stable) version of Node, or have a better version management to suggest, please open a ticket.

### Installing and running the app
### Installation

Install the dependencies.

`--include=optional` is to make sure optional dependencies are installed (pre-build native modules compatible with your system)

```bash
npm i --include=optional
bun i
```

Then run the actual app, the first time you go to localhost:3000 after typing this command, the app will compile, which can take a minute (like, literally: `Compiled / in 52.6s (6372 modules)`)
You can run the following command to build the app, making sure all the types are consistant and properly set:

```bash
npm run dev
npm run build
```

### Running the web app

### Building the app

You can run the following command to build the app, making sure all the types are consistant and properly set:
Then run the actual app, the first time you go to localhost:3000 after typing this command, the app will compile, which can take a minute (like, literally: `Compiled / in 52.6s (6372 modules)`)

```bash
npm run build
bun run dev
```

### Running the app with Electron


An Electron build is in progress.

There are still some things to debug and figure out, but if you are a developer you can try it out by starting Clapper through Electron like this:


```bash
npm run electron:start
cd packages/app
bun run electron:start
```

If that doesn't work for you (issue with node-gyp, setuptools, distutils etc) you might have to run:
Expand All @@ -128,7 +133,8 @@ python3 -m pip install --break-system-packages setuptools
You can also build Clapper for your operating system by typing:

```bash
npm run electron:make
cd packages/app
bun run electron:make
```

You might see a DeprecationWarning message written in red at the end but that's only a warning, just open `./out/make` to check if the build worked.
Expand All @@ -141,7 +147,9 @@ I have setup Prettier and ESLint, they use some basic rules (you can propose new

To run all the tests (unit and e2e) please run:

`npm run test`
```bash
bun run test
```

This is not instantaneous: playwright may seems to do nothing for a while at first.

Expand All @@ -153,10 +161,18 @@ Note: I've just added Vitest so we only have a few tests for now.


To run the test without watching, type:
`npm run test:unit:ci`

```bash
cd packages/app
bun run test:unit:ci
```

To run the tests with watching, type:
`npm run test:unit:watch`

```bash
cd packages/app
bun run test:unit:watch
```

#### End-to-end tests

Expand All @@ -165,30 +181,30 @@ Note: I've just added Playwright, but we don't really have tests yet.
Please note that due to the app needing to build during 30~60s (depending on the speed of your computer), running those tests may
take some time to execute.

`npm run test:e2e`
`bun run test:e2e`

More Playwright commands:
`npx playwright test`
`bunx playwright test`
Runs the end-to-end tests.

`npx playwright test --ui`
`bunx playwright test --ui`
Starts the interactive UI mode.

`npx playwright test --project=chromium`
`bunx playwright test --project=chromium`
Runs the tests only on Desktop Chrome.

`npx playwright test example`
`bunx playwright test example`
Runs the tests in a specific file.

` npx playwright test --debug`
` bunx playwright test --debug`
Runs the tests in debug mode.

`npx playwright codegen`
`bunx playwright codegen`
Auto generate tests with Codegen.

We suggest that you begin by typing:

`npx playwright test`
`bunx playwright test`


### Architecture
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dev": "bun run --cwd packages/app dev",
"start": "bun run --cwd packages/app start",
"build": "bun run build:all",
"build:all": "bun run build:clap && bun run build:timeline && bun run build:api-client && bun run build:io && bun run build:colors && bun run build:engine && bun run build:broadway && bun run build:services && bun run build:app",
"build:all": "bun run build:clap && bun run build:timeline && bun run build:api-client && bun run build:io && bun run build:colors && bun run build:engine && bun run build:broadway && bun run build:clapper-services && bun run build:app",
"build:clap": "bun run --cwd packages/clap build",
"build:timeline": "bun run --cwd packages/timeline build",
"build:api-client": "bun run --cwd packages/api-client build",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@tailwindcss/container-queries": "^0.1.1",
"@types/dom-speech-recognition": "^0.0.4",
"@types/pngjs": "^6.0.5",
"@xenova/transformers": "github:xenova/transformers.js#v3",
"@huggingface/transformers": "3.0.0-alpha.5",
"@xyflow/react": "^12.0.3",
"autoprefixer": "10.4.19",
"base64-arraybuffer": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/public/workers/captioning.worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
importScripts('https://cdn.jsdelivr.net/npm/@xenova/transformers@3.0.0');
importScripts('https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.0.0');

const { AutoProcessor, AutoTokenizer, Moondream1ForConditionalGeneration, RawImage } = transformers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
AutoTokenizer,
Moondream1ForConditionalGeneration,
RawImage,
} from '@xenova/transformers'
Tensor,
} from '@huggingface/transformers'

export async function extractCaptionFromFrameMoondream(
imageInBase64DataUri: string
Expand Down Expand Up @@ -51,12 +52,13 @@ Linux experimental support also requires launching the browser with --enable-fea
const vision_inputs = await processor(image)

// Generate response
const output = await model.generate({
const output = (await model.generate({
...text_inputs,
...vision_inputs,
do_sample: false,
max_new_tokens: 177,
})
})) as Tensor // is that alright? I'm not sure..

const decoded = tokenizer.batch_decode(output, { skip_special_tokens: false })
console.log(decoded)
// [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// AutoTokenizer,
// Florence2ForConditionalGeneration,
// RawImage,
// } from '@xenova/transformers'
// } from '@huggingface/transformers'

export const cache: {
model?: Promise<any>
Expand Down

0 comments on commit 6318758

Please sign in to comment.