Views
No views yet
pip install zipnn1# Load model directly
2from transformers import AutoProcessor, AutoModelForPreTraining
3from zipnn import zipnn_hf
4
5zipnn_hf()
6
7processor = AutoProcessor.from_pretrained("royleibov/pixtral-12b-ZipNN-Compressed")
8model = AutoModelForPreTraining.from_pretrained("royleibov/pixtral-12b-ZipNN-Compressed")python zipnn_compress_path.py safetensors --model royleibov/pixtral-12b-ZipNN-Compressed --hf_cachezipnn_hf() is added at the top of the file like in the example above.python zipnn_decompress_path.py --model royleibov/pixtral-12b-ZipNN-Compressed --hf_cache1from PIL import Image
2from transformers import AutoProcessor, LlavaForConditionalGeneration
3from zipnn import zipnn_hf
4
5zipnn_hf()
6
7model_id = "royleibov/pixtral-12b-ZipNN-Compressed"
8model = LlavaForConditionalGeneration.from_pretrained(model_id)
9processor = AutoProcessor.from_pretrained(model_id)
10
11IMG_URLS = [
12"https://picsum.photos/id/237/400/300",
13"https://picsum.photos/id/231/200/300",
14"https://picsum.photos/id/27/500/500",
15"https://picsum.photos/id/17/150/600",
16]
17PROMPT = "<s>[INST]Describe the images.\n[IMG][IMG][IMG][IMG][/INST]"
18
19inputs = processor(text=PROMPT, images=IMG_URLS, return_tensors="pt").to("cuda")
20generate_ids = model.generate(**inputs, max_new_tokens=500)
21output = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
"""
Describe the images.
Sure, let's break down each image description:
1. **Image 1:**
- **Description:** A black dog with a glossy coat is sitting on a wooden floor. The dog has a focused expression and is looking directly at the camera.
- **Details:** The wooden floor has a rustic appearance with visible wood grain patterns. The dog's eyes are a striking color, possibly brown or amber, which contrasts with its black fur.
2. **Image 2:**
- **Description:** A scenic view of a mountainous landscape with a winding road cutting through it. The road is surrounded by lush green vegetation and leads to a distant valley.
- **Details:** The mountains are rugged with steep slopes, and the sky is clear, indicating good weather. The winding road adds a sense of depth and perspective to the image.
3. **Image 3:**
- **Description:** A beach scene with waves crashing against the shore. There are several people in the water and on the beach, enjoying the waves and the sunset.
- **Details:** The waves are powerful, creating a dynamic and lively atmosphere. The sky is painted with hues of orange and pink from the setting sun, adding a warm glow to the scene.
4. **Image 4:**
- **Description:** A garden path leading to a large tree with a bench underneath it. The path is bordered by well-maintained grass and flowers.
- **Details:** The path is made of small stones or gravel, and the tree provides a shaded area with the bench invitingly placed beneath it. The surrounding area is lush and green, suggesting a well-kept garden.
Each image captures a different scene, from a close-up of a dog to expansive natural landscapes, showcasing various elements of nature and human interaction with it.
"""images argument to the processor contains the images in the order
that they appear in the chat, so that the model understands where each image is supposed to go.1from PIL import Image
2from transformers import AutoProcessor, LlavaForConditionalGeneration
3from zipnn import zipnn_hf
4
5zipnn_hf()
6
7model_id = "royleibov/pixtral-12b-ZipNN-Compressed"
8model = LlavaForConditionalGeneration.from_pretrained(model_id)
9processor = AutoProcessor.from_pretrained(model_id)
10
11url_dog = "https://picsum.photos/id/237/200/300"
12url_mountain = "https://picsum.photos/seed/picsum/200/300"
13
14chat = [
15 {
16 "role": "user", "content": [
17 {"type": "text", "content": "Can this animal"},
18 {"type": "image"},
19 {"type": "text", "content": "live here?"},
20 {"type": "image"}
21 ]
22 }
23]
24
25prompt = processor.apply_chat_template(chat)
26inputs = processor(text=prompt, images=[url_dog, url_mountain], return_tensors="pt").to(model.device)
27generate_ids = model.generate(**inputs, max_new_tokens=500)
28output = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]Can this animallive here?Certainly! Here are some details about the images you provided:
### First Image
- **Description**: The image shows a black dog lying on a wooden surface. The dog has a curious expression with its head tilted slightly to one side.
- **Details**: The dog appears to be a young puppy with soft, shiny fur. Its eyes are wide and alert, and it has a playful demeanor.
- **Context**: This image could be used to illustrate a pet-friendly environment or to showcase the dog's personality.
### Second Image
- **Description**: The image depicts a serene landscape with a snow-covered hill in the foreground. The sky is painted with soft hues of pink, orange, and purple, indicating a sunrise or sunset.
- **Details**: The hill is covered in a blanket of pristine white snow, and the horizon meets the sky in a gentle curve. The scene is calm and peaceful.
- **Context**: This image could be used to represent tranquility, natural beauty, or a winter wonderland.
### Combined Context
If you're asking whether the dog can "live here," referring to the snowy landscape, it would depend on the breed and its tolerance to cold weather. Some breeds, like Huskies or Saint Bernards, are well-adapted to cold environments, while others might struggle. The dog in the first image appears to be a breed that might prefer warmer climates.
Would you like more information on any specific aspect?