Image-to-Image
Diffusers
Safetensors
Transformers
GGUF
English
Flux2Pipeline
image-generation
image-editing
text-to-image
flux2
flux
quantization
hqq
optimization
quantized
2bit
Instructions to use AlekseyCalvin/FLUX2_dev_2bit_hqq with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use AlekseyCalvin/FLUX2_dev_2bit_hqq with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("AlekseyCalvin/FLUX2_dev_2bit_hqq", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Transformers
How to use AlekseyCalvin/FLUX2_dev_2bit_hqq with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-to-image", model="AlekseyCalvin/FLUX2_dev_2bit_hqq")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AlekseyCalvin/FLUX2_dev_2bit_hqq", dtype="auto") - Notebooks
- Google Colab
- Kaggle
Upload tokenizer/chat_template.jinja with huggingface_hub
Browse files
tokenizer/chat_template.jinja
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set today = strftime_now("%Y-%m-%d") %}
|
| 2 |
+
{%- set default_system_message = "You are Mistral Small 3, a Large Language Model (LLM) created by Mistral AI, a French startup headquartered in Paris.\nYour knowledge base was last updated on 2023-10-01. The current date is " + today + ".\n\nWhen you're not sure about some information, you say that you don't have the information and don't make up anything.\nIf the user's question is not clear, ambiguous, or does not provide enough context for you to accurately answer the question, you do not try to answer it right away and you rather ask the user to clarify their request (e.g. \"What are some good restaurants around me?\" => \"Where are you?\" or \"When is the next flight to Tokyo\" => \"Where do you travel from?\")" %}
|
| 3 |
+
|
| 4 |
+
{{- bos_token }}
|
| 5 |
+
|
| 6 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 7 |
+
{%- if messages[0]['content'] is string %}
|
| 8 |
+
{%- set system_message = messages[0]['content'] %}
|
| 9 |
+
{%- else %}
|
| 10 |
+
{%- set system_message = messages[0]['content'][0]['text'] %}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{%- set loop_messages = messages[1:] %}
|
| 13 |
+
{%- else %}
|
| 14 |
+
{%- set system_message = default_system_message %}
|
| 15 |
+
{%- set loop_messages = messages %}
|
| 16 |
+
{%- endif %}
|
| 17 |
+
{{- '[SYSTEM_PROMPT]' + system_message + '[/SYSTEM_PROMPT]' }}
|
| 18 |
+
|
| 19 |
+
{%- for message in loop_messages %}
|
| 20 |
+
{%- if message['role'] == 'user' %}
|
| 21 |
+
{%- if message['content'] is string %}
|
| 22 |
+
{{- '[INST]' + message['content'] + '[/INST]' }}
|
| 23 |
+
{%- else %}
|
| 24 |
+
{{- '[INST]' }}
|
| 25 |
+
{%- for block in message['content'] %}
|
| 26 |
+
{%- if block['type'] == 'text' %}
|
| 27 |
+
{{- block['text'] }}
|
| 28 |
+
{%- elif block['type'] in ['image', 'image_url'] %}
|
| 29 |
+
{{- '[IMG]' }}
|
| 30 |
+
{%- else %}
|
| 31 |
+
{{- raise_exception('Only text and image blocks are supported in message content!') }}
|
| 32 |
+
{%- endif %}
|
| 33 |
+
{%- endfor %}
|
| 34 |
+
{{- '[/INST]' }}
|
| 35 |
+
{%- endif %}
|
| 36 |
+
{%- elif message['role'] == 'system' %}
|
| 37 |
+
{%- if message['content'] is string %}
|
| 38 |
+
{{- '[SYSTEM_PROMPT]' + message['content'] + '[/SYSTEM_PROMPT]' }}
|
| 39 |
+
{%- else %}
|
| 40 |
+
{{- '[SYSTEM_PROMPT]' + message['content'][0]['text'] + '[/SYSTEM_PROMPT]' }}
|
| 41 |
+
{%- endif %}
|
| 42 |
+
{%- elif message['role'] == 'assistant' %}
|
| 43 |
+
{%- if message['content'] is string %}
|
| 44 |
+
{{- message['content'] + eos_token }}
|
| 45 |
+
{%- else %}
|
| 46 |
+
{{- message['content'][0]['text'] + eos_token }}
|
| 47 |
+
{%- endif %}
|
| 48 |
+
{%- else %}
|
| 49 |
+
{{- raise_exception('Only user, system and assistant roles are supported!') }}
|
| 50 |
+
{%- endif %}
|
| 51 |
+
{%- endfor %}
|