Spaces:
Runtime error
Runtime error
Set Capabara theme
Browse files- app.py +38 -4
- static/assets/TM_Capabara_210622.png +0 -0
- style.css +41 -4
app.py
CHANGED
@@ -6,7 +6,7 @@ import spaces
|
|
6 |
import torch
|
7 |
from transformers import AutoModelForCausalLM, AutoProcessor
|
8 |
|
9 |
-
DESCRIPTION = "# Image Captioning with GIT"
|
10 |
|
11 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
12 |
|
@@ -22,12 +22,46 @@ def run(image: PIL.Image.Image) -> str:
|
|
22 |
return processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
23 |
|
24 |
|
25 |
-
with gr.Blocks(
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
input_image = gr.Image(type="pil")
|
28 |
-
run_button = gr.Button("Caption")
|
29 |
output = gr.Textbox(label="Result")
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
run_button.click(
|
32 |
fn=run,
|
33 |
inputs=input_image,
|
|
|
6 |
import torch
|
7 |
from transformers import AutoModelForCausalLM, AutoProcessor
|
8 |
|
9 |
+
DESCRIPTION = "# Capabara - Image Captioning with GIT"
|
10 |
|
11 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
12 |
|
|
|
22 |
return processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
23 |
|
24 |
|
25 |
+
with gr.Blocks(
|
26 |
+
title="Capabara - Image Captioning with GIT",
|
27 |
+
theme=gr.themes.Default(font=[gr.themes.GoogleFont("Work Sans"), "sans-serif"]),
|
28 |
+
css_paths="style.css",
|
29 |
+
) as demo:
|
30 |
+
gr.Image(
|
31 |
+
elem_id="capa-logo",
|
32 |
+
value="./static/assets/TM_Capabara_210622.png",
|
33 |
+
container=False,
|
34 |
+
height=139,
|
35 |
+
width=176,
|
36 |
+
show_download_button=False,
|
37 |
+
show_fullscreen_button=False,
|
38 |
+
)
|
39 |
+
|
40 |
+
gr.HTML(
|
41 |
+
elem_id="capa-title",
|
42 |
+
value="""
|
43 |
+
<h1>Capabara - Image Captioning with GIT</h1>
|
44 |
+
""",
|
45 |
+
)
|
46 |
+
|
47 |
input_image = gr.Image(type="pil")
|
48 |
+
run_button = gr.Button(value="Caption", elem_classes=["capa-btn"])
|
49 |
output = gr.Textbox(label="Result")
|
50 |
|
51 |
+
gr.HTML("""<br/>""")
|
52 |
+
gr.HTML(
|
53 |
+
"""
|
54 |
+
<h4>Reference</h4>
|
55 |
+
<ul>
|
56 |
+
<li>
|
57 |
+
<p>
|
58 |
+
This project uses code from <a href="https://huggingface.co/spaces/hysts/image-captioning-with-git/tree/main" target="_blank">Hysts</a>. Thank you for your contributions!
|
59 |
+
</p>
|
60 |
+
</li>
|
61 |
+
</ul>
|
62 |
+
"""
|
63 |
+
)
|
64 |
+
|
65 |
run_button.click(
|
66 |
fn=run,
|
67 |
inputs=input_image,
|
static/assets/TM_Capabara_210622.png
ADDED
![]() |
style.css
CHANGED
@@ -1,11 +1,48 @@
|
|
|
|
|
|
1 |
h1 {
|
2 |
text-align: center;
|
3 |
display: block;
|
4 |
}
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
8 |
color: #fff;
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
}
|
|
|
1 |
+
@import url("https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap");
|
2 |
+
|
3 |
h1 {
|
4 |
text-align: center;
|
5 |
display: block;
|
6 |
}
|
7 |
|
8 |
+
h1,
|
9 |
+
h4,
|
10 |
+
li,
|
11 |
+
p {
|
12 |
color: #fff;
|
13 |
+
}
|
14 |
+
|
15 |
+
body {
|
16 |
+
font-family: "Work Sans", sans-serif !important;
|
17 |
+
}
|
18 |
+
|
19 |
+
body > gradio-app {
|
20 |
+
background: #0c4a6e !important;
|
21 |
+
}
|
22 |
+
|
23 |
+
#capa-logo {
|
24 |
+
width: 11rem;
|
25 |
+
display: block;
|
26 |
+
margin: 0 auto 0 auto;
|
27 |
+
}
|
28 |
+
|
29 |
+
#capa-logo > div.image-container > button {
|
30 |
+
cursor: default;
|
31 |
+
}
|
32 |
+
|
33 |
+
#capa-logo > div.image-container > button:hover {
|
34 |
+
background-color: transparent !important;
|
35 |
+
}
|
36 |
+
|
37 |
+
#capa-logo > div.image-container > div {
|
38 |
+
display: none;
|
39 |
+
}
|
40 |
+
|
41 |
+
.capa-btn {
|
42 |
+
color: #fff;
|
43 |
+
background: #f2762e;
|
44 |
+
}
|
45 |
+
|
46 |
+
.capa-btn:hover {
|
47 |
+
background: #fc9f53;
|
48 |
}
|