Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,6 @@ from gradio_client.client import Job
|
|
9 |
|
10 |
DESCRIPTION = "# Comparing image captioning models"
|
11 |
ORIGINAL_SPACE_INFO = """\
|
12 |
-
- [BLIP fine-tuned for Long Captions](https://huggingface.co/spaces/unography/image-captioning-with-longcap)
|
13 |
- [GIT-large fine-tuned on COCO](https://huggingface.co/spaces/library-samples/image-captioning-with-git)
|
14 |
- [BLIP-large](https://huggingface.co/spaces/library-samples/image-captioning-with-blip)
|
15 |
- [BLIP-2 OPT 6.7B](https://huggingface.co/spaces/merve/BLIP2-with-transformers)
|
@@ -46,15 +45,6 @@ def generate_caption_blip(image_path: str, return_job: bool = False) -> str | Jo
|
|
46 |
gr.Warning("The BLIP-large Space is currently unavailable. Please try again later.")
|
47 |
return ""
|
48 |
|
49 |
-
def generate_caption_longcap(image_path: str, return_job: bool = False) -> str | Job:
|
50 |
-
try:
|
51 |
-
client = Client("unography/image-captioning-with-longcap")
|
52 |
-
fn = client.submit if return_job else client.predict
|
53 |
-
return fn(image_path, "A picture of", api_name="/caption")
|
54 |
-
except Exception:
|
55 |
-
gr.Warning("The BLIP-LongCaptions Space is currently unavailable. Please try again later.")
|
56 |
-
return ""
|
57 |
-
|
58 |
|
59 |
def generate_caption_blip2_opt(image_path: str, return_job: bool = False) -> str | Job:
|
60 |
try:
|
@@ -126,9 +116,8 @@ def generate_caption_fuyu(image_path: str, return_job: bool = False) -> str | Jo
|
|
126 |
return ""
|
127 |
|
128 |
|
129 |
-
def generate_captions(image_path: str) -> tuple[str, str, str, str, str, str
|
130 |
jobs = [
|
131 |
-
generate_caption_longcap(image_path, return_job=True),
|
132 |
generate_caption_git(image_path, return_job=True),
|
133 |
generate_caption_blip(image_path, return_job=True),
|
134 |
generate_caption_blip2_opt(image_path, return_job=True),
|
@@ -146,7 +135,6 @@ with gr.Blocks(css="style.css") as demo:
|
|
146 |
input_image = gr.Image(type="filepath")
|
147 |
run_button = gr.Button("Caption")
|
148 |
with gr.Column():
|
149 |
-
out_longcap = gr.Textbox(label="BLIP fine-tuned for long captions")
|
150 |
out_git = gr.Textbox(label="GIT-large fine-tuned on COCO")
|
151 |
out_blip = gr.Textbox(label="BLIP-large")
|
152 |
out_blip2_opt = gr.Textbox(label="BLIP-2 OPT 6.7B")
|
@@ -155,7 +143,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
155 |
out_fuyu = gr.Textbox(label="Fuyu-8B")
|
156 |
|
157 |
outputs = [
|
158 |
-
|
159 |
out_blip,
|
160 |
out_blip2_opt,
|
161 |
out_blip2_t5xxl,
|
|
|
9 |
|
10 |
DESCRIPTION = "# Comparing image captioning models"
|
11 |
ORIGINAL_SPACE_INFO = """\
|
|
|
12 |
- [GIT-large fine-tuned on COCO](https://huggingface.co/spaces/library-samples/image-captioning-with-git)
|
13 |
- [BLIP-large](https://huggingface.co/spaces/library-samples/image-captioning-with-blip)
|
14 |
- [BLIP-2 OPT 6.7B](https://huggingface.co/spaces/merve/BLIP2-with-transformers)
|
|
|
45 |
gr.Warning("The BLIP-large Space is currently unavailable. Please try again later.")
|
46 |
return ""
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
def generate_caption_blip2_opt(image_path: str, return_job: bool = False) -> str | Job:
|
50 |
try:
|
|
|
116 |
return ""
|
117 |
|
118 |
|
119 |
+
def generate_captions(image_path: str) -> tuple[str, str, str, str, str, str]:
|
120 |
jobs = [
|
|
|
121 |
generate_caption_git(image_path, return_job=True),
|
122 |
generate_caption_blip(image_path, return_job=True),
|
123 |
generate_caption_blip2_opt(image_path, return_job=True),
|
|
|
135 |
input_image = gr.Image(type="filepath")
|
136 |
run_button = gr.Button("Caption")
|
137 |
with gr.Column():
|
|
|
138 |
out_git = gr.Textbox(label="GIT-large fine-tuned on COCO")
|
139 |
out_blip = gr.Textbox(label="BLIP-large")
|
140 |
out_blip2_opt = gr.Textbox(label="BLIP-2 OPT 6.7B")
|
|
|
143 |
out_fuyu = gr.Textbox(label="Fuyu-8B")
|
144 |
|
145 |
outputs = [
|
146 |
+
out_git,
|
147 |
out_blip,
|
148 |
out_blip2_opt,
|
149 |
out_blip2_t5xxl,
|