Spaces:
Runtime error
Runtime error
kittchy
commited on
Commit
•
6b7bb3b
1
Parent(s):
1e76352
[FIX] トップ5まで出せるように修正
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
from model import MLModel
|
4 |
from dotenv import load_dotenv
|
@@ -22,16 +23,29 @@ def save(image_path: str):
|
|
22 |
|
23 |
def search(prompt: str):
|
24 |
urls = model.search(prompt)
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
|
28 |
with gr.Blocks() as app:
|
29 |
# Rowでレイアウトを定義
|
|
|
30 |
input = gr.Textbox(placeholder="可愛いワンコ", label="検索")
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
32 |
btn = gr.Button("検索")
|
33 |
-
btn.click(
|
|
|
|
|
34 |
|
|
|
35 |
save_image = gr.Image(type="filepath")
|
36 |
result = gr.Text(label="upload結果")
|
37 |
save_btn = gr.Button("保存")
|
|
|
1 |
import gradio as gr
|
2 |
+
from gradio.components import label
|
3 |
|
4 |
from model import MLModel
|
5 |
from dotenv import load_dotenv
|
|
|
23 |
|
24 |
def search(prompt: str):
|
25 |
urls = model.search(prompt)
|
26 |
+
result = [None] * 5
|
27 |
+
for i, url in enumerate(urls):
|
28 |
+
result[i] = url
|
29 |
+
|
30 |
+
return result
|
31 |
|
32 |
|
33 |
with gr.Blocks() as app:
|
34 |
# Rowでレイアウトを定義
|
35 |
+
gr.Label("自然言語画像検索(左から検索ランキングが高い)")
|
36 |
input = gr.Textbox(placeholder="可愛いワンコ", label="検索")
|
37 |
+
with gr.Row():
|
38 |
+
output1 = gr.Image(type="filepath", label="ランキング1")
|
39 |
+
output2 = gr.Image(type="filepath", label="ランキング2")
|
40 |
+
output3 = gr.Image(type="filepath", label="ランキング3")
|
41 |
+
output4 = gr.Image(type="filepath", label="ランキング4")
|
42 |
+
output5 = gr.Image(type="filepath", label="ランキング5")
|
43 |
btn = gr.Button("検索")
|
44 |
+
btn.click(
|
45 |
+
fn=search, inputs=input, outputs=[output1, output2, output3, output4, output5]
|
46 |
+
)
|
47 |
|
48 |
+
gr.Label("画像保存")
|
49 |
save_image = gr.Image(type="filepath")
|
50 |
result = gr.Text(label="upload結果")
|
51 |
save_btn = gr.Button("保存")
|