Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,7 +22,7 @@ def get_text_after_colon(input_text):
|
|
| 22 |
# Return the original text if ":" is not found
|
| 23 |
return input_text
|
| 24 |
|
| 25 |
-
def infer(image_input, audience):
|
| 26 |
gr.Info('Calling CLIP Interrogator, ์ด๋ฏธ์ง๋ฅผ ํด์ํ๊ณ ์์ต๋๋ค...')
|
| 27 |
clipi_result = clipi_client.predict(
|
| 28 |
image_input, # str (filepath or URL to image) in 'parameter_3' Image component
|
|
@@ -37,8 +37,9 @@ def infer(image_input, audience):
|
|
| 37 |
I'll give you a simple image caption, please provide a fictional story for a {audience} audience that would fit well with the image. Please be creative, do not worry and only generate a cool fictional story.
|
| 38 |
Here's the image description:
|
| 39 |
'{clipi_result[0]}'
|
|
|
|
|
|
|
| 40 |
ํ๊ตญ์ด๋ก ๋ต๋ณํด์ค.
|
| 41 |
-
|
| 42 |
"""
|
| 43 |
gr.Info('Calling ChatGPT, ์ด์ผ๊ธฐ๋ฅผ ๋ง๋ค๊ณ ์์ต๋๋ค...')
|
| 44 |
#result = client.predict(
|
|
@@ -131,10 +132,13 @@ with gr.Blocks(css=css) as demo:
|
|
| 131 |
<p style="text-align: center">ChatGPT ์๋ต์ด ์ค๋ ์ง์ฐ๋๊ฑฐ๋ ์ฌ์ฉ์ ํ์ผ๋ก ์๋ ๋๊ฐ ์์ต๋๋ค.</p>
|
| 132 |
"""
|
| 133 |
)
|
|
|
|
| 134 |
with gr.Row():
|
| 135 |
with gr.Column():
|
| 136 |
image_in = gr.Image(label="์ด๋ฏธ์ง ์
๋ ฅ", type="filepath", elem_id="image-in", height=420)
|
| 137 |
audience = gr.Radio(label="๋์", choices=["Children", "Adult"], value="Children")
|
|
|
|
|
|
|
| 138 |
submit_btn = gr.Button('๊ธ์ ๋ง๋ค์ด ์ฃผ์ธ์')
|
| 139 |
with gr.Column():
|
| 140 |
#caption = gr.Textbox(label="Generated Caption")
|
|
@@ -151,8 +155,9 @@ with gr.Blocks(css=css) as demo:
|
|
| 151 |
outputs=[story, share_group],
|
| 152 |
cache_examples=True
|
| 153 |
)
|
| 154 |
-
|
| 155 |
-
submit_btn.click(fn=infer, inputs=[image_in, audience], outputs=[story, share_group])
|
|
|
|
| 156 |
share_button.click(None, [], [], _js=share_js)
|
| 157 |
|
| 158 |
demo.queue(max_size=12).launch()
|
|
|
|
| 22 |
# Return the original text if ":" is not found
|
| 23 |
return input_text
|
| 24 |
|
| 25 |
+
def infer(image_input, audience, keyword, protagonist):
|
| 26 |
gr.Info('Calling CLIP Interrogator, ์ด๋ฏธ์ง๋ฅผ ํด์ํ๊ณ ์์ต๋๋ค...')
|
| 27 |
clipi_result = clipi_client.predict(
|
| 28 |
image_input, # str (filepath or URL to image) in 'parameter_3' Image component
|
|
|
|
| 37 |
I'll give you a simple image caption, please provide a fictional story for a {audience} audience that would fit well with the image. Please be creative, do not worry and only generate a cool fictional story.
|
| 38 |
Here's the image description:
|
| 39 |
'{clipi_result[0]}'
|
| 40 |
+
Keyword: {keyword}
|
| 41 |
+
Protagonist: {protagonist}
|
| 42 |
ํ๊ตญ์ด๋ก ๋ต๋ณํด์ค.
|
|
|
|
| 43 |
"""
|
| 44 |
gr.Info('Calling ChatGPT, ์ด์ผ๊ธฐ๋ฅผ ๋ง๋ค๊ณ ์์ต๋๋ค...')
|
| 45 |
#result = client.predict(
|
|
|
|
| 132 |
<p style="text-align: center">ChatGPT ์๋ต์ด ์ค๋ ์ง์ฐ๋๊ฑฐ๋ ์ฌ์ฉ์ ํ์ผ๋ก ์๋ ๋๊ฐ ์์ต๋๋ค.</p>
|
| 133 |
"""
|
| 134 |
)
|
| 135 |
+
|
| 136 |
with gr.Row():
|
| 137 |
with gr.Column():
|
| 138 |
image_in = gr.Image(label="์ด๋ฏธ์ง ์
๋ ฅ", type="filepath", elem_id="image-in", height=420)
|
| 139 |
audience = gr.Radio(label="๋์", choices=["Children", "Adult"], value="Children")
|
| 140 |
+
keyword_in = gr.Textbox(label="ํต์ฌ ํค์๋") # ํต์ฌ ํค์๋ ์
๋ ฅ ์์
|
| 141 |
+
protagonist_in = gr.Textbox(label="์ฃผ์ธ๊ณต") # ์ฃผ์ธ๊ณต ์
๋ ฅ ์์
|
| 142 |
submit_btn = gr.Button('๊ธ์ ๋ง๋ค์ด ์ฃผ์ธ์')
|
| 143 |
with gr.Column():
|
| 144 |
#caption = gr.Textbox(label="Generated Caption")
|
|
|
|
| 155 |
outputs=[story, share_group],
|
| 156 |
cache_examples=True
|
| 157 |
)
|
| 158 |
+
|
| 159 |
+
submit_btn.click(fn=infer, inputs=[image_in, audience, keyword_in, protagonist_in], outputs=[story, share_group])
|
| 160 |
+
# submit_btn.click(fn=infer, inputs=[image_in, audience], outputs=[story, share_group])
|
| 161 |
share_button.click(None, [], [], _js=share_js)
|
| 162 |
|
| 163 |
demo.queue(max_size=12).launch()
|