Views
No views yet
builder.py, conversation.py, inference.py, model_UI.py, and mm_utils.py locally.1wget https://huggingface.co/jadechoghari/Ferret-UI-Gemma2b/raw/main/conversation.py
2wget https://huggingface.co/jadechoghari/Ferret-UI-Gemma2b/raw/main/builder.py
3wget https://huggingface.co/jadechoghari/Ferret-UI-Gemma2b/raw/main/inference.py
4wget https://huggingface.co/jadechoghari/Ferret-UI-Gemma2b/raw/main/model_UI.py
5wget https://huggingface.co/jadechoghari/Ferret-UI-Gemma2b/raw/main/mm_utils.py1from inference import inference_and_run
2image_path = "appstore_reminders.png"
3prompt = "Describe the image in details"
4
5# Call the function without a box
6inference_text = inference_and_run(image_path, prompt, conv_mode="ferret_gemma_instruct", model_path="jadechoghari/Ferret-UI-Gemma2b")
7
8# Output processed text
9print("Inference Text:", inference_text)1# Task with bounding boxes
2image_path = "appstore_reminders.png"
3prompt = "What's inside the selected region?"
4box = [189, 906, 404, 970]
5
6inference_text = inference_and_run(
7 image_path=image_path,
8 prompt=prompt,
9 conv_mode="ferret_gemma_instruct",
10 model_path="jadechoghari/Ferret-UI-Gemma2b",
11 box=box
12)
13# you could also pass process_image=True
14# to output: processed_image, inference_text = inference_and_run(...., process_image=True)
15
16print("Inference Text:", inference_text)1# GROUNDING PROMPTS
2GROUNDING_TEMPLATES = [
3 '\nProvide the bounding boxes of the mentioned objects.',
4 '\nInclude the coordinates for each mentioned object.',
5 '\nLocate the objects with their coordinates.',
6 '\nAnswer in [x1, y1, x2, y2] format.',
7 '\nMention the objects and their locations using the format [x1, y1, x2, y2].',
8 '\nDraw boxes around the mentioned objects.',
9 '\nUse boxes to show where each thing is.',
10 '\nTell me where the objects are with coordinates.',
11 '\nList where each object is with boxes.',
12 '\nShow me the regions with boxes.'
13]