stabilityai / japanese-instructblip-alpha

huggingface.co
Total runs: 390
24-hour runs: 0
7-day runs: 44
30-day runs: 230
Model's Last Updated: November 17 2023
image-to-text

Introduction of japanese-instructblip-alpha

Model Details of japanese-instructblip-alpha

Japanese InstructBLIP Alpha

japanese-instructblip-icon

Model Details

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

Usage

First install additional dependencies in requirements.txt :

pip install sentencepiece einops
import torch
from transformers import LlamaTokenizer, AutoModelForVision2Seq, BlipImageProcessor
from PIL import Image
import requests

# helper function to format input prompts
def build_prompt(prompt="", sep="\n\n### "):
    sys_msg = "以下は、タスクを説明する指示と、文脈のある入力の組み合わせです。要求を適切に満たす応答を書きなさい。"
    p = sys_msg
    roles = ["指示", "応答"]
    user_query = "与えられた画像について、詳細に述べてください。"
    msgs = [": \n" + user_query, ": "]
    if prompt:
        roles.insert(1, "入力")
        msgs.insert(1, ": \n" + prompt)
    for role, msg in zip(roles, msgs):
        p += sep + role + msg
    return p

# load model
model = AutoModelForVision2Seq.from_pretrained("stabilityai/japanese-instructblip-alpha", trust_remote_code=True)
processor = BlipImageProcessor.from_pretrained("stabilityai/japanese-instructblip-alpha")
tokenizer = LlamaTokenizer.from_pretrained("novelai/nerdstash-tokenizer-v1", additional_special_tokens=['▁▁'])
device = "cuda" if torch.cuda.is_available() else "cpu"
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 = "" # input empty string for image captioning. You can also input questions as prompts 
prompt = build_prompt(prompt)
inputs = processor(images=image, return_tensors="pt")
text_encoding = tokenizer(prompt, add_special_tokens=False, return_tensors="pt")
text_encoding["qformer_input_ids"] = text_encoding["input_ids"].clone()
text_encoding["qformer_attention_mask"] = text_encoding["attention_mask"].clone()
inputs.update(text_encoding)

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

Japanese InstructBLIP Alpha leverages the InstructBLIP architecture. It consists of 3 components: a frozen vision image encoder, a Q-Former, and a frozen LLM. The vision encoder and the Q-Former were initialized with Salesforce/instructblip-vicuna-7b . For the frozen LLM, Japanese-StableLM-Instruct-Alpha-7B model was used. During training, only Q-Former was trained.

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 chat-like applications in adherence with the research license.

Limitations and bias

Although the aforementioned datasets help to steer the base language models into "safer" distributions of text, not all biases and toxicity can be mitigated through fine-tuning. We ask that users be mindful of such potential issues that can arise in generated responses. Do not treat model outputs as substitutes for human judgment or as sources of truth. Please use responsibly.

How to cite
@misc{JapaneseInstructBLIPAlpha, 
    url    = {[https://huggingface.co/stabilityai/japanese-instructblip-alpha](https://huggingface.co/stabilityai/japanese-instructblip-alpha)}, 
    title  = {Japanese InstructBLIP Alpha}, 
    author = {Shing, Makoto and Akiba, Takuya}
}
Citations
@misc{dai2023instructblip,
    title         = {InstructBLIP: Towards General-purpose Vision-Language Models with Instruction Tuning}, 
    author        = {Wenliang Dai and Junnan Li and Dongxu Li and Anthony Meng Huat Tiong and Junqi Zhao and Weisheng Wang and Boyang Li and Pascale Fung and Steven Hoi},
    year          = {2023},
    eprint        = {2305.06500},
    archivePrefix = {arXiv},
    primaryClass  = {cs.CV}
}
Contact

Runs of stabilityai japanese-instructblip-alpha on huggingface.co

390
Total runs
0
24-hour runs
13
3-day runs
44
7-day runs
230
30-day runs

More Information About japanese-instructblip-alpha huggingface.co Model

More japanese-instructblip-alpha license Visit here:

https://choosealicense.com/licenses/other

japanese-instructblip-alpha huggingface.co

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

japanese-instructblip-alpha huggingface.co Url

https://huggingface.co/stabilityai/japanese-instructblip-alpha

stabilityai japanese-instructblip-alpha online free

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

stabilityai japanese-instructblip-alpha online free url in huggingface.co:

https://huggingface.co/stabilityai/japanese-instructblip-alpha

japanese-instructblip-alpha install

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

japanese-instructblip-alpha install url in huggingface.co:

https://huggingface.co/stabilityai/japanese-instructblip-alpha

Url of japanese-instructblip-alpha

japanese-instructblip-alpha huggingface.co Url

Provider of japanese-instructblip-alpha huggingface.co

stabilityai
ORGANIZATIONS

Other API from stabilityai

huggingface.co

Total runs: 168.2K
Run Growth: 33.6K
Growth Rate: 20.80%
Updated: August 04 2023
huggingface.co

Total runs: 126.8K
Run Growth: -2.6K
Growth Rate: -2.01%
Updated: July 10 2024
huggingface.co

Total runs: 33.5K
Run Growth: 3.2K
Growth Rate: 9.42%
Updated: August 09 2024
huggingface.co

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

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

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