Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
import os
|
4 |
hf_token = os.environ.get('HF_TOKEN')
|
@@ -46,11 +47,65 @@ def infer(image_input):
|
|
46 |
|
47 |
result = get_text_after_colon(result)
|
48 |
|
49 |
-
return result
|
50 |
|
51 |
css="""
|
52 |
#col-container {max-width: 910px; margin-left: auto; margin-right: auto;}
|
53 |
a {text-decoration-line: underline; font-weight: 600;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
"""
|
55 |
|
56 |
with gr.Blocks(css=css) as demo:
|
@@ -63,17 +118,24 @@ with gr.Blocks(css=css) as demo:
|
|
63 |
)
|
64 |
with gr.Row():
|
65 |
with gr.Column():
|
66 |
-
image_in = gr.Image(label="Image input", type="filepath")
|
67 |
submit_btn = gr.Button('Tell me a story')
|
68 |
with gr.Column():
|
69 |
#caption = gr.Textbox(label="Generated Caption")
|
70 |
-
story = gr.Textbox(label="generated Story")
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
gr.Examples(examples=[["./examples/crabby.png"],["./examples/hopper.jpeg"]],
|
72 |
fn=infer,
|
73 |
inputs=[image_in],
|
74 |
-
outputs=[story],
|
75 |
cache_examples=True
|
76 |
)
|
77 |
-
submit_btn.click(fn=infer, inputs=[image_in], outputs=[story])
|
|
|
78 |
|
79 |
demo.queue(max_size=12).launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from share_btn import community_icon_html, loading_icon_html, share_js
|
3 |
|
4 |
import os
|
5 |
hf_token = os.environ.get('HF_TOKEN')
|
|
|
47 |
|
48 |
result = get_text_after_colon(result)
|
49 |
|
50 |
+
return result, gr.Group.update(visible=True)
|
51 |
|
52 |
css="""
|
53 |
#col-container {max-width: 910px; margin-left: auto; margin-right: auto;}
|
54 |
a {text-decoration-line: underline; font-weight: 600;}
|
55 |
+
a {text-decoration-line: underline; font-weight: 600;}
|
56 |
+
.animate-spin {
|
57 |
+
animation: spin 1s linear infinite;
|
58 |
+
}
|
59 |
+
@keyframes spin {
|
60 |
+
from {
|
61 |
+
transform: rotate(0deg);
|
62 |
+
}
|
63 |
+
to {
|
64 |
+
transform: rotate(360deg);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
#share-btn-container {
|
68 |
+
display: flex;
|
69 |
+
padding-left: 0.5rem !important;
|
70 |
+
padding-right: 0.5rem !important;
|
71 |
+
background-color: #000000;
|
72 |
+
justify-content: center;
|
73 |
+
align-items: center;
|
74 |
+
border-radius: 9999px !important;
|
75 |
+
max-width: 13rem;
|
76 |
+
}
|
77 |
+
div#share-btn-container > div {
|
78 |
+
flex-direction: row;
|
79 |
+
background: black;
|
80 |
+
align-items: center;
|
81 |
+
}
|
82 |
+
#share-btn-container:hover {
|
83 |
+
background-color: #060606;
|
84 |
+
}
|
85 |
+
#share-btn {
|
86 |
+
all: initial;
|
87 |
+
color: #ffffff;
|
88 |
+
font-weight: 600;
|
89 |
+
cursor:pointer;
|
90 |
+
font-family: 'IBM Plex Sans', sans-serif;
|
91 |
+
margin-left: 0.5rem !important;
|
92 |
+
padding-top: 0.5rem !important;
|
93 |
+
padding-bottom: 0.5rem !important;
|
94 |
+
right:0;
|
95 |
+
}
|
96 |
+
#share-btn * {
|
97 |
+
all: unset;
|
98 |
+
}
|
99 |
+
#share-btn-container div:nth-child(-n+2){
|
100 |
+
width: auto !important;
|
101 |
+
min-height: 0px !important;
|
102 |
+
}
|
103 |
+
#share-btn-container .wrap {
|
104 |
+
display: none !important;
|
105 |
+
}
|
106 |
+
#share-btn-container.hidden {
|
107 |
+
display: none!important;
|
108 |
+
}
|
109 |
"""
|
110 |
|
111 |
with gr.Blocks(css=css) as demo:
|
|
|
118 |
)
|
119 |
with gr.Row():
|
120 |
with gr.Column():
|
121 |
+
image_in = gr.Image(label="Image input", type="filepath", elem_id="image_in")
|
122 |
submit_btn = gr.Button('Tell me a story')
|
123 |
with gr.Column():
|
124 |
#caption = gr.Textbox(label="Generated Caption")
|
125 |
+
story = gr.Textbox(label="generated Story", elem_id="story")
|
126 |
+
|
127 |
+
with gr.Group(elem_id="share-btn-container", visible=False) as share_group:
|
128 |
+
community_icon = gr.HTML(community_icon_html)
|
129 |
+
loading_icon = gr.HTML(loading_icon_html)
|
130 |
+
share_button = gr.Button("Share to community", elem_id="share-btn")
|
131 |
+
|
132 |
gr.Examples(examples=[["./examples/crabby.png"],["./examples/hopper.jpeg"]],
|
133 |
fn=infer,
|
134 |
inputs=[image_in],
|
135 |
+
outputs=[story, share_group],
|
136 |
cache_examples=True
|
137 |
)
|
138 |
+
submit_btn.click(fn=infer, inputs=[image_in], outputs=[story, share_group])
|
139 |
+
share_button.click(None, [], [], _js=share_js)
|
140 |
|
141 |
demo.queue(max_size=12).launch()
|