Spaces:
Runtime error
Runtime error
Download vision.py from mtj21/LLaMA_3.1_Vision: direct link, hf CLI and curl.
- Browser
- Download file 887 Bytes
-
https://huggingface.co/spaces/mtj21/LLaMA_3.1_Vision/resolve/main/vision.py
- Command line
-
hf download hf://spaces/mtj21/LLaMA_3.1_Vision/vision.py
-
curl -L -o vision.py https://huggingface.co/spaces/mtj21/LLaMA_3.1_Vision/resolve/main/vision.py
887 Bytes
| from gradio_client import Client, handle_file | |
| cache = {} | |
| client = Client("gokaygokay/Florence-2", verbose=False) | |
| def see_url(url): | |
| result = client.predict( | |
| image=handle_file(url), | |
| task_prompt="More Detailed Caption", | |
| text_input=None, | |
| model_id="microsoft/Florence-2-large", | |
| api_name="/process_image" | |
| ) | |
| return(result[0].replace("{'<MORE_DETAILED_CAPTION>': '", "").replace("'}", "")) | |
| def see_file(fp): | |
| if fp in cache: | |
| return cache[fp] | |
| result = client.predict( | |
| image=handle_file(fp), | |
| task_prompt="More Detailed Caption", | |
| text_input=None, | |
| model_id="microsoft/Florence-2-large", | |
| api_name="/process_image" | |
| ) | |
| r=result[0].replace("{'<MORE_DETAILED_CAPTION>': '", "").replace("'}", "") | |
| cache[fp] = r | |
| return r |