Skip to content

Commit 2bfbe5d

Browse files
authored
Create Electron example app README (#66)
* Create Electron README * Fix whitespace
1 parent 8abc617 commit 2bfbe5d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

electron/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
# Transformers.js - Sample Electron application
3+
4+
An example project to show how to run 🤗 Transformers in an [Electron](https://www.electronjs.org/) application.
5+
6+
## Getting Started
7+
1. Clone the repo and enter the project directory:
8+
```bash
9+
git clone https://github.com/huggingface/transformers.js-examples.git
10+
cd transformers.js-examples/electron/
11+
```
12+
13+
1. Install the necessary dependencies:
14+
```bash
15+
npm install
16+
```
17+
18+
1. Run the application:
19+
```bash
20+
npm run start
21+
```
22+
23+
After a few seconds, a new window should pop up on your screen!
24+
25+
26+
## Editing the template
27+
28+
All source code can be found in `./src/`:
29+
- `index.js` - Serves as the entry point for the application's main process. When an Electron app is launched, this is the first file that gets executed, and it is responsible for setting up the main process of the application. You will need to restart the application after editing this file for your changes to take effect.
30+
- `preload.js` - Used to preload scripts and modules in a renderer process before any other scripts run. In our case, we use the `contextBridge` API to expose the `classify` function to the renderer, which runs the model in the background. You will need to restart the application after editing this file for your changes to take effect.
31+
- `classify.js` - Contains logic for loading the model and running predictions via the `classify` function. You will need to restart the application after editing this file for your changes to take effect.
32+
33+
- `index.html`, `index.css` - The user interface that is displayed to the user, along with example code for how to call the `classify` function from the renderer process. To see changes made to this file made while editing, simply refresh the window (<kbd>Ctrl + R</kbd> or "View" &rarr; "Reload").

0 commit comments

Comments
 (0)