Downloads · 30 days
0
AiArtLab/Qwen35-08b-nsfw
Qwen35-08b-nsfw is a machine learning model from AiArtLab. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
import torch import requests from PIL import Image from transformers import AutoProcessor, AutoModelForImageTextToText
Downloads · 30 days
0
Access
Public
Updated May 20, 2026
Repo size
5.3 GB
Likes
0
Public
Click a slice to open those files.
.safetensors3.5 GB · 98%
From the Hugging Face model README
import torch
import requests
from PIL import Image
# Используем AutoModelForImageTextToText вместо CausalLM или Qwen2VL
from transformers import AutoProcessor, AutoModelForImageTextToText
model_id = "/workspace/qwen35-08b/qwen_merged_0.6"
# 1. Загружаем модель через правильный мультимодальный Auto-класс
model = AutoModelForImageTextToText.from_pretrained(
model_id,
torch_dtype="auto",
device_map="auto",
trust_remote_code=True # Обязательно, чтобы HF скачал кастомный класс Qwen3_5ForConditionalGeneration
)
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
# 2. Скачиваем изображение
url = "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/ea2a1444-c4e8-44cf-9d37-65a457631dde/original=true,quality=90/131110212.jpeg"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
# 3. Формируем структуру сообщений
messages = [
{
"role": "user",
"content": [
{"type": "image"},
{"type": "text", "text": "Describe this image compact"}
]
}
]
# 4. Применяем Chat Template
prompt = processor.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
# 5. Обрабатываем текст и картинку
inputs = processor(
text=[prompt],
images=[image],
padding=True,
return_tensors="pt"
).to(model.device)
# 6. Генерируем ответ (теперь модель поймет все визуальные тензоры)
#generated_ids = model.generate(**inputs, max_new_tokens=256,temperature = 1.5, min_p = 0.1)
generated_ids = model.generate(**inputs, max_new_tokens=250, temperature=0.7, min_p=0.1, repetition_penalty=1.3)
# 7. Отсекаем промпт и декодируем
generated_ids_trimmed = [
out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed,
skip_special_tokens=True,
clean_up_tokenization_spaces=False
)[0]
print("Ответ модели:", output_text)