• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Get Started with Apple's FastVLM: A Step-By-Step Guide

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Apple’s FastVLM is here and it is currently emerging as a game-changer in Vision Language Models (VLMs), combining fast speed with state-of-the-art accuracy. It is designed for real-time performance without compromising on output quality, and uses FastViTHD, a hybrid vision encoder that drastically cuts down the number of image tokens, making inference lightning-fast even with high-resolution inputs. Its smallest variant outpaces LLaVA-OneVision-0.5B with an outstanding 85x faster Time-to-First-Token (TTFT), all while being 3.4x smaller in size. On the other end of the scale, its larger models powered by Qwen2-7B surpass recent competitors like Cambrian-1-8B, achieving 7.9x faster TTFT using just a single image encoder. If you’re running models on powerful servers or experimenting on mobile devices, FastVLM delivers top-tier vision-language capabilities with low latency and unmatched efficiency.

In this guide, we're going to cover step-by-step process to install and run FastVLM locally or on cloud.

Prerequisites


The minimum system requirements for running this model are:

Step-by-step process to install and run FastVLM by Apple


For the purpose of this tutorial, we’ll use a GPU-powered Virtual Machine by

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

since it provides high compute Virtual Machines at a very affordable cost on a scale that meets GDPR, SOC2, and ISO27001 requirements. Also, it offers an intuitive and user-friendly interface, making it easier for beginners to get started with Cloud deployments. However, feel free to use any cloud provider of your choice and follow the same steps for the rest of the tutorial.

Step 1: Setting up a NodeShift Account


Visit

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

and create an account by filling in basic details, or continue signing up with your Google/GitHub account.

If you already have an account,

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

straight to your dashboard.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Step 2: Create a GPU Node


After accessing your account, you should see a dashboard (see image), now:

1) Navigate to the menu on the left side.

2) Click on the GPU Nodes option.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



3) Click on Start to start creating your very first GPU node.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



These GPU nodes are GPU-powered virtual machines by NodeShift. These nodes are highly customizable and let you control different environmental configurations for GPUs ranging from H100s to A100s, CPUs, RAM, and storage, according to your needs.

Step 3: Selecting configuration for GPU (model, region, storage)


1) For this tutorial, we’ll be using 1x RTX A6000 GPU, however, you can choose any GPU as per the prerequisites.

2) Similarly, we’ll opt for 200GB storage by sliding the bar. You can also select the region where you want your GPU to reside from the available ones.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Step 4: Choose GPU Configuration and Authentication method


1) After selecting your required configuration options, you'll see the available GPU nodes in your region and according to (or very close to) your configuration. In our case, we'll choose a 1x RTX A6000 48GB GPU node with 64vCPUs/63GB RAM/200GB SSD.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



2) Next, you'll need to select an authentication method. Two methods are available: Password and SSH Key. We recommend using SSH keys, as they are a more secure option. To create one, head over to our

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Step 5: Choose an Image


The final step is to choose an image for the VM, which in our case is Nvidia Cuda.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



That's it! You are now ready to deploy the node. Finalize the configuration summary, and if it looks good, click Create to deploy the node.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Step 6: Connect to active Compute Node using SSH


1) As soon as you create the node, it will be deployed in a few seconds or a minute. Once deployed, you will see a status Running in green, meaning that our Compute node is ready to use!

2) Once your GPU shows this status, navigate to the three dots on the right, click on Connect with SSH, and copy the SSH details that appear.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



As you copy the details, follow the below steps to connect to the running GPU VM via SSH:

1) Open your terminal, paste the SSH command, and run it.

2) In some cases, your terminal may take your consent before connecting. Enter ‘yes’.

3) A prompt will request a password. Type the SSH password, and you should be connected.

Output:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Next, If you want to check the GPU details, run the following command in the terminal:


!nvidia-smi
Step 7: Set up the project environment with dependencies


1) Create a virtual environment using Anaconda.


conda create -n fastvlm python=3.10 -y && conda activate fastvlm

Output:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



2) Clone the official repository of Apple-FastVLM.


git clone

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Output:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



4) Move inside the project directory and run the following command to install the current directory as a package in editable mode.


cd ml-fastvlm
pip install -e .

Output:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Step 8: Download and Run the model


1) Download all model checkpoints.


chmod a+x get_models.sh
bash get_models.sh

Output:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



2) Once all the checkpoints are downloaded, we'll connect our local VSCode editor to the remote server to do some changes in the python script before inference.

If you're using a GPU through a remote server (e.g., NodeShift), you can connect it to your visual studio code editor by following the steps below:

a) Install the “Remote-SSH” Extension by Microsoft on VS Code.
b) Type “Remote-SSH: Connect to Host” on the Command Palette.
c) Click on "Add a new host".
d) Enter the host details, such as username and SSH password, and you should be connected.

3) Open predict.py and replace all the instances of "mps" with "cuda" if running with GPU and with "cpu" if running with CPU only. If you're running this model on your local Mac machine, then you do not need to replace anything.

4) Once done, upload images that you want to test your model on. Below are some results that this model generated for two different tasks.

Use the given commands to run inference:

For describing image:

(Replace /path/to/checkpoint-dir with the full path to the exact model that you want to use for inference. E.g. llava-fastvithd_7b_stage3. Also replace /path/to/image.png with the full path to the place where you have uploaded your images.)


python predict.py --model-path /path/to/checkpoint-dir \
--image-file /path/to/image.png \
--prompt "Describe the image."

Here's a blurry image that we're using in our prompt:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Output:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



For extracting text from image:


python predict.py --model-path /path/to/checkpoint-dir \
--image-file /path/to/image.png \
--prompt "Extract the text from this image."

Here's the output we received for the given image:

Image:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Output:


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Conclusion


Apple's FastVLM stands out as a transformative Vision Language Model, delivering exceptional speed and accuracy through its innovative FastViTHD encoder. By significantly reducing visual token counts and encoding latency, FastVLM ensures real-time performance even with high-resolution images, making it ideal for diverse applications ranging from mobile devices to large-scale cloud deployments. To fully leverage FastVLM's capabilities, deploying it on a robust and scalable infrastructure is crucial. NodeShift cloud offers an optimal solution by providing GPU-powered Virtual Machines that are both affordable and compliant with industry standards like GDPR, SOC2, and ISO27001. With NodeShift's user-friendly platform, developers can effortlessly set up and run FastVLM, ensuring seamless integration and efficient performance across various environments.

For more information about NodeShift:



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу