Spaces:
Sleeping
Sleeping
Download scripts/testing/test_predictor.py from Kurtgitgit/mission17-ai: direct link, hf CLI and curl.
- Browser
- Download file 781 Bytes
-
https://huggingface.co/spaces/Kurtgitgit/mission17-ai/resolve/main/scripts/testing/test_predictor.py
- Command line
-
hf download hf://spaces/Kurtgitgit/mission17-ai/scripts/testing/test_predictor.py
-
curl -L -o test_predictor.py https://huggingface.co/spaces/Kurtgitgit/mission17-ai/resolve/main/scripts/testing/test_predictor.py
781 Bytes
| import sys | |
| import os | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) | |
| from utils.predictor import Predictor | |
| def test_ollama(): | |
| print("Testing Ollama Predictor...") | |
| p = Predictor() | |
| print(f"Model configured: {p.get_model_name()}") | |
| # We will just see if we can reach the API | |
| # Since we need an image, let's create a dummy 1x1 black pixel image | |
| import io | |
| from PIL import Image | |
| img = Image.new('RGB', (10, 10), color = 'black') | |
| img_byte_arr = io.BytesIO() | |
| img.save(img_byte_arr, format='PNG') | |
| img_bytes = img_byte_arr.getvalue() | |
| print("Sending dummy image to Ollama...") | |
| res = p.predict(img_bytes) | |
| print("Response:", res) | |
| if __name__ == "__main__": | |
| test_ollama() | |