Instructions to use kumararvindibs/ibs_imgToTextGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kumararvindibs/ibs_imgToTextGeneration with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="kumararvindibs/ibs_imgToTextGeneration")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("kumararvindibs/ibs_imgToTextGeneration") model = AutoModelForMultimodalLM.from_pretrained("kumararvindibs/ibs_imgToTextGeneration", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use kumararvindibs/ibs_imgToTextGeneration with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kumararvindibs/ibs_imgToTextGeneration" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kumararvindibs/ibs_imgToTextGeneration", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/kumararvindibs/ibs_imgToTextGeneration
- SGLang
How to use kumararvindibs/ibs_imgToTextGeneration with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "kumararvindibs/ibs_imgToTextGeneration" \ --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": "kumararvindibs/ibs_imgToTextGeneration", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
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 "kumararvindibs/ibs_imgToTextGeneration" \ --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": "kumararvindibs/ibs_imgToTextGeneration", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use kumararvindibs/ibs_imgToTextGeneration with Docker Model Runner:
docker model run hf.co/kumararvindibs/ibs_imgToTextGeneration
Update handler.py
Browse files- handler.py +6 -13
handler.py
CHANGED
|
@@ -21,22 +21,15 @@ class EndpointHandler():
|
|
| 21 |
|
| 22 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
| 23 |
logging.error(f"----------This is an error message")
|
| 24 |
-
#logging.critical('-------------------This is a critical message')
|
| 25 |
-
print("000000--",type(data))
|
| 26 |
-
#logging.warning('--------This is a warning message')
|
| 27 |
-
print("input data is here------------",data)
|
| 28 |
input_data = data.get("inputs", {})
|
| 29 |
-
logging.warning(
|
| 30 |
-
print("input data is here-2-----------",type(input_data))
|
| 31 |
encoded_images = input_data.get("images")
|
| 32 |
-
logging.warning(f"---encoded_images-----
|
| 33 |
-
print("input encoded_images is here------------",type(encoded_images))
|
| 34 |
if not encoded_images:
|
|
|
|
| 35 |
return {"captions": [], "error": "No images provided"}
|
| 36 |
-
|
| 37 |
-
#texts = input_data.get("texts", ["a photography of"] * len(encoded_images))
|
| 38 |
-
|
| 39 |
try:
|
|
|
|
| 40 |
byteImgIO = io.BytesIO()
|
| 41 |
|
| 42 |
byteImg = Image.open(encoded_images[0])
|
|
@@ -48,7 +41,7 @@ class EndpointHandler():
|
|
| 48 |
# Non test code
|
| 49 |
dataBytesIO = io.BytesIO(byteImg)
|
| 50 |
raw_images =[Image.open(dataBytesIO)]
|
| 51 |
-
logging.warning(f"----raw_images----
|
| 52 |
# Check if any images were successfully decoded
|
| 53 |
if not raw_images:
|
| 54 |
print("No valid images found.")
|
|
@@ -63,7 +56,7 @@ class EndpointHandler():
|
|
| 63 |
out = self.model.generate(**processed_inputs)
|
| 64 |
|
| 65 |
captions = self.processor.batch_decode(out, skip_special_tokens=True)
|
| 66 |
-
logging.warning(f"----captions----
|
| 67 |
print("caption is here-------",captions)
|
| 68 |
return {"captions": captions}
|
| 69 |
except Exception as e:
|
|
|
|
| 21 |
|
| 22 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
| 23 |
logging.error(f"----------This is an error message")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
input_data = data.get("inputs", {})
|
| 25 |
+
logging.warning(f"------input_data-- {str(input_data)}")
|
|
|
|
| 26 |
encoded_images = input_data.get("images")
|
| 27 |
+
logging.warning(f"---encoded_images----- {str(encoded_images)}")
|
|
|
|
| 28 |
if not encoded_images:
|
| 29 |
+
logging.warning(f"---encoded_images--not provided in if block--- {str(encoded_images)}")
|
| 30 |
return {"captions": [], "error": "No images provided"}
|
|
|
|
|
|
|
|
|
|
| 31 |
try:
|
| 32 |
+
logging.warning(f"---encoded_images-- provided in try block--- {str(encoded_images)}")
|
| 33 |
byteImgIO = io.BytesIO()
|
| 34 |
|
| 35 |
byteImg = Image.open(encoded_images[0])
|
|
|
|
| 41 |
# Non test code
|
| 42 |
dataBytesIO = io.BytesIO(byteImg)
|
| 43 |
raw_images =[Image.open(dataBytesIO)]
|
| 44 |
+
logging.warning(f"----raw_images----0--- {str(raw_images)}")
|
| 45 |
# Check if any images were successfully decoded
|
| 46 |
if not raw_images:
|
| 47 |
print("No valid images found.")
|
|
|
|
| 56 |
out = self.model.generate(**processed_inputs)
|
| 57 |
|
| 58 |
captions = self.processor.batch_decode(out, skip_special_tokens=True)
|
| 59 |
+
logging.warning(f"----captions---- {str(captions)}")
|
| 60 |
print("caption is here-------",captions)
|
| 61 |
return {"captions": captions}
|
| 62 |
except Exception as e:
|