ProGamerGov/synthetic-dataset-1m-dalle3-high-quality-captions
Updated • 1.51k • 150
How to use John6666/gokaygokay-Florence-2-SD3-Captioner-8bit with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="John6666/gokaygokay-Florence-2-SD3-Captioner-8bit", trust_remote_code=True) # Load model directly
from transformers import AutoProcessor, AutoModelForMultimodalLM
processor = AutoProcessor.from_pretrained("John6666/gokaygokay-Florence-2-SD3-Captioner-8bit", trust_remote_code=True)
model = AutoModelForMultimodalLM.from_pretrained("John6666/gokaygokay-Florence-2-SD3-Captioner-8bit", trust_remote_code=True)How to use John6666/gokaygokay-Florence-2-SD3-Captioner-8bit with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "John6666/gokaygokay-Florence-2-SD3-Captioner-8bit"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "John6666/gokaygokay-Florence-2-SD3-Captioner-8bit",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/John6666/gokaygokay-Florence-2-SD3-Captioner-8bit
How to use John6666/gokaygokay-Florence-2-SD3-Captioner-8bit with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "John6666/gokaygokay-Florence-2-SD3-Captioner-8bit" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "John6666/gokaygokay-Florence-2-SD3-Captioner-8bit",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "John6666/gokaygokay-Florence-2-SD3-Captioner-8bit" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "John6666/gokaygokay-Florence-2-SD3-Captioner-8bit",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use John6666/gokaygokay-Florence-2-SD3-Captioner-8bit with Docker Model Runner:
docker model run hf.co/John6666/gokaygokay-Florence-2-SD3-Captioner-8bit
Original model is here. Tagger for local environment is here.
# recipe
from transformers import AutoModelForCausalLM, AutoProcessor, BitsAndBytesConfig
import transformers
import torch
import json
model_id = 'gokaygokay/Florence-2-SD3-Captioner'
save_path = 'gokaygokay-Florence-2-SD3-Captioner-8bit'
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
torch_dtype=torch.float32,
low_cpu_mem_usage=True,
quantization_config=BitsAndBytesConfig(
load_in_8bit=True,
llm_int8_threshold=6.0,
llm_int8_enable_fp32_cpu_offload=True,
llm_int8_skip_modules=['lm_head'],
),
)
processor.save_pretrained(save_path)
model.save_pretrained(save_path, safe_serialization=True)
config = {}
with open(f'{save_path}/config.json') as f:
config = json.load(f)
config['vision_config']['model_type'] = 'davit'
with open(f'{save_path}/config.json', 'w') as f:
json.dump(config, f, indent=2)
Base model
gokaygokay/Florence-2-SD3-Captioner