stabilityai / japanese-stable-vlm

huggingface.co
Total runs: 323
24-hour runs: 0
7-day runs: -12
30-day runs: -18
Model's Last Updated: Juli 10 2024
image-to-text

Introduction of japanese-stable-vlm

Model Details of japanese-stable-vlm

Japanese Stable VLM

Please note: for commercial usage of this model, please see https://stability.ai/license

商用利用に関する日本語での問い合わせは partners-jp@stability.ai までお願い致します。

Model Details

Japanese Stable VLM is a vision-language instruction-following model that enables to generate Japanese descriptions for input images and optionally input texts such as questions.

Usage
import torch
from transformers import AutoTokenizer, AutoModelForVision2Seq, AutoImageProcessor
from PIL import Image
import requests

# helper function to format input prompts
TASK2INSTRUCTION = {
    "caption": "画像を詳細に述べてください。",
    "tag": "与えられた単語を使って、画像を詳細に述べてください。",
    "vqa": "与えられた画像を下に、質問に答えてください。",
}


def build_prompt(task="caption", input=None, sep="\n\n### "):
    assert (
        task in TASK2INSTRUCTION
    ), f"Please choose from {list(TASK2INSTRUCTION.keys())}"
    if task in ["tag", "vqa"]:
        assert input is not None, "Please fill in `input`!"
        if task == "tag" and isinstance(input, list):
            input = "、".join(input)
    else:
        assert input is None, f"`{task}` mode doesn't support to input questions"
    sys_msg = "以下は、タスクを説明する指示と、文脈のある入力の組み合わせです。要求を適切に満たす応答を書きなさい。"
    p = sys_msg
    roles = ["指示", "応答"]
    instruction = TASK2INSTRUCTION[task]
    msgs = [": \n" + instruction, ": \n"]
    if input:
        roles.insert(1, "入力")
        msgs.insert(1, ": \n" + input)
    for role, msg in zip(roles, msgs):
        p += sep + role + msg
    return p

# load model
device = "cuda" if torch.cuda.is_available() else "cpu"
model = AutoModelForVision2Seq.from_pretrained("stabilityai/japanese-stable-vlm", trust_remote_code=True)
processor = AutoImageProcessor.from_pretrained("stabilityai/japanese-stable-vlm")
tokenizer = AutoTokenizer.from_pretrained("stabilityai/japanese-stable-vlm")
model.to(device)

# prepare inputs
url = "https://images.unsplash.com/photo-1582538885592-e70a5d7ab3d3?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1770&q=80"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
prompt = build_prompt(task="caption")
# prompt = build_prompt(task="tag", input=["河津桜", "青空"])
# prompt = build_prompt(task="vqa", input="季節はいつですか?")

inputs = processor(images=image, return_tensors="pt")
text_encoding = tokenizer(prompt, add_special_tokens=False, return_tensors="pt")
inputs.update(text_encoding)

# generate
outputs = model.generate(
    **inputs.to(device, dtype=model.dtype),
    do_sample=False,
    num_beams=5,
    max_new_tokens=128,
    min_length=1,
    repetition_penalty=1.5,
)
generated_text = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0].strip()
print(generated_text)
# 桜越しの東京スカイツリー
Model Details
Training

This model is a vision-language instruction-following model with the LLaVA 1.5 architecture. It uses stabilityai/japanese-stablelm-instruct-gamma-7b as a language model and openai/clip-vit-large-patch14 as an image encoder. During training, the MLP projection was trained from scratch at the first stage and the language model and the MLP projection were further trained at the second stage.

Training Dataset

The training dataset includes the following public datasets:

Use and Limitations
Intended Use

This model is intended to be used by the open-source community in vision-language applications.

Limitations and bias

The training dataset may have contained offensive or inappropriate content even though we applied data filters. We recommend users exercise reasonable caution when using these models in production systems. Do not use the model for any applications that may cause harm or distress to individuals or groups.

How to cite
@misc{JapaneseStableVLM, 
    url    = {[https://huggingface.co/stabilityai/japanese-stable-vlm](https://huggingface.co/stabilityai/japanese-stable-vlm)}, 
    title  = {Japanese Stable VLM}, 
    author = {Shing, Makoto and Akiba, Takuya}
}
Contact

Runs of stabilityai japanese-stable-vlm on huggingface.co

323
Total runs
0
24-hour runs
7
3-day runs
-12
7-day runs
-18
30-day runs

More Information About japanese-stable-vlm huggingface.co Model

More japanese-stable-vlm license Visit here:

https://choosealicense.com/licenses/other

japanese-stable-vlm huggingface.co

japanese-stable-vlm huggingface.co is an AI model on huggingface.co that provides japanese-stable-vlm's model effect (), which can be used instantly with this stabilityai japanese-stable-vlm model. huggingface.co supports a free trial of the japanese-stable-vlm model, and also provides paid use of the japanese-stable-vlm. Support call japanese-stable-vlm model through api, including Node.js, Python, http.

japanese-stable-vlm huggingface.co Url

https://huggingface.co/stabilityai/japanese-stable-vlm

stabilityai japanese-stable-vlm online free

japanese-stable-vlm huggingface.co is an online trial and call api platform, which integrates japanese-stable-vlm's modeling effects, including api services, and provides a free online trial of japanese-stable-vlm, you can try japanese-stable-vlm online for free by clicking the link below.

stabilityai japanese-stable-vlm online free url in huggingface.co:

https://huggingface.co/stabilityai/japanese-stable-vlm

japanese-stable-vlm install

japanese-stable-vlm is an open source model from GitHub that offers a free installation service, and any user can find japanese-stable-vlm on GitHub to install. At the same time, huggingface.co provides the effect of japanese-stable-vlm install, users can directly use japanese-stable-vlm installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

japanese-stable-vlm install url in huggingface.co:

https://huggingface.co/stabilityai/japanese-stable-vlm

Url of japanese-stable-vlm

japanese-stable-vlm huggingface.co Url

Provider of japanese-stable-vlm huggingface.co

stabilityai
ORGANIZATIONS

Other API from stabilityai

huggingface.co

Total runs: 143.2K
Run Growth: 8.3K
Growth Rate: 5.81%
Updated: August 04 2023
huggingface.co

Total runs: 137.2K
Run Growth: 16.4K
Growth Rate: 11.93%
Updated: Juli 10 2024
huggingface.co

Total runs: 34.3K
Run Growth: 3.4K
Growth Rate: 10.04%
Updated: August 09 2024
huggingface.co

Total runs: 378
Run Growth: -97.9K
Growth Rate: -25898.41%
Updated: August 03 2024
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated: Juli 10 2024
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated: April 13 2024