Spaces:
Paused
Paused
Download utils.py from Salesforce/BLIP2: direct link, hf CLI and curl.
- Browser
- Download file 682 Bytes
-
https://huggingface.co/spaces/Salesforce/BLIP2/resolve/66be1aee5c7f7d913aeedb8564d73efc8bdd2feb/utils.py
- Command line
-
hf download hf://spaces/Salesforce/BLIP2@66be1aee5c7f7d913aeedb8564d73efc8bdd2feb/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/Salesforce/BLIP2/resolve/66be1aee5c7f7d913aeedb8564d73efc8bdd2feb/utils.py
682 Bytes
| import os | |
| import requests | |
| class Endpoint: | |
| def __init__(self): | |
| self.config_path = "https://storage.googleapis.com/sfr-vision-language-research/LAVIS/projects/blip2/config.json" | |
| self._url = None | |
| def url(self): | |
| if self._url is None: | |
| self._url = self.get_url() | |
| return self._url | |
| def get_url(self): | |
| response = requests.get(self.config_path) | |
| config = response.json() | |
| return config["endpoint"] | |
| def get_token(): | |
| token = os.environ.get("auth_token") | |
| if token is None: | |
| raise ValueError("auth-token not found in environment variables") | |
| return token | |