Views
No views yet
| Image | Example |
|---|---|
![]() | Describe this image in great details answer in hindi चित्र में एक व्यक्ति को हरे-भरा मैदान के बीचोबीच, पानी का सिर पर छाता पकड़े हुए देखा गया है। उनका शरीर ऊपर उठा हुआ दिखाई देता था जो उन्हें नीचे की ओर खींचती हुई प्रकृति से बचाया जा रहा होता होगा ।जमीन नदी जैसा तालाब या झील जैसे आकार और रंगों द्वारा बनाई गई थी. ये पेड़ अपनी गहरी शाखाओं वाला संतुलित ढेर हैं क्योंकि वे इमारatsकी मरम्मत करते समय भी अपना स्थान संरक्षित कर रहे थे - कुछ बाहर निकले गए तो अन्य भागे रहते ही वापस फेंके जाते देख सकते होंगे! पृष्ठष्ठीय प्रकाश व्यवस्था ने दृश्य समग्र रूप प्रदान किया है: नीली चमत्कारी आसमान जिससे बादलों तक पहुंचने लगकर भूखंजन बन जाता सूर्य वर्गी |
![]() | What is the scenery of this image? Here we can see an animation of a forest. In the foreground there are rocks, trees and plants on ground with green leaves. Behind it's looking like buildings or houses which is made up of bricks at top right side corner of picture where light colored something seems happening over here such as lighting effect might be present under these objects where tree trunk appears yellow color from bottom towards middle its looks redish orange colour while other branches appear yellowish brown all around them after that. |
1!pip install peft trl datasets accelerate bitsandbytes
2!pip install transformers --upgrade1from transformers import PaliGemmaForConditionalGeneration , AutoProcessor
2import torch
3import requests
4from PIL import Image
5from io import BytesIO
6
7# URL of the image
8url = "https://huggingface.co/Tensoic/Cerule-v0.1/resolve/main/examples/astronaut.png"
9
10# Use requests to get the image
11response = requests.get(url)
12
13# Use BytesIO to convert the response content to a file-like object
14image_file = BytesIO(response.content)
15
16# Use PIL to open the image file
17image = Image.open(image_file)
18text = "What is this image about answer in hindi "
19
20device_index = torch.cuda.current_device()
21print("device_index:",device_index)
22base_model = PaliGemmaForConditionalGeneration.from_pretrained("BhashaAI/Paligemma-hindi-chat-v1.0",device_map={"": device_index},torch_dtype=torch.float16,low_cpu_mem_usage=True)
23processor = AutoProcessor.from_pretrained("BhashaAI/Paligemma-hindi-chat-v1.0")
24
25inputs = processor(text=text, images=image, return_tensors="pt").to("cuda")
26for k,v in inputs.items():
27 print(k,v.shape)
28
29MAX_LENGTH = 200
30# Autoregressively generate
31# We use greedy decoding here, for more fancy methods see https://huggingface.co/blog/how-to-generate
32generated_ids = base_model.generate(**inputs, max_new_tokens=MAX_LENGTH,temperature=0.7,repetition_penalty=2.0,do_sample=True)
33
34# Next we turn each predicted token ID back into a string using the decode method
35# We chop of the prompt, which consists of image tokens and our text prompt
36image_token_index = base_model.config.image_token_index
37num_image_tokens = len(generated_ids[generated_ids==image_token_index])
38num_text_tokens = len(processor.tokenizer.encode(text))
39num_prompt_tokens = num_image_tokens + num_text_tokens + 2
40generated_text = processor.batch_decode(generated_ids[:, num_prompt_tokens:], skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
41generated_text
421from transformers import PaliGemmaForConditionalGeneration , AutoProcessor,BitsAndBytesConfig
2import torch
3from datasets import load_dataset
4import requests
5from PIL import Image
6from io import BytesIO
7
8# URL of the image
9url = "https://huggingface.co/Tensoic/Cerule-v0.1/resolve/main/examples/mario.png"
10# Use requests to get the image
11response = requests.get(url)
12
13# Use BytesIO to convert the response content to a file-like object
14image_file = BytesIO(response.content)
15
16# Use PIL to open the image file
17image = Image.open(image_file)
18text = "Describe this image and tell me about these character"
19
20device_index = torch.cuda.current_device()
21print("device_index:",device_index)
22quantization_config = BitsAndBytesConfig(load_in_4bit=True)
23base_model = PaliGemmaForConditionalGeneration.from_pretrained("BhashaAI/Paligemma-hindi-chat-v1.0",device_map={"": device_index},quantization_config=quantization_config,torch_dtype=torch.float16,low_cpu_mem_usage=True)
24processor = AutoProcessor.from_pretrained("BhashaAI/Paligemma-hindi-chat-v1.0")
25
26inputs = processor(text=text, images=image, return_tensors="pt").to("cuda")
27for k,v in inputs.items():
28 print(k,v.shape)
29
30MAX_LENGTH = 200
31# Autoregressively generate
32# We use greedy decoding here, for more fancy methods see https://huggingface.co/blog/how-to-generate
33generated_ids = base_model.generate(**inputs, max_new_tokens=MAX_LENGTH,temperature=0.7,repetition_penalty=2.0,do_sample=True)
34
35# Next we turn each predicted token ID back into a string using the decode method
36# We chop of the prompt, which consists of image tokens and our text prompt
37image_token_index = base_model.config.image_token_index
38num_image_tokens = len(generated_ids[generated_ids==image_token_index])
39num_text_tokens = len(processor.tokenizer.encode(text))
40num_prompt_tokens = num_image_tokens + num_text_tokens + 2
41generated_text = processor.batch_decode(generated_ids[:, num_prompt_tokens:], skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
42generated_text