Commit
·
295ed9e
1
Parent(s):
09f19d8
Update app.py
Browse filesRemoved some models and added some others
app.py
CHANGED
|
@@ -20,17 +20,15 @@ endpoint_base_url = "https://api-inference.huggingface.co/models/"
|
|
| 20 |
endpoints = [
|
| 21 |
"Salesforce/blip-image-captioning-large",
|
| 22 |
"Salesforce/blip-image-captioning-base",
|
| 23 |
-
"Salesforce/blip2-opt-2.7b",
|
| 24 |
-
"Salesforce/instructblip-vicuna-7b",
|
| 25 |
-
"Salesforce/instructblip-flan-t5-xl",
|
| 26 |
-
"facebook/nougat-base",
|
| 27 |
"nlpconnect/vit-gpt2-image-captioning",
|
| 28 |
-
"jinhybr/OCR-Donut-CORD",
|
| 29 |
"microsoft/git-base",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
"Norm/nougat-latex-base",
|
|
|
|
| 31 |
]
|
| 32 |
-
## Test later:
|
| 33 |
-
# "microsoft/kosmos-2-patch14-224",
|
| 34 |
|
| 35 |
|
| 36 |
# --- Define helper functions ---
|
|
@@ -77,13 +75,12 @@ def captioner(image):
|
|
| 77 |
results = get_completion(base64_image)
|
| 78 |
captions = []
|
| 79 |
for endpoint, result in results.items():
|
| 80 |
-
model_name = endpoint.split("/")[-1] # Extract the model name from the endpoint
|
| 81 |
if "error" not in result:
|
| 82 |
caption = (
|
| 83 |
-
f"**{
|
| 84 |
)
|
| 85 |
else:
|
| 86 |
-
caption = f"**{model_name.upper()}**: \n Error - {result['error']} \n\n\n "
|
| 87 |
captions.append(caption)
|
| 88 |
return "".join(captions) # Join all captions into a single string
|
| 89 |
|
|
|
|
| 20 |
endpoints = [
|
| 21 |
"Salesforce/blip-image-captioning-large",
|
| 22 |
"Salesforce/blip-image-captioning-base",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
"nlpconnect/vit-gpt2-image-captioning",
|
|
|
|
| 24 |
"microsoft/git-base",
|
| 25 |
+
"microsoft/kosmos-2-patch14-224",
|
| 26 |
+
"microsoft/git-large-textcaps",
|
| 27 |
+
"microsoft/git-large-r-coco",
|
| 28 |
+
"facebook/nougat-base",
|
| 29 |
"Norm/nougat-latex-base",
|
| 30 |
+
"bipin/image-caption-generator",
|
| 31 |
]
|
|
|
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
# --- Define helper functions ---
|
|
|
|
| 75 |
results = get_completion(base64_image)
|
| 76 |
captions = []
|
| 77 |
for endpoint, result in results.items():
|
|
|
|
| 78 |
if "error" not in result:
|
| 79 |
caption = (
|
| 80 |
+
f"**{endpoint}**: \n\n {result[0]['generated_text']} \n\n\n "
|
| 81 |
)
|
| 82 |
else:
|
| 83 |
+
caption = f"**{model_name.upper()}**: \n\n Error - {result['error']} \n\n\n "
|
| 84 |
captions.append(caption)
|
| 85 |
return "".join(captions) # Join all captions into a single string
|
| 86 |
|