Hafedh Hichri's picture

Hafedh Hichri

not-lain

AI & ML interests

custom AI models with HF integration, multimodal rag and open-source contributions && may or may not be a huggingface fellow

Recent Activity

upvoted a paper about 18 hours ago
Qwen2.5 Technical Report
updated a Space 1 day ago
not-lain/gpu-utils
liked a Space 2 days ago
Omnibus/Reverse-Image
View all activity

Articles

Organizations

Stanford AI's profile picture AI FILMS's profile picture OpenGVLab's profile picture MusicAI's profile picture BigScience Biomedical Datasets's profile picture OpenVINO Toolkit's profile picture Hugging Face Fellows's profile picture Gradio-Blocks-Party's profile picture scikit-learn's profile picture DeepGHS's profile picture Open-Source AI Meetup's profile picture AMD's profile picture lora concepts library's profile picture The introspector project's profile picture Arabic Machine Learning 's profile picture Literally Me FRFR Research Society's profile picture East China Normal University's profile picture Kornia AI's profile picture Tune a video concepts library's profile picture Keras Dreambooth Event's profile picture AI Zero to Hero's profile picture Stable Diffusion Dreambooth Concepts Library's profile picture The Waifu Research Department's profile picture AI Indonesia Community's profile picture M.O.F.U.'s profile picture ShoukanLabs's profile picture Blog-explorers's profile picture BangumiBase's profile picture CyberHarem's profile picture Touhou AI Experimental Group (MOFU)'s profile picture Tensor Diffusion's profile picture OpenOrca's profile picture huggingPartyParis's profile picture Multi🤖Transformers's profile picture Team Tonic's profile picture That Time I got Reincarnated as a Hugging Face Organization's profile picture ZeroGPU Explorers's profile picture LocalLLaMA's profile picture BrainPulse's profile picture Argilla Explorers's profile picture MLX Community's profile picture INNOVA AI's profile picture Narra's profile picture Social Post Explorers's profile picture C4AI Community's profile picture Tunisia.AI's profile picture M4-ai's profile picture Dev Mode Explorers's profile picture Chinese LLMs on Hugging Face's profile picture Paris AI Running Club's profile picture AI4Health's profile picture Stable Diffusion Community (Unofficial, Non-profit)'s profile picture Hugging Face for Legal's profile picture Hugging Face Discord Community's profile picture phxia's profile picture random cool awesome garbage's profile picture Arilio's profile picture Data Tonic (Alignment Lab)'s profile picture Nerdy Face's profile picture open/ acc's profile picture Data Is Better Together Contributor's profile picture Donut Earthers 🍩's profile picture

Posts 13

view post
Post
1767
ever wondered how you can make an API call to a visual-question-answering model without sending an image url 👀

you can do that by converting your local image to base64 and sending it to the API.

recently I made some changes to my library "loadimg" that allows you to make converting images to base64 a breeze.
🔗 https://github.com/not-lain/loadimg

API request example 🛠️:
from loadimg import load_img
from huggingface_hub import InferenceClient

# or load a local image
my_b64_img = load_img(imgPath_url_pillow_or_numpy ,output_type="base64" ) 

client = InferenceClient(api_key="hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

messages = [
	{
		"role": "user",
		"content": [
			{
				"type": "text",
				"text": "Describe this image in one sentence."
			},
			{
				"type": "image_url",
				"image_url": {
					"url": my_b64_img # base64 allows using images without uploading them to the web
				}
			}
		]
	}
]

stream = client.chat.completions.create(
    model="meta-llama/Llama-3.2-11B-Vision-Instruct", 
	messages=messages, 
	max_tokens=500,
	stream=True
)

for chunk in stream:
    print(chunk.choices[0].delta.content, end="")