Skip to content

Commit a66f226

Browse files
committed
Update docs and model urls
1 parent 214b532 commit a66f226

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

apps/computer-vision/app/text_to_image/index.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from 'react-native';
99
import React, { useContext, useEffect, useState } from 'react';
1010
import Spinner from 'react-native-loading-spinner-overlay';
11-
import { useTextToImage, BK_SDM_TINY_VPRED } from 'react-native-executorch';
11+
import { useTextToImage, BK_SDM_TINY_VPRED_256 } from 'react-native-executorch';
1212
import { GeneratingContext } from '../../context';
1313
import ColorPalette from '../../colors';
1414
import ProgressBar from '../../components/ProgressBar';
@@ -22,9 +22,9 @@ export default function TextToImageScreen() {
2222
const [showTextInput, setShowTextInput] = useState(false);
2323
const [keyboardVisible, setKeyboardVisible] = useState(false);
2424

25-
const imageSize = 352;
25+
const imageSize = 224;
2626
const model = useTextToImage({
27-
model: BK_SDM_TINY_VPRED,
27+
model: BK_SDM_TINY_VPRED_256,
2828
inferenceCallback: (x) => setInferenceStepIdx(x),
2929
});
3030

@@ -53,10 +53,7 @@ export default function TextToImageScreen() {
5353
setSteps(numSteps);
5454
try {
5555
const output = await model.generate(input, imageSize, steps);
56-
console.log('Is output?', !!output);
57-
console.log(output);
5856
if (!output.length) {
59-
console.log('interrupted');
6057
setImageTitle(null);
6158
return;
6259
}

docs/docs/02-hooks/02-computer-vision/useTextToImage.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ It is recommended to use models provided by us which are available at our Huggin
1515
## Reference
1616

1717
```typescript
18-
import { useTextToImage, BK_SDM_TINY_VPRED } from 'react-native-executorch';
18+
import { useTextToImage, BK_SDM_TINY_VPRED_256 } from 'react-native-executorch';
1919

20-
const model = useTextToImage({ model: BK_SDM_TINY_VPRED });
20+
const model = useTextToImage({ model: BK_SDM_TINY_VPRED_256 });
2121

2222
const input = 'a castle';
2323

@@ -61,9 +61,7 @@ For more information on loading resources, take a look at [loading models](../..
6161

6262
To run the model, you can use the `forward` method. It accepts four arguments: a text prompt describing the requested image, a size of the image in pixels, a number of denoising steps, and an optional seed value, which enables reproducibility of the results.
6363

64-
The image size must fall within the range from 128 to 512 unless specified differently, and be a multiple of 32 due to the architecture of the U-Net and VAE models.
65-
66-
The seed should be a positive integer.
64+
The image size must be a multiple of 32 due to the architecture of the U-Net and VAE models. The seed should be a positive integer.
6765

6866
:::warning
6967
Larger imageSize values require significantly more memory to run the model.
@@ -72,10 +70,10 @@ Larger imageSize values require significantly more memory to run the model.
7270
## Example
7371

7472
```tsx
75-
import { useTextToImage, BK_SDM_TINY_VPRED } from 'react-native-executorch';
73+
import { useTextToImage, BK_SDM_TINY_VPRED_256 } from 'react-native-executorch';
7674

7775
function App() {
78-
const model = useTextToImage({ model: BK_SDM_TINY_VPRED });
76+
const model = useTextToImage({ model: BK_SDM_TINY_VPRED_256 });
7977

8078
//...
8179
const input = 'a medieval castle by the sea shore';
@@ -104,26 +102,25 @@ function App() {
104102
| ------------------------------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
105103
| [bk-sdm-tiny-vpred](https://huggingface.co/vivym/bk-sdm-tiny-vpred) | 0.5 | BK-SDM (Block-removed Knowledge-distilled Stable Diffusion Model) is a compressed version of Stable Diffusion v1.4 with several residual and attention blocks removed. The BK-SDM-Tiny is a v-prediction variant of the model, obtained through further block removal, built around a 0.33B-parameter U-Net. |
106104

107-
|
108-
109105
## Benchmarks
110106

111107
:::info
112-
The number following the underscore (\_) specifies that the model is exported with a static image size. This helps optimize memory usage by allocating only as much as needed. In contrast, models exported with dynamic shapes allocate memory up to the maximum allowed image dimensions, which can be less efficient. This setting has no effect on the actual model size, only on how memory is allocated at runtime.
108+
The number following the underscore (\_) indicates that the model supports generating image with dimensions ranging from 128 pixels up to that value. This setting doesn’t affect the model’s file size - it only determines how memory is allocated at runtime, based on the maximum allowed image size.
113109
:::
114110

115111
### Model size
116112

117-
| Model | Text encoder (XNNPACK) [MB] | UNet (XNNPACK) [MB] | VAE decoder (XNNPACK) [MB] |
118-
| ----------------- | --------------------------- | ------------------- | -------------------------- |
119-
| BK_SDM_TINY_VPRED | 492 | 1290 | 198 |
113+
| Model | Text encoder (XNNPACK) [MB] | UNet (XNNPACK) [MB] | VAE decoder (XNNPACK) [MB] |
114+
| --------------------- | --------------------------- | ------------------- | -------------------------- |
115+
| BK_SDM_TINY_VPRED_256 | 492 | 1290 | 198 |
116+
| BK_SDM_TINY_VPRED_512 | 492 | 1290 | 198 |
120117

121118
### Memory usage
122119

123120
| Model | Android (XNNPACK) [MB] | iOS (XNNPACK) [MB] |
124121
| --------------------- | ---------------------- | ------------------ |
125122
| BK_SDM_TINY_VPRED_256 | 2900 | 2800 |
126-
| BK_SDM_TINY_VPRED | 6700 | 6560 |
123+
| BK_SDM_TINY_VPRED_512 | 6700 | 6560 |
127124

128125
### Inference time
129126

docs/docs/03-typescript-api/02-computer-vision/TextToImageModule.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ TypeScript API implementation of the [useTextToImage](../../02-hooks/02-computer
77
## Reference
88

99
```typescript
10-
import { TextToImageModule, BK_SDM_TINY_VPRED } from 'react-native-executorch';
10+
import {
11+
TextToImageModule,
12+
BK_SDM_TINY_VPRED_256,
13+
} from 'react-native-executorch';
1114

1215
const input = 'a castle';
1316

1417
// Creating an instance
1518
const textToImageModule = new TextToImageModule();
1619

1720
// Loading the model
18-
await textToImageModule.load(BK_SDM_TINY_VPRED);
21+
await textToImageModule.load(BK_SDM_TINY_VPRED_256);
1922

2023
// Running the model
2124
const image = await textToImageModule.forward(input);

packages/react-native-executorch/src/constants/modelUrls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ export const CLIP_VIT_BASE_PATCH32_TEXT = {
424424
};
425425

426426
// Image generation
427-
export const BK_SDM_TINY_VPRED = {
427+
export const BK_SDM_TINY_VPRED_512 = {
428428
schedulerSource:
429429
'https://huggingface.co/aszymanska/bk-sdm-tiny-vpred/resolve/main/scheduler/scheduler_config.json',
430430
tokenizerSource:

0 commit comments

Comments
 (0)