Spaces:
Paused
Paused
Download test_vision.py from Leon4gr45/phi_inference: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/Leon4gr45/phi_inference/resolve/main/test_vision.py
- Command line
-
hf download hf://spaces/Leon4gr45/phi_inference/test_vision.py
-
curl -L -o test_vision.py https://huggingface.co/spaces/Leon4gr45/phi_inference/resolve/main/test_vision.py
1.13 kB
| """Smoke test: text chat + vision (image_url) against the phi_inference Space.""" | |
| import base64 | |
| import json | |
| import sys | |
| import requests | |
| BASE = "https://Leon4gr45-phi-inference.hf.space" | |
| # 1) text-only | |
| r = requests.post(f"{BASE}/v1/chat/completions", json={ | |
| "model": "lfm2.5-vl-1.6b", | |
| "messages": [{"role": "user", "content": "Say hello in one sentence."}], | |
| "max_tokens": 48, | |
| }, timeout=180) | |
| print("TEXT:", json.dumps(r.json(), indent=2)[:500]) | |
| # 2) vision — pass an image path as argv[1], else skip | |
| if len(sys.argv) > 1: | |
| with open(sys.argv[1], "rb") as f: | |
| b64 = base64.b64encode(f.read()).decode() | |
| r = requests.post(f"{BASE}/v1/chat/completions", json={ | |
| "model": "lfm2.5-vl-1.6b", | |
| "messages": [{"role": "user", "content": [ | |
| {"type": "text", "text": "Describe this image in detail."}, | |
| {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64}"}}, | |
| ]}], | |
| "max_tokens": 256, | |
| }, timeout=300) | |
| print("VISION:", r.json()["choices"][0]["message"]["content"]) | |
| else: | |
| print("(pass an image path as argv[1] to test vision)") | |