Skip to content

[llava][21/N] Add llava runner test binary and build script #4667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Aug 16, 2024

Conversation

larryliu0820
Copy link
Contributor

@larryliu0820 larryliu0820 commented Aug 12, 2024

Stack from ghstack (oldest at bottom):

Add a main.cpp and CMakeLists.txt for llava runner. This runner takes in an image in the format of .pt (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run build.sh to build the runner.

To serialize the image into a .pt file, run the following script:

import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")

To run the runner, use the following command:

cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0

Differential Revision: D61146432

As titled. This PR moves the token generation loop in llama2 runner into
a new class so it can be reused.

[ghstack-poisoned]
…o a class"

As titled. This PR moves the token generation loop in llama2 runner into
a new class so it can be reused.

Differential Revision: [D61047601](https://our.internmc.facebook.com/intern/diff/D61047601)

[ghstack-poisoned]
As titled. This PR moves the token generation loop in llama2 runner into
a new class so it can be reused.

Differential Revision: [D61047601](https://our.internmc.facebook.com/intern/diff/D61047601)

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Aug 12, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/4667

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 5b687ce with merge base 84100d1 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

larryliu0820 added a commit that referenced this pull request Aug 12, 2024
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 12, 2024
@larryliu0820 larryliu0820 marked this pull request as ready for review August 12, 2024 16:38
Copy link
Contributor

@lucylq lucylq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm after linter/nits, thank you

… and build script"


Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```


[ghstack-poisoned]
Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```


[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Aug 14, 2024
… and build script"


Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```


[ghstack-poisoned]
Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```


[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Aug 15, 2024
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

… and build script"


Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Aug 16, 2024
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

… and build script"


Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Aug 16, 2024
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@larryliu0820 larryliu0820 changed the base branch from gh/larryliu0820/50/base to main August 16, 2024 09:01
facebook-github-bot pushed a commit that referenced this pull request Aug 16, 2024
Summary:


Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```


imported-using-ghimport

Test Plan: Imported from OSS

Reviewed By: kirklandsign

Differential Revision: D61146432

Pulled By: larryliu0820
… and build script"


Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Aug 16, 2024
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

larryliu0820 added a commit that referenced this pull request Aug 16, 2024
Summary:
Pull Request resolved: #4750

Pull Request resolved: #4667

Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

imported-using-ghimport

Test Plan: Imported from OSS

Reviewed By: kirklandsign

Differential Revision: D61146432

Pulled By: larryliu0820
… and build script"


Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Aug 16, 2024
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

larryliu0820 added a commit that referenced this pull request Aug 16, 2024
Summary:
Pull Request resolved: #4750

Pull Request resolved: #4667

Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

imported-using-ghimport

Test Plan: Imported from OSS

Reviewed By: kirklandsign

Differential Revision: D61146432

Pulled By: larryliu0820
… and build script"


Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Aug 16, 2024
kirklandsign pushed a commit to kirklandsign/executorch that referenced this pull request Aug 16, 2024
Summary:
Pull Request resolved: pytorch#4750

Pull Request resolved: pytorch#4667

Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

imported-using-ghimport

Test Plan: Imported from OSS

Reviewed By: kirklandsign

Differential Revision: D61146432

Pulled By: larryliu0820
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

larryliu0820 added a commit that referenced this pull request Aug 16, 2024
Summary:
Pull Request resolved: #4750

Pull Request resolved: #4667

Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

imported-using-ghimport

Test Plan: Imported from OSS

Reviewed By: kirklandsign

Differential Revision: D61146432

Pulled By: larryliu0820
… and build script"


Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Aug 16, 2024
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

larryliu0820 added a commit that referenced this pull request Aug 16, 2024
Summary:
Pull Request resolved: #4750

Pull Request resolved: #4667

Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

imported-using-ghimport

Test Plan: Imported from OSS

Reviewed By: kirklandsign

Differential Revision: D61146432

Pulled By: larryliu0820
… and build script"


Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \    
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

Differential Revision: [D61146432](https://www.internalfb.com/diff/D61146432)

[ghstack-poisoned]
larryliu0820 added a commit that referenced this pull request Aug 16, 2024
@larryliu0820
Copy link
Contributor Author

@larryliu0820 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

kirklandsign pushed a commit to kirklandsign/executorch that referenced this pull request Aug 16, 2024
Summary:
Pull Request resolved: pytorch#4750

Pull Request resolved: pytorch#4667

Add a `main.cpp` and CMakeLists.txt for llava runner. This runner takes in an image in the format of `.pt` (a serialized pytorch model) along with text prompt. It will generate text tokens in a way similar to llama runner.

Run `build.sh` to build the runner.

To serialize the image into a `.pt` file, run the following script:

```python
import torch
from torch import nn

copy = torch.tensor(resized)
m = nn.Module()
par = nn.Parameter(copy, requires_grad=False)
m.register_parameter("0",par)
tensors = torch.jit.script(m)
tensors.save("image.pt")
```

To run the runner, use the following command:

```
cmake-out/examples/models/llava/llava_main                                                               \
    --tokenizer_path tokenizer.bin                                                                                    \
    --model_path llava_kv_768.pte                                                                                  \
    --prompt "\nWhat are the things I should be cautious about when I visit here?"  \
    --image_path image.pt                                                                                                \
    --temperature 0
```

imported-using-ghimport

Test Plan: Imported from OSS

Reviewed By: kirklandsign

Differential Revision: D61146432

Pulled By: larryliu0820
@larryliu0820 larryliu0820 merged commit 45e9f6b into main Aug 16, 2024
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants