Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ INFERENCE_ENDPOINT = "https://your-endpoint-url" # Replace with your endpoint U
|
|
| 8 |
API_TOKEN = "your-api-token" # Replace with your Hugging Face API token
|
| 9 |
|
| 10 |
#Image-to-text endpoint
|
| 11 |
-
def get_completion(inputs, parameters=None, endpoint_url=
|
| 12 |
headers = {
|
| 13 |
"Authorization": f"Bearer {API_TOKEN}",
|
| 14 |
"Content-Type": "application/json"
|
|
@@ -16,7 +16,7 @@ def get_completion(inputs, parameters=None, endpoint_url=endpoint_url):
|
|
| 16 |
data = {"inputs": inputs}
|
| 17 |
if parameters is not None:
|
| 18 |
data.update({"parameters": parameters})
|
| 19 |
-
response = requests.post(
|
| 20 |
return json.loads(response.content.decode("utf-8"))
|
| 21 |
|
| 22 |
def get_generation(model, processor, image, dtype):
|
|
|
|
| 8 |
API_TOKEN = "your-api-token" # Replace with your Hugging Face API token
|
| 9 |
|
| 10 |
#Image-to-text endpoint
|
| 11 |
+
def get_completion(inputs, parameters=None, endpoint_url=INFERENCE_ENDPOINT):
|
| 12 |
headers = {
|
| 13 |
"Authorization": f"Bearer {API_TOKEN}",
|
| 14 |
"Content-Type": "application/json"
|
|
|
|
| 16 |
data = {"inputs": inputs}
|
| 17 |
if parameters is not None:
|
| 18 |
data.update({"parameters": parameters})
|
| 19 |
+
response = requests.post(endpoint_url, headers=headers, data=json.dumps(data))
|
| 20 |
return json.loads(response.content.decode("utf-8"))
|
| 21 |
|
| 22 |
def get_generation(model, processor, image, dtype):
|